Skip to content

fix(release): gate tags on main CI - #700

Merged
vladimirrott merged 3 commits into
lacs-project:mainfrom
dannyward630:fix/issue-553-release-tag-guard
Oct 30, 2026
Merged

vladimirrott merged 3 commits into
lacs-project:mainfrom
dannyward630:fix/issue-553-release-tag-guard

Conversation

@dannyward630

@dannyward630 dannyward630 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #553. Release tags now stop before publishing unless the tagged commit is reachable from main and a completed ci workflow run from a push succeeded for that exact commit.

Related issue

Closes #553

Validation

  • Release guard tests cover missing runs, the wrong workflow, a pull_request event, the wrong SHA, failed and incomplete runs.
  • Release documentation explains when to push a tag and how to recover when CI is still running.
  • Security impact considered: preflight fails closed on tags outside main and missing or unsuccessful CI.
  • Trust boundary preserved: no privileged executor behavior changed.
  • tests/release/release-main-guard.test.sh — passed.
  • tests/release/check-release-ci.test.sh — passed.
  • tests/release/release-create-rerun.test.sh — passed.
  • scripts/check_test_reachability.sh — passed.
  • bash -n on the changed shell scripts and git diff --check — passed.
  • All applicable GitHub Actions checks pass at 031947cb; container-smoke is skipped as configured.

Assisted by Codex (GPT-6).

Notes for Reviewers

The preflight grants only read access to Actions and checks, fetches full history to test ancestry, and checks the Actions run metadata behind the commit's check-run URLs. It fails closed when the commit has no Actions check runs or no successful ci push run.

@vladimirrott vladimirrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at fb7ab1f7.

Thanks, Danny. The guard has the right shape: the refusal names the SHA, the preflight asks for read access to actions and checks and nothing more, and the CI lookup treats zero check runs as a refusal, the part of #553 I wanted most. I ran your two tests and the rest of docs-and-hygiene in a container on your head and on a trial merge with current main, and broke the script three ways (a failed run, a wrong SHA, a wrong workflow name). Your tests caught all three.

One thing blocks, and you could not have seen it with the gh stub in place. gh refuses --slurp together with --jq:

$ gh api --paginate --slurp --jq '...' "repos/lacs-project/sysknife/commits/24ebd624.../check-runs?per_page=100"
the `--slurp` option is not supported with `--jq` or `--template`

gh has refused that combination since --slurp arrived in 2.48.0, so on a runner check_release_ci.sh exits with Could not read check runs for every tag, good ones included. The stub matches on $* and prints a finished run ID, so the flag and the jq filter never run in the test. When I made the stub refuse --slurp with --jq the way gh does, the success case went red.

Dropping --slurp, filtering per page and deduplicating at the end works:

run_ids_output="$(gh api --paginate \
    --jq '.check_runs[]? | (.details_url // "") | try capture("/actions/runs/(?<run_id>[0-9]+)/job/").run_id catch empty' \
    "repos/${repo}/commits/${release_sha}/check-runs?per_page=100")" || {
    printf '::error::Could not read check runs for release commit %s\n' "$release_sha" >&2
    exit 1
}
run_ids_output="$(sort -u <<< "$run_ids_output")"

Against the real API on main at 24ebd624 that returns 13 run IDs, and the ci push run among them reads completed success. With that change and the stricter stub, your test passes and shellcheck stays clean. Please keep a stub that fails the way gh fails, or feed a recorded check-runs response through jq with the script's own filter, so the test runs the filter the script ships.

I'd like your view on one more thing, and it does not block: in three of the last five releases (v0.28.0, v0.27.0 and v0.24.0) I pushed the tag while ci on that commit was still running. Your guard stops those releases at preflight. Re-running the workflow once ci is green recovers, so a line in docs/release.md covers it; a bounded wait in the script would remove the step. I'd lean to the wait, since skipping that step is exactly what I keep doing, but either works.

Optional:

  • release-main-guard.test.sh checks substrings, so it stays green if the ancestry step loses its exit 1 or the CI step gains continue-on-error: true. I tried both. Asserting on those two closes it.
  • Requiring event == "push" on the matching run means only a ci run of that exact commit counts. A pull_request run with the same head SHA tested the merge ref, a different tree.
  • release-main-guard.test.sh calls python -. The other release tests call python3, and stock Debian and Ubuntu ship no python.

@vladimirrott

Copy link
Copy Markdown
Member

The sign-off note on #698 applies here too: the same three commands, run from this branch, clear the dco check.

@dannyward630
dannyward630 force-pushed the fix/issue-553-release-tag-guard branch from fb7ab1f to 031947c Compare October 29, 2026 17:21

@vladimirrott vladimirrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at 031947cb. Approved.

Thanks, Danny. You fixed the blocker and took all three optional items as well. The best part is the stub: it now refuses --slurp with --jq the way gh does, so the test can no longer pass on a flag combination a runner rejects.

I ran both release tests in a no-network container at 031947cb, then broke the code four ways:

change test result
none both pass
put --slurp back on the check-runs call check-release-ci.test.sh Could not read check runs, exit 1
drop "$event" == push check-release-ci.test.sh FAIL: wrong-event unexpectedly passed
delete exit 1 from the ancestry step release-main-guard.test.sh ancestry step is missing 'exit 1'
continue-on-error: true on the CI step release-main-guard.test.sh preflight must not continue after a failed guard

The stub still returns run 101 without running your jq filter, so I ran the filter from check_release_ci.sh against the real API on main at 093436f0. It returned 23 lines and 8 unique run IDs, and 40922961254 reads ci 093436f0 push completed success, the run your guard needs to find.

The docs/release.md paragraph answers my question about pushing the tag while ci is still running. Rerunning the release workflow is a fine recovery, and I'll follow it.

As with #698, the branch is one commit behind main (the 0.29.0 release, version bumps only, no conflict), and GitHub wants it current. Since this one changes two workflow files, I'll read the rebased workflow diff again myself before I merge it.

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.

release.yml publishes for any v*.*.* tag without checking the commit is on main or that CI passed

2 participants