From ff69ab67f75e9e0cdf7eaf19e5d221b756b8822b Mon Sep 17 00:00:00 2001 From: Jay Qi <2721979+jayqi@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:19:56 -0500 Subject: [PATCH] Harden CI workflow permissions and add zizmor, all-green, and Dependabot Assisted-by: Claude Opus 5.5 --- .github/dependabot.yml | 12 ++++++++++ .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++-------- AGENTS.md | 1 + CONTRIBUTING.md | 1 + justfile | 5 +++++ 5 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..1be97f6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: monthly + groups: + actions: + patterns: + - "*" + cooldown: + default-days: 7 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58c3797..bd38510 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,21 +17,22 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: true -permissions: - contents: read +permissions: {} jobs: lint: name: Lint runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 with: just-version: "1.55.0" # Keep in sync with minimum-version in justfile - - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: cache-suffix: lint - name: Check the lockfile is up to date @@ -43,9 +44,24 @@ jobs: just codegen git diff --exit-code src/pdc_api_client/_generated.py + zizmor: + name: Zizmor audit + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: zizmorcore/zizmor-action@53290badfa369cb0bf7ad16342cb62c2fa47ac7b # v0.8.0 + with: + advanced-security: false + test: name: Unit tests and type checks (Python ${{ matrix.python }}${{ matrix.lowest_direct && ', lowest direct dependencies' || '' }}) runs-on: ubuntu-latest + permissions: + contents: read strategy: fail-fast: false matrix: @@ -57,10 +73,10 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 with: just-version: "1.55.0" # Keep in sync with minimum-version in justfile - - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: cache-suffix: tests-py${{ matrix.python }}${{ matrix.lowest_direct && '-lowest-direct' || '' }} - run: just test --python="$PYTHON" ${LOWEST_DIRECT:+--lowest-direct} ${UPGRADE:+--upgrade} @@ -77,6 +93,8 @@ jobs: integration: name: Integration tests runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -92,10 +110,10 @@ jobs: working-directory: service run: docker compose -f compose-ci.yml up -d --wait timeout-minutes: 5 - - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4 + - uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0 with: just-version: "1.55.0" # Keep in sync with minimum-version in justfile - - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 + - uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3 with: cache-suffix: integration - run: just integration ${UPGRADE:+--upgrade} @@ -103,9 +121,20 @@ jobs: env: UPGRADE: ${{ (github.event_name == 'schedule' || inputs.upgrade) && 'true' || '' }} + all-green: + name: All green + if: always() + needs: [lint, zizmor, test, integration] + runs-on: ubuntu-latest + permissions: {} + steps: + - uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0 + with: + jobs: ${{ toJSON(needs) }} + notify: name: Notify failed build - needs: [lint, test, integration] + needs: [lint, zizmor, test, integration] if: failure() && (github.event_name == 'push' || github.event_name == 'schedule') runs-on: ubuntu-latest permissions: diff --git a/AGENTS.md b/AGENTS.md index 6814a39..17b4061 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,6 +26,7 @@ A framework-free Python client for the Philanthropy Data Commons (PDC) API. The - `just test [--python VERSION] [--lowest-direct] [--upgrade] [-- ARGS]` runs the unit tests, which mock all HTTP with `responses`. `just integration` takes the same options. Both run against the installed package in an isolated environment, with the versions in `uv.lock` unless `--lowest-direct` or `--upgrade` resolves them fresh. Arguments after `--` go to pytest. - `just pdc up` starts PDC's CI stack in Docker; `just integration` runs the live suite against it. - `just typecheck` runs mypy (with the pydantic plugin) over `src` and both test suites, mypy in strict mode over `src`, then pyrefly and ty over `src` and both test suites, and fails at the end if any of them failed. `just typecheck-mypy`, `just typecheck-pyrefly`, and `just typecheck-ty` run one checker each. All take `--python` and `--lowest-direct`, which work as they do for `just test`. +- `just zizmor` audits the GitHub Actions workflows; run it after changing anything in `.github/`. It runs offline audits only unless `GH_TOKEN` is set. Arguments go to zizmor. - Verify with `just check` (lint, type checks, and both suites). The unit tests can't catch a change in PDC's behavior; if the stack isn't available, run `just lint`, `just typecheck`, and `just test` and say that integration verification is pending. ## Standards diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4512a21..6f2a94e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,7 @@ We use [uv](https://docs.astral.sh/uv/) and [just](https://just.systems): uv sync just test # unit tests, no network just typecheck # mypy, pyrefly, and ty +just zizmor # audit the GitHub Actions workflows just pdc up # start PDC's CI stack in Docker just integration # integration tests against that stack just check # lint, type checks, unit tests, and integration tests diff --git a/justfile b/justfile index 0e98837..53f3ea8 100644 --- a/justfile +++ b/justfile @@ -20,6 +20,11 @@ format: uv run ruff format . uv run ruff check . --fix +# Audit GitHub Actions workflows with zizmor (passes through args) +[group('dev')] +zizmor *args: + uvx --exclude-newer "7 days" zizmor .github/ {{args}} + # Run all three type checkers, failing at the end if any failed [group('dev')] [arg("python", long)]