Harden GitHub Actions workflows - #2262
Open
rly wants to merge 6 commits into
Open
Conversation
Add least-privilege `permissions: contents: read` to every workflow, with elevated scopes declared only on the jobs that need them. Pin every action to a full commit SHA with a version comment. Five actions publish GitHub immutable releases, whose tags cannot be reassigned; they are pinned to a version tag and exempted in .github/zizmor.yml. Set `persist-credentials: false` on every checkout. No workflow pushes with the checkout credentials. Add .github/actions/setup-python-tox, a composite action that sets up Python with pip caching and installs tox, referenced with the self-repository `$/` syntax so it resolves to the running commit without a checkout. Add .github/workflows/zizmor.yml, which audits .github/ on changes to it, and .github/dependabot.yml, which tracks action updates weekly with a 7-day cooldown after publication. In run_coverage.yml, rename the codecov-action `file` input to `files`; `file` was removed in codecov-action v5 and was being ignored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Move `concurrency` from the workflow level down to each job, keyed on the
matrix entry, so a superseding run cancels each matrix leg individually.
Tag-triggered `deploy_release.yml` and issue-triggered `project_action.yml`
stay ungrouped, since neither should be cancelled by a later run.
generate_test_files.yml named its job `${{ matrix.os }}`, a key its matrix
does not define, so every job rendered with a blank name. Use `matrix.name`.
run_dandi_read_tests.yml sets up Python with `actions/setup-python` and
installs into it with pip, so its conda reporting step described the runner's
preinstalled conda rather than the environment under test.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Give every job a `timeout-minutes` backstop in place of the 6-hour default, sized at roughly three times the maximum runtime measured over recent successful runs. Cache pip downloads on the workflows that were still downloading everything each run. Caching is off for the two jobs whose distributions are published, so a release and the rolling "latest" pre-release are built from a cold cache; `setup-python-tox` takes a `pip-cache` input to select this. Skip the Codecov upload on a pull request from a fork. `CODECOV_TOKEN` is not exposed there, and `fail_ci_if_error: true` turned that into a failure on every external contributor's pull request. The tests themselves still run. Delete the "Generate test files" workflow. Running src/pynwb/testing/make_test_files.py under an old PyNWB generates the back-compat files when they are needed. Shallow-clone NWB Inspector, keep its tox pin consistent with run_all_tests, and expire the `distributions` artifact after a day, since the deploy-dev job consumes it within the same run. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2262 +/- ##
=======================================
Coverage 96.17% 96.17%
=======================================
Files 30 30
Lines 3003 3003
Branches 437 437
=======================================
Hits 2888 2888
Misses 65 65
Partials 50 50
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rly
marked this pull request as ready for review
September 2, 2026 22:52
These are all internal CI changes; the detail belongs in the pull request. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
zizmor-action carries the zizmor version it runs, pinned by container image digest, so Dependabot keeps zizmor current by bumping the action. A version inside a `run:` step is invisible to Dependabot and has to be bumped by hand. The action publishes immutable releases, so it takes a version tag under the policy in .github/zizmor.yml. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4 tasks
Run Codespell on pull requests and on manual dispatch. The branch filters were redundant with the pull request trigger, and the push trigger re-ran the check on dev after it had already passed on the pull request. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Ports the GitHub Actions hardening from hdmf-dev/hdmf#1518, plus a few CI fixes found along the way.
Least-privilege
permissions, SHA-pinned actions,persist-credentials: false, asetup-python-toxcomposite action, Dependabot for actions with a 7-day cooldown, and a zizmor audit of.github/. Actions publishing immutable releases stay on version tags for readability, with the exception recorded in.github/zizmor.yml.Three points that are not self-evident from the diff:
uses: $/...is GitHub's self-repository syntax, GA since 2026-07-30 and requiring runner ≥ 2.336.0 (hosted runners are on 2.337.0). It resolves to the running commit with no checkout.actionlint1.7.12 predates it and reports it as malformed; we do not run actionlint in CI.deploy_release.yml, and theupload-wheelsleg feeding the rollinglatestpre-release), so a poisoned cache cannot reach a consumer. zizmor flags this pattern ascache-poisoning; the two workflows that publish nothing carry a documented ignore.Also deletes
generate_test_files.yml, which is unused.src/pynwb/testing/make_test_files.pystill generates the back-compat files when run under an old PyNWB.How to test the behavior?
Passes with no findings, offline and online. The rest is exercised by this PR's own CI.
Checklist
ruff check . && codespellfrom the source directory.🤖 Generated with Claude Code