Gate releases on successful tag commit checks (CLS-1422) #335

Merged
stephen merged 3 commits from cls-1422-release-status-gate into main 2026-11-22 03:06:43 +00:00
Owner

First part of CLS-1422. prepare resolves the release tag to a commit SHA, and gate checks that SHA before any build starts. The gate uses the workflow's existing GITHUB_TOKEN and requires successful ci / check (push), ci / coverage (push), and ci / live-e2e (push) contexts.

Status scope: every other commit context must also be successful, including external checks such as security-scan. Only this release workflow's contexts and pull request event contexts are excluded.

Stable snapshot: the gate reads every page from the combined commit-status endpoint twice and requires the complete status sets to match. API errors, duplicate contexts, incomplete scans, and changing sets fail closed.

The release run adds its own pending contexts to the same SHA, so those contexts must be excluded to avoid blocking itself. Gate failures flow to guard for release recovery, and a successful publish clears the draft state in visible.

No local build or test suite was run. Shellcheck passes on the extracted gate script. Actionlint reports existing Forgejo-specific label and action URL warnings, plus warnings in other steps. CI will validate the workflow.

First part of CLS-1422. `prepare` resolves the release tag to a commit SHA, and `gate` checks that SHA before any build starts. The gate uses the workflow's existing `GITHUB_TOKEN` and requires successful `ci / check (push)`, `ci / coverage (push)`, and `ci / live-e2e (push)` contexts. Status scope: every other commit context must also be successful, including external checks such as `security-scan`. Only this release workflow's contexts and pull request event contexts are excluded. Stable snapshot: the gate reads every page from the combined commit-status endpoint twice and requires the complete status sets to match. API errors, duplicate contexts, incomplete scans, and changing sets fail closed. The release run adds its own pending contexts to the same SHA, so those contexts must be excluded to avoid blocking itself. Gate failures flow to `guard` for release recovery, and a successful publish clears the draft state in `visible`. No local build or test suite was run. Shellcheck passes on the extracted gate script. Actionlint reports existing Forgejo-specific label and action URL warnings, plus warnings in other steps. CI will validate the workflow.
Gate releases on successful commit checks
Some checks failed
ci / check (pull_request) Successful in 27m35s
ci / coverage (pull_request) Has been cancelled
ci / live-e2e (pull_request) Has been cancelled
7d3e27a47a
Signed-off-by: Stephen Way <stephen@rasterstate.com>
gerri requested changes 2026-11-21 23:05:36 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head 7d3e27a47a.

  • Medium .forgejo/workflows/release.yml:111: Invariant: a release gate must evaluate the complete status set. The combined-status endpoint paginates, but this request reads only its default first page. The existing status scanner explicitly walks until an empty page because neither a short page nor the reported total proves completeness. If a tag commit has enough contexts for a failed or pending check to fall on a later page, the workflow can publish it after seeing only successes. This defeats the gate introduced by this PR. Fetch every page, verify the SHA on each response, and fail closed if the scan cannot establish completeness.

  • Medium .forgejo/workflows/release.yml:119: Invariant: a failed release attempt must not leave an advertised, empty release without a visible failure report. A failed check, missing status set, or API error now fails prepare, but the existing guard runs only when prepare succeeds. On a normal tag push, Forgejo can already expose the tag as a published release, so a tag pushed while CI is pending or during an API outage leaves that empty release advertised and files no issue. This newly reachable failure belongs in this PR. Run recovery for gate failures after tag resolution, preserving the resolved tag for the guard and reporting the prepare failure.

BLOCKING: 2

Reviewed head 7d3e27a47a at 2026-11-21T23:05:36Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 7d3e27a47acaf5b436ed0cdd424570de0bcfead0. - **Medium** [.forgejo/workflows/release.yml:111](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:111): **Invariant: a release gate must evaluate the complete status set.** The combined-status endpoint paginates, but this request reads only its default first page. The existing [status scanner](/home/dev/work/reviews/rasterstate-fj-335/src/api/pull_status.rs:67) explicitly walks until an empty page because neither a short page nor the reported total proves completeness. If a tag commit has enough contexts for a failed or pending check to fall on a later page, the workflow can publish it after seeing only successes. This defeats the gate introduced by this PR. Fetch every page, verify the SHA on each response, and fail closed if the scan cannot establish completeness. - **Medium** [.forgejo/workflows/release.yml:119](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:119): **Invariant: a failed release attempt must not leave an advertised, empty release without a visible failure report.** A failed check, missing status set, or API error now fails `prepare`, but the existing `guard` runs only when `prepare` succeeds. On a normal tag push, Forgejo can already expose the tag as a published release, so a tag pushed while CI is pending or during an API outage leaves that empty release advertised and files no issue. This newly reachable failure belongs in this PR. Run recovery for gate failures after tag resolution, preserving the resolved tag for the guard and reporting the prepare failure. BLOCKING: 2 --- Reviewed head 7d3e27a47acaf5b436ed0cdd424570de0bcfead0 at 2026-11-21T23:05:36Z by codex exec (read-only sandbox).
Gate releases on every CI job, read every status page, and make failure recovery visible
All checks were successful
ci / check (pull_request) Successful in 26m24s
ci / live-e2e (pull_request) Successful in 5m56s
ci / coverage (pull_request) Successful in 7m38s
76aebdd7ce
The release gate read only the first page of the combined-status endpoint, accepted any non-empty set of successful contexts, and reported failures through a guard that a failed prepare skipped.

The gate is now its own job (prepare stays green, so guard runs). It walks pages until an empty page, as src/api/pull_status.rs does, and fails closed on a repeated page, a response for another sha, a missing statuses array, or more than 50 pages. It also requires a status for each CI job (check, coverage, live-e2e), so a tag pushed before live-e2e reports cannot release.

guard no longer stops at the first failed call: it attempts the demotion and the issue independently and fails the run, naming what failed, when either did not happen. The publish job clears draft and prerelease after attaching assets, so a retry after a demotion restores the release; release tags are strictly vX.Y.Z, so a published release is neither. publish gains curl and jq for that step.
Author
Owner

Fixed in the latest push.

  • The status read walks every page until an empty page (as src/api/pull_status.rs does) and fails closed on a repeated page, a response for another sha, a missing statuses array, or more than 50 pages.
  • The gate now requires the exact main-branch contexts for each CI job (ci / check, coverage, live-e2e, all (push)) and judges only push contexts, so a tag pushed before live-e2e reports cannot release, a PR-only status cannot satisfy it, and a stale failed PR context cannot block a green main run.
  • The check is its own job, so a failed gate leaves prepare green and guard runs. guard also runs when prepare itself fails on a tag push, using the push ref re-validated against the same shape rules. It no longer stops at the first failed call: it attempts the demotion and the issue independently and fails the run, naming what failed.
  • A new visible job clears draft and prerelease after publish (a - suffix keeps prerelease), falling back to the release list if the tag lookup does not return a draft. A failure there is reported as published but not visible, not as no artifacts.

Tested the gate and guard shell logic against a mock curl (clean, late failure, repeated page, wrong sha, no live-e2e, null statuses, PR-only contexts, API down, injection-shaped tag). Not exercised: a real release run, the 50-page cap, and the visible job against a real draft.

Not changed here, and in the guard's original behaviour rather than new: a release that got some but not all assets stays public (guard demotes only an empty one), and two overlapping runs for one tag can race on the demotion. Both are worth a follow-up issue.

Fixed in the latest push. - The status read walks every page until an empty page (as src/api/pull_status.rs does) and fails closed on a repeated page, a response for another sha, a missing statuses array, or more than 50 pages. - The gate now requires the exact main-branch contexts for each CI job (ci / check, coverage, live-e2e, all (push)) and judges only push contexts, so a tag pushed before live-e2e reports cannot release, a PR-only status cannot satisfy it, and a stale failed PR context cannot block a green main run. - The check is its own job, so a failed gate leaves prepare green and guard runs. guard also runs when prepare itself fails on a tag push, using the push ref re-validated against the same shape rules. It no longer stops at the first failed call: it attempts the demotion and the issue independently and fails the run, naming what failed. - A new visible job clears draft and prerelease after publish (a - suffix keeps prerelease), falling back to the release list if the tag lookup does not return a draft. A failure there is reported as published but not visible, not as no artifacts. Tested the gate and guard shell logic against a mock curl (clean, late failure, repeated page, wrong sha, no live-e2e, null statuses, PR-only contexts, API down, injection-shaped tag). Not exercised: a real release run, the 50-page cap, and the visible job against a real draft. Not changed here, and in the guard's original behaviour rather than new: a release that got some but not all assets stays public (guard demotes only an empty one), and two overlapping runs for one tag can race on the demotion. Both are worth a follow-up issue.
gerri requested changes 2026-11-22 00:39:48 +00:00
Dismissed
gerri left a comment

Automated Codex review (read-only) of head 76aebdd7ce.

  • Medium .forgejo/workflows/release.yml:170: The gate must reject every unsuccessful non-release check, as the PR body promises. It instead ignores every context that does not end in (push). On the supported Forgejo commit-status API, an external check can report a failure under a context such as security-scan; if the three named CI push jobs are green, this gate still publishes the release. This belongs in the PR because the new gate claims to prevent precisely that outcome. Exclude the release workflow and the explicitly unwanted pull-request contexts, then evaluate all other statuses, including ordinary external status contexts.

  • Low .forgejo/workflows/release.yml:142: Edge case. A completed scan must represent one coherent status set. Statuses can change while the pages are read, shifting entries between pages; a context can be missed even though the scan reaches an empty page. A check that changes during the scan could therefore be omitted and the release allowed. Re-read and compare the set or otherwise establish a stable snapshot before certifying it.

BLOCKING: 1

Reviewed head 76aebdd7ce at 2026-11-22T00:39:47Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 76aebdd7ce5fe2eb125bd60fe3a97eb7827ed250. - **Medium** [.forgejo/workflows/release.yml:170](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:170): The gate must reject every unsuccessful non-release check, as the PR body promises. It instead ignores every context that does not end in `(push)`. On the supported Forgejo commit-status API, an external check can report a failure under a context such as `security-scan`; if the three named CI push jobs are green, this gate still publishes the release. This belongs in the PR because the new gate claims to prevent precisely that outcome. Exclude the release workflow and the explicitly unwanted pull-request contexts, then evaluate all other statuses, including ordinary external status contexts. - **Low** [.forgejo/workflows/release.yml:142](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:142): **Edge case.** A completed scan must represent one coherent status set. Statuses can change while the pages are read, shifting entries between pages; a context can be missed even though the scan reaches an empty page. A check that changes during the scan could therefore be omitted and the release allowed. Re-read and compare the set or otherwise establish a stable snapshot before certifying it. BLOCKING: 1 --- Reviewed head 76aebdd7ce5fe2eb125bd60fe3a97eb7827ed250 at 2026-11-22T00:39:47Z by codex exec (read-only sandbox).
Require stable complete status set before release
All checks were successful
ci / check (pull_request) Successful in 30m50s
ci / live-e2e (pull_request) Successful in 5m0s
ci / coverage (pull_request) Successful in 6m28s
897c5ed3bd
Signed-off-by: Stephen Way <stephen@rasterstate.com>
gerri approved these changes 2026-11-22 02:07:49 +00:00
gerri left a comment

Automated Codex review (read-only) of head 897c5ed3bd.

  • Low release.yml:571: Invariant: release visibility reflects the tag’s version. The check treats any hyphen as a prerelease marker, including one in build metadata. For example, the accepted stable tag v1.2.3+build-1 becomes a prerelease after publication. Parse the version’s prerelease component separately from its build metadata. This is an edge case.

  • Low release.yml:638: Invariant: recovery identifies the existing release across retries. visible accounts for the tag lookup returning 404 for a draft, but guard does not use the same fallback. If a failed release was already demoted and a subsequent attempt fails before publication, recovery reports a lookup failure despite the draft existing. Use the authenticated release-list fallback in both paths. This is an edge case because the release is already hidden and the issue is still attempted.

BLOCKING: 0

Reviewed head 897c5ed3bd at 2026-11-22T02:07:48Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 897c5ed3bddaae8f230919278423fd0f3deea2fe. - **Low** [release.yml:571](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:571): **Invariant: release visibility reflects the tag’s version.** The check treats any hyphen as a prerelease marker, including one in build metadata. For example, the accepted stable tag `v1.2.3+build-1` becomes a prerelease after publication. Parse the version’s prerelease component separately from its build metadata. This is an edge case. - **Low** [release.yml:638](/home/dev/work/reviews/rasterstate-fj-335/.forgejo/workflows/release.yml:638): **Invariant: recovery identifies the existing release across retries.** `visible` accounts for the tag lookup returning 404 for a draft, but `guard` does not use the same fallback. If a failed release was already demoted and a subsequent attempt fails before publication, recovery reports a lookup failure despite the draft existing. Use the authenticated release-list fallback in both paths. This is an edge case because the release is already hidden and the issue is still attempted. BLOCKING: 0 --- Reviewed head 897c5ed3bddaae8f230919278423fd0f3deea2fe at 2026-11-22T02:07:48Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.