Repository navigation
fix(release): gate tags on main CI - #700
vladimirrott merged 3 commits into
Conversation
vladimirrott
left a comment
There was a problem hiding this comment.
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.shchecks substrings, so it stays green if the ancestry step loses itsexit 1or the CI step gainscontinue-on-error: true. I tried both. Asserting on those two closes it.- Requiring
event == "push"on the matching run means only acirun of that exact commit counts. Apull_requestrun with the same head SHA tested the merge ref, a different tree. release-main-guard.test.shcallspython -. The other release tests callpython3, and stock Debian and Ubuntu ship nopython.
|
The sign-off note on #698 applies here too: the same three commands, run from this branch, clear the |
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
fb7ab1f to
031947c
Compare
vladimirrott
left a comment
There was a problem hiding this comment.
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.
Signed-off-by: Vladimir Rotariu <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Closes #553. Release tags now stop before publishing unless the tagged commit is reachable from
mainand a completedciworkflow run from apushsucceeded for that exact commit.Related issue
Closes #553
Validation
pull_requestevent, the wrong SHA, failed and incomplete runs.mainand missing or unsuccessful CI.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 -non the changed shell scripts andgit diff --check— passed.031947cb;container-smokeis 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
cipush run.