Skip to content

ci: add dependency audit workflow #43

ci: add dependency audit workflow

ci: add dependency audit workflow #43

Workflow file for this run

name: Security Audit
permissions:
contents: read
on:
push:
branches: ["main"]
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: "17 4 * * 1"
workflow_dispatch:
jobs:
dependency-audit:
name: Dependency audit (${{ matrix.os }}, Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 2
- name: Install uv
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: ${{ matrix.python-version }}
# The committed .github/security-audit-requirements.txt is generated with
# --universal (resolves across all interpreters/platforms) and is what
# push/PR runs audit. The scheduled job instead compiles per matrix
# entry with --python-version so it can surface advisories in wheels that
# only resolve on a specific interpreter (e.g. 3.11-only) — coverage the
# universal file may not exercise. This broadening is intentional; PR runs
# trade that depth for determinism against the committed snapshot.
- name: Compile scheduled audit requirements
if: ${{ github.event_name == 'schedule' }}
run: |
uv pip compile pyproject.toml --extra test --python-version "${{ matrix.python-version }}" --upgrade --generate-hashes --quiet --output-file "${{ runner.temp }}/spec-kit-audit-requirements.txt"
- name: Run pip-audit (scheduled live resolution)
if: ${{ github.event_name == 'schedule' }}
run: uvx --from pip-audit==2.10.0 pip-audit --disable-pip --require-hashes -r "${{ runner.temp }}/spec-kit-audit-requirements.txt" --progress-spinner off
- name: Check committed audit requirements are current
if: ${{ github.event_name != 'schedule' }}
env:
DEPENDENCY_DIFF_BASE: ${{ github.event.pull_request.base.sha || github.event.before || '' }}
DEPENDENCY_DIFF_HEAD: ${{ github.sha }}
GENERATED_REQUIREMENTS: ${{ runner.temp }}/security-audit-requirements.txt
run: python .github/scripts/check_security_requirements.py
- name: Run pip-audit (committed requirements)
if: ${{ github.event_name != 'schedule' }}
run: uvx --from pip-audit==2.10.0 pip-audit --disable-pip --require-hashes -r .github/security-audit-requirements.txt --progress-spinner off