Skip to content

ci: test release scripts and lint workflows - #581

Merged
somanshreddy merged 1 commit into
mainfrom
11-16-ci_test_and_lint_release_scripts
Nov 16, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
11-16-ci_test_and_lint_release_scripts

Conversation

@somanshreddy

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CI | Module: Release

Summary

Adds automated tests for the release helper scripts, and lints every workflow in CI with actionlint, shellcheck and zizmor. It also narrows workflow token permissions and stops keeping checkout credentials where a job doesn't use them. A release does exactly what it did before.

How it works

  • Test runner: a plain-bash runner puts fake gh, aws and git commands first on PATH and runs each real release script. Each test checks the exit code, the key output line and the exact calls the script made. A call the test didn't register fails the test.
  • What the tests check:
    • Arguments are validated before any API call.
    • The download step refuses a checksums file that isn't the recorded one, a draft or mismatched release, an unlisted file name, and a mismatched archive.
    • The CDN check refuses an older version, and a changed manifest for a version that is already published. It passes a retry and a new version.
    • Cleanup touches only this run's drafts and tag.
  • New CI jobs: release-scripts runs the tests and shellcheck. workflow-lint runs actionlint and zizmor. Both tools are installed as pinned releases with a checked sha256, the way GoReleaser already is.
  • Permissions: CI now runs with contents: read by default, and the release workflows grant contents: write only to the release job.
  • Checkout credentials: checkouts that never push set persist-credentials: false. The checkouts that push or delete the release tag keep their credentials, with an inline zizmor ignore that gives the reason.

Testing

  • make test-release-scripts: all 25 tests pass. Each check was confirmed to fail when the line it covers is broken: 38 single-line mutations, all caught.
  • actionlint, shellcheck and zizmor pass on this branch. zizmor reports a template-injection error when an expression is added to a run: block.

🤖 Generated with Claude Code

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Every job keeps the permissions it uses after write access moved off the workflow level, and the new tests catch removed guards.

Permissions, job by job (parsed from the YAML at head)

  • release-stable.yml and dev-release.yml now have top-level permissions: {}. Every job declares its own permissions, so none of them inherits the empty set by accident.
    • release: contents: write. It pushes the tag, and GoReleaser creates the draft release. Listing releases to find this run's draft also needs write, because drafts are only visible with push access.
    • cleanup-failed-release: contents: write. It runs git push --force-with-lease ... :refs/tags/<tag> and DELETE releases/<id>. Its checkout keeps credentials for that push, so the artipacked ignore is justified there and on release.
    • publish-release: contents: write for the PATCH draft=false.
    • publish-cdn (stable only): contents: read + id-token: write. It runs after publish-release, so the release it downloads is already public and read is enough. The checkout is now persist-credentials: false, and the job only runs git ls-remote.
  • ci.yml: top-level contents: read. pr-template adds pull-requests: read, surface-report keeps its pull-requests: write, and every checkout drops persisted credentials.

Tests. run.sh passes locally (25/25). I removed six guards one at a time, and a test failed for each:

  • the draft check in download-release-assets.sh
  • the checksums-hash comparison in download-release-assets.sh
  • the tag-message/run-id match in cleanup-failed-release.sh
  • the non-draft refusal in cleanup-failed-release.sh
  • the numeric run-id validation in cleanup-failed-release.sh
  • an exit in check-cdn-publish.sh

The fake fails any call a test didn't register, which keeps the call assertions honest.

Tool pins. ACTIONLINT_SHA256 matches actionlint_1.7.12_checksums.txt. ZIZMOR_SHA256 matches the v1.32.0 asset digest. workflow-lint is green at head, so the # v7.0.1 # zizmor: ignore[artipacked] double comment parses.

Non-blocking:

  • fake-command.sh keys calls on "$tool ${args[*]}", so argument boundaries are lost (gh api "a b" and gh api a b share a key). None of the current scripts pass arguments with spaces. Joining with printf '%q ' would make the key exact if that ever changes.
  • The red govulncheck is main's Go toolchain advisory (fixed by the Go bump PR), not this change.

— Rames

@somanshreddy
somanshreddy force-pushed the 11-16-ci_test_and_lint_release_scripts branch from 0c4155c to 51b3e1a Compare November 16, 2026 02:57
@somanshreddy
somanshreddy merged commit 80f0050 into main Nov 16, 2026
11 checks passed
@somanshreddy
somanshreddy deleted the 11-16-ci_test_and_lint_release_scripts branch November 16, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants