Stop gstack-pr-wait, the land gate and the release cut from calling a head green while a check on it failed (GST-2252) (#4257)

* Make gstack-pr-wait, gstack-ci-gate and the release cut count a failed check hidden behind an empty rerun (GST-2252)

GitHub rollup and default check-runs list hold only each check suite latest attempt, so a rerun attempt with no jobs hid the failed run before it, and a workflow run that failed before any job never appeared. All three readers now add CI at the commit as the merge queue reads it (ciAtHead via lib/ci-head-checks.ts) and keep the worse bucket per check. Tests reuse the gstack-evals#303 recording from #4235.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Have the release cut read every check attempt only for commits that pass its named checks (GST-2252)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Say in the changelog that the release cut now counts failed commit statuses (GST-2252)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* Let the release cut set its own jobs aside in the every-attempt check read too (GST-2252)

After #4297 the cut sets aside check runs from its own workflow and the Windows nightly by job id, but the rows from lib/ci-head-checks.ts skipped that filter, so the cut waited on its own run. headCheckRows now takes the set-aside check run and workflow run ids and removes them from every list before ciAtHead reads it.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-17 10:03:19 +00:00
1 parent 2af3822f94
commit 83cc10acd2
15 files changed
+307 -43

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
/**
* GitHub's REST answers about CI at one commit, for unit fakes of the readers that share ciAtHead (lib/ci-head-checks.ts,
* GST-2252), with the check runs and workflow runs #4235 (GST-2167) recorded from gstack-evals#303 in
* test/gstack-ship-queue.test.ts. A check run marked earlier_attempt belongs to a superseded workflow-run attempt: like
* GitHub's default filter=latest and ghQueueShim (test/helpers/ship-queue-fixture.ts), it is listed only when the call asks
* for filter=all.
*/
export interface CiAtCommit { check_runs: Array<Record<string, unknown>>; statuses?: Array<Record<string, unknown>>; workflow_runs?: Array<Record<string, unknown>> }
const app = { id: 15368 };
const wf = (id: number, name: string, workflow_id: number, suite: number, conclusion: string, created_at: string) => ({ id, name, workflow_id, check_suite_id: suite, status: 'completed', conclusion, created_at });
const checks = { id: 129322614246, name: 'checks', status: 'completed', conclusion: 'failure', completed_at: '2026-11-09T17:49:57Z', app, check_suite: { id: 115553115622 } };
const sealed = { id: 129322588977, name: 'sealed', status: 'completed', conclusion: 'success', completed_at: '2026-11-09T17:22:47Z', app, check_suite: { id: 115553095053 } };
/**
* gstack-evals#303: `checks` failed in its first attempt and the rerun attempt created no jobs, so GitHub's default list shows
* only the passing `sealed`; a second sealed run failed without creating a job. ciAtHead reads it red (passed=1 failed=2).
*/
export const PR303: CiAtCommit = {
check_runs: [{ ...checks, earlier_attempt: true }, sealed],
workflow_runs: [
wf(42671854799, 'sealed', 2, 115574560782, 'failure', '2026-11-09T18:11:40Z'),
wf(42663983836, 'ci', 1, 115553115622, 'failure', '2026-11-09T17:22:30Z'),
wf(42663976278, 'sealed', 2, 115553095053, 'success', '2026-11-09T17:22:28Z'),
],
};
/** The negative control from the same test: the failed `checks` attempt was rerun and passed, so the head is green. */
export const PR303_RERUN_PASSED: CiAtCommit = {
check_runs: [{ ...checks, earlier_attempt: true }, { ...checks, id: 129330000000, conclusion: 'success', completed_at: '2026-11-09T18:20:00Z' }, sealed],
workflow_runs: [wf(42663983836, 'ci', 1, 115553115622, 'success', '2026-11-09T17:22:30Z'), wf(42663976278, 'sealed', 2, 115553095053, 'success', '2026-11-09T17:22:28Z')],
};
/**
* Bash `case "$*"` arms for a gh shim that answers every read of CI at a commit with `checkRuns` (all in their latest attempt):
* gateVerdict's `--paginate --slurp` check-runs pages and ciAtHead's single pages, with no statuses and no workflow runs.
*/
export function ciShimCases(checkRuns: unknown[]): string {
return [
` *--slurp*check-runs*) echo '${JSON.stringify([{ check_runs: checkRuns }])}' ;;`,
` *check-runs*) echo '${JSON.stringify({ total_count: checkRuns.length, check_runs: checkRuns })}' ;;`,
` */status\\?*) echo '{"total_count":0,"statuses":[]}' ;;`,
` *actions/runs*) echo '{"total_count":0,"workflow_runs":[]}' ;;`,
].join('\n') + '\n';
}
/**
* gh's reply to one REST read of CI at a commit, or null when `args` is not one: `commits/<sha>/check-runs`, `commits/<sha>/status`
* or `actions/runs?head_sha=<sha>`, as one page (`page=N`), `--paginate --jq '.<key>[]'` lines or `--paginate --slurp` pages.
*/
export function ciRest(args: string[], data: CiAtCommit): { status: number; stdout: string; stderr: string } | null {
if (args[0] !== 'api') return null;
const path = args.find((a, i) => i > 0 && !a.startsWith('--') && args[i - 1] !== '--jq') ?? '';
const m = /commits\/[0-9a-f]+\/(check-runs|status)\b|actions\/runs\?head_sha=/.exec(path);
if (!m) return null;
const key = m[1] === 'check-runs' ? 'check_runs' : m[1] === 'status' ? 'statuses' : 'workflow_runs';
const list = key === 'check_runs' ? data.check_runs.filter(r => /[?&]filter=all(&|$)/.test(path) || !r.earlier_attempt) : data[key] ?? [];
const out = (stdout: string) => ({ status: 0, stdout, stderr: '' });
if (args.includes('--jq')) return out(list.map(item => JSON.stringify(item)).join('\n'));
if (args.includes('--slurp')) return out(JSON.stringify([{ total_count: list.length, [key]: list }]));
const page = Number(/[?&]page=(\d+)/.exec(path)?.[1] ?? 1);
return out(JSON.stringify({ total_count: list.length, [key]: page === 1 ? list : [] }));
}