Skip to content

fix(release): count only the latest check run per name in the CI-green gate - #1537

Merged
c-vigo merged 2 commits into
devfrom
feature/1522-validate-latest-check-run
Aug 17, 2026
Merged

c-vigo merged 2 commits into
devfrom
feature/1522-validate-latest-check-run

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #1522 (follow-up to the #1516 train blocker): the CI-green gate counted every FAILURE/ERROR in the release PR head SHA's statusCheckRollup, so stale check runs left by a superseded workflow run (e.g. after a close/reopen re-run) blocked a branch that gh pr checks correctly reported green — during the 1.10.0 train this forced deleting the superseded run.

The gate now dedups the rollup once into a latest-per-name set and derives all three counts (CI_FAILED, CI_PENDING, CI_SUCCESS) from it, matching gh pr checks semantics:

jq '[group_by(.name // .context // "?")[] | max_by(.startedAt // .createdAt // "")]'
  • Recency key startedAt, not completedAt: completedAt is null while a re-run is in flight, which would rank the live run oldest and let the superseded FAILURE win — the exact inversion of the intended behavior.
  • Group key .name // .context: StatusContexts have no name; they key on context, are each their own latest, and keep their pre-existing pending treatment (pinned by test, not changed).
  • Applied to all six sites (approved scope beyond the two the issue names — the promote gates share the identical logic and hazard): release.yml, both promote-release.yml gates (devkit + scaffold), and the consumer release-core.yml. Sync topology verified first: none of these four files is manifest-generated, so each was edited as an independent source.

Test plan

New tests/test_ci_green_gate.py: 7 scenarios x 6 sites = 42 tests that execute the real extracted bash+jq against fixture rollups (harness in tests/workflow_scaffold.py) — superseded FAILURE passes (the #1516 case, red before the fix: 18 failed), latest-run FAILURE still blocks, in-progress re-run counts pending not failed, distinct-name FAILURE still blocks, StatusContext treatment unchanged, distinct StatusContexts not collapsed, order-independence across permutations. Naming each site explicitly also closes the historical scaffold-vs-devkit copy blind spot.

Existing suites untouched and green: test_release_validate_gate.py + test_promote_release.py + test_release_core.py (80 passed with the new suite), just test-bats 552 passed, prek run --all-files exit 0 (verified independently of the implementation run).

Follow-up candidates noted in review (not in scope): StatusContexts always count as pending in these gates (pre-existing), and vig_utils/gh_issues.py::_dedupe_status_checks still keys on completedAt.

Closes #1522

c-vigo added 2 commits August 17, 2026 12:25
Add tests/test_ci_green_gate.py: it extracts the release-PR CI gate's real
bash from all six copies (release.yml, release-core.yml, and the validate +
merge gates of both promote-release.yml copies) and runs it against fixture
statusCheckRollup payloads. Shape assertions cannot distinguish a correct
per-name dedup from a plausible one, so the #1516 stale-FAILURE scenario is
pinned as behavior.

extract_ci_gate/run_ci_gate join the shared workflow_scaffold helpers.

Refs: #1522
…n gate

The release-PR CI gate counted every FAILURE/ERROR entry in the head SHA's
statusCheckRollup. A superseded workflow run leaves its check runs attached to
that same SHA, so the gate refused a branch that `gh pr checks` — which keeps
only the latest run per name — reported green; the 1.10.0 train had to delete
the superseded run to proceed (#1516).

Each gate now groups the rollup by check name and derives CI_FAILED, CI_PENDING
and CI_SUCCESS from the latest run of each. Recency keys on startedAt, not
completedAt: completedAt is null while a re-run is in flight, which would rank
the live run oldest and let the stale FAILURE win. StatusContexts carry no
name/startedAt, so they key on context/createdAt and keep their current
treatment.

The issue names release.yml and release-core.yml; the four promote-release.yml
gates (validate and merge, both copies) carry the identical logic and the
identical hazard, so all six sites are fixed together.

Refs: #1522
@c-vigo
c-vigo merged commit 24a097a into dev Aug 17, 2026
12 checks passed
@c-vigo
c-vigo deleted the feature/1522-validate-latest-check-run branch August 17, 2026 10:57
c-vigo added a commit that referenced this pull request Aug 17, 2026
## Summary

Implements #1538 (follow-up to #1537): the six CI-green gates classified
every rollup entry by `.conclusion` — a CheckRun-only field — so a
StatusContext (commit status API, which carries `state`) always fell
into the pending bucket: a red commit status could never block as failed
(on the failures-only `release-core.yml` gate it passed outright), and a
green one held the pending gates open forever. Latent today (no org repo
publishes commit statuses); real the day a consumer adds a status-API
tool.

All three counts now bind one normalized verdict per entry —
`(.conclusion // .state) as $v` — and compare against it: FAILURE/ERROR
→ failed, SUCCESS → success,
null/""/PENDING/IN_PROGRESS/QUEUED/**EXPECTED** → pending. Field shapes
were verified live via GraphQL introspection, not assumed: `StatusState`
is exactly `EXPECTED, ERROR, FAILURE, PENDING, SUCCESS`, and CheckRun
has no `state` field, so nothing can double-classify; an in-progress
CheckRun (`conclusion: null`) resolves `null // null` → still pending,
and `conclusion: ""` stays pending via the retained `== ""` arm (empty
string is truthy in jq, no fall-through). Applied at all six sites
(#1537 scope); the #1537 dedup expression is untouched, and its comment
blocks were corrected where they claimed StatusContexts "keep counting
as before".

## Test plan

`tests/test_ci_green_gate.py`: the deliberately-pinned StatusContext
test from #1537 is inverted as the issue prescribed, replaced by seven
new scenario families x six sites — red status blocks as failed
(sharpest red case: previously *passed* the release-core gate), green
status passes / counts as a successful check, PENDING/EXPECTED still
hold, mixed rollups classify each kind independently, same-keyed vs
distinctly-keyed StatusContext/CheckRun grouping pinned as #1537
actually behaves. TDD red: 34 failed before the fix; 90 passed after.
Combined gate suites: 128 passed; `prek run --all-files` exit 0
(verified independently of the implementation run).

Closes #1538
c-vigo added a commit that referenced this pull request Aug 17, 2026
The gh-issues PR table kept the latest run of each check name by
completedAt, which is null while a rerun is in flight: the live run
ranked as the oldest of its name and the FAILURE it supersedes won the
CI cell during exactly the window someone watches a rerun. Key on
startedAt with a createdAt fallback for StatusContexts, mirroring the
release-workflow CI-green gates fixed in #1537.

Refs: #1539
c-vigo added a commit that referenced this pull request Aug 17, 2026
## Summary

Implements #1539 (follow-up to #1537): `_dedupe_status_checks` — feeding
the `just gh-issues` PR table — keyed recency on `completedAt`, which is
null while a re-run is in flight, so the table showed the superseded
FAILURE during exactly the window someone is watching a re-run.

The recency key is now a helper mirroring the release gates' jq
expression: `startedAt or createdAt or ""` (the `createdAt` arm covers
StatusContexts, which have no `startedAt`; `completedAt` is deliberately
absent — a completed CheckRun always has `startedAt`, so it would only
reintroduce the skew). Grouping key, tie-breaking (`>=`, last wins),
insertion order, and output shape unchanged; the #176-era no-timestamps
behavior (last in list wins) is preserved and still pinned.

Display-only fix — no gate behavior changes.

## Found during implementation, deliberately out of scope

Two more latent StatusContext gaps in the same file, the display-table
analogues of #1538: grouping uses `name` only (all commit statuses would
collapse into one `"?"` bucket; gates use `.name // .context`), and
`_format_ci_status` classifies on `conclusion` only (a red commit status
would render pending). Latent today — zero StatusContext entries across
the last 40 devkit PRs. Follow-up candidates.

## Test plan

New `TestDedupeStatusChecks` (6 tests): in-progress re-run beats older
completed FAILURE (TDD red: 3 failed pre-fix), newer SUCCESS beats older
FAILURE, distinct names untouched, order-independence, StatusContext
`createdAt` fallback, and an end-to-end pin that the CI cell renders `⏳
0/1` rather than `✗ 0/1`. `packages/vig-utils/tests`: 529 passed; `prek
run --all-files` exit 0 (verified independently of the implementation
run).

Closes #1539
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.

1 participant