mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 08:31:44 +01:00
A skipped CI run no longer blocks reusing a passing run on the same commit (GST-3514) (#4695)
When one commit gets two runs of the same workflow and the newer one skipped every job, the passing run can now be reused, and the CI wait no longer reports that commit red. gbrain hit this when a pull request run that skipped all its jobs, created in the same second as a passing manual run, blocked that passing run. Nothing to do: a newer failed, cancelled or still-running run still blocks reuse exactly as before. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=red-team
This commit is contained in:
1 parent
25bf93c4e2
commit
7530280407
6 files changed
+27
-3
No files matched your search
@@ -0,0 +1 @@
|
||||
**A skipped CI run no longer blocks reuse of a passing run on the same commit.** When a workflow fired twice for one commit, say a manual dispatch plus a pull request run whose jobs all skipped, the skipped run was treated as a newer failure: `gstack-pregate` refused the passing run with `newer_run_vetoes`, and `gstack-ci-carry wait` reported the commit red. Both now pass over the skipped run. A newer failed, cancelled or still-running run still blocks reuse.
|
||||
+5
-1
@@ -914,7 +914,11 @@ once:
|
||||
(`tree_mismatch` otherwise). The API answers with
|
||||
the newest attempt, so an earlier green attempt under a newer red one is
|
||||
refused, and the run is read again after the evidence is collected: a new
|
||||
attempt meanwhile is `run_changed`.
|
||||
attempt meanwhile is `run_changed`. A newer run of the same workflow on the
|
||||
head, of any event, vetoes it (`newer_run_vetoes`) when that run failed, was
|
||||
cancelled or is still running. A newer green run doesn't, and neither does a
|
||||
newer skipped run, which ran no job and so says nothing about the tree
|
||||
(GST-3514).
|
||||
- Every job the profile names appears exactly once in that attempt and
|
||||
succeeded. Jobs and runs are read across every page.
|
||||
- `tree.json` (an artifact of at most 8 MiB) names this run, attempt, event and
|
||||
|
||||
+2
-1
@@ -175,7 +175,8 @@ const PASSING = ['success', 'skipped', 'neutral'];
|
||||
export async function waitForRun(deps: RunDeps, o: { workflow: string; events: string[]; head: string; also?: string[]; timeoutMs: number; intervalMs: number; sleep: (ms: number) => Promise<void>; clock: () => number; random?: () => number }): Promise<WaitVerdict> {
|
||||
const end = o.clock() + o.timeoutMs;
|
||||
for (;;) {
|
||||
const newest = [o.head, ...(o.also ?? [])].flatMap(h => deps.runsForHead(o.workflow, h)).filter(r => o.events.includes(r.event)).sort(newestFirst)[0];
|
||||
const runs = [o.head, ...(o.also ?? [])].flatMap(h => deps.runsForHead(o.workflow, h)).filter(r => o.events.includes(r.event)).sort(newestFirst);
|
||||
const newest = runs.find(r => !(r.status === 'completed' && r.conclusion === 'skipped')) ?? runs[0];
|
||||
if (newest?.status === 'completed') {
|
||||
if (newest.conclusion === 'success') return { state: 'green', run: newest };
|
||||
const failing = deps.jobs(newest.id, newest.run_attempt).filter(j => !PASSING.includes(j.conclusion ?? '')).map(j => j.name);
|
||||
|
||||
+1
-1
@@ -223,7 +223,7 @@ export function verifyRun(deps: RunDeps, o: { repo: string; runRef: string; prof
|
||||
}
|
||||
const heads = [...new Set([run.head_sha, ...(o.vetoHeads ?? []).filter(h => SHA.test(h))])];
|
||||
for (const head of heads) {
|
||||
const newer = deps.runsForHead(p.workflow, head).filter(r => !(r.id === id && r.run_attempt === run.run_attempt) && r.id !== o.ignoreRun && started(r) >= (run.created_at ?? '') && !(r.status === 'completed' && r.conclusion === 'success'));
|
||||
const newer = deps.runsForHead(p.workflow, head).filter(r => !(r.id === id && r.run_attempt === run.run_attempt) && r.id !== o.ignoreRun && started(r) >= (run.created_at ?? '') && !(r.status === 'completed' && (r.conclusion === 'success' || r.conclusion === 'skipped')));
|
||||
if (newer.length) return fail('newer_run_vetoes', `newer run ${newer[0]!.id} of ${p.workflow} on ${head.slice(0, 12)} is ${newer[0]!.status === 'completed' ? newer[0]!.conclusion : newer[0]!.status}`);
|
||||
}
|
||||
if (p.skippable && p.skippable.jobs.every(j => skippedJobs.includes(j)) && o.docsOnly?.(run.head_sha)) {
|
||||
|
||||
@@ -137,6 +137,15 @@ describe('waitForRun', () => {
|
||||
expect((await o([run(4, { status: 'in_progress', conclusion: null })])).state).toBe('running');
|
||||
expect((await o([])).state).toBe('none');
|
||||
});
|
||||
|
||||
// Value: protects=the wait agrees with verifyRun (GST-3514): a newer skipped run leaves the green dispatch green; fails_when=the skipped run is read as red
|
||||
test('a newer skipped run is passed over for the run before it; a lone skipped run is still red', async () => {
|
||||
const o = (runs: ApiRun[]) => waitForRun(source(runs).deps, { workflow: 'free-tests.yml', events: PROFILE.events, head: HEAD, timeoutMs: 60_000, intervalMs: 20_000, ...clockAt() });
|
||||
const skipped = run(5, { event: 'pull_request', conclusion: 'skipped', created_at: run(4).created_at });
|
||||
expect(await o([run(4), skipped])).toMatchObject({ state: 'green', run: { id: 4 } });
|
||||
expect((await o([run(4, { conclusion: 'failure' }), skipped])).state).toBe('red');
|
||||
expect(await o([skipped])).toMatchObject({ state: 'red', run: { id: 5 } });
|
||||
});
|
||||
});
|
||||
|
||||
describe('ship_lanes_from config and the ci_carried receipt field', () => {
|
||||
|
||||
@@ -102,6 +102,15 @@ describe('verifyRun', () => {
|
||||
expect(reason(world({ run: { ...w.run, run_started_at: '2026-10-29T12:00:00Z' }, others: [newer('completed', 'failure')] }))).toBe('newer_run_vetoes');
|
||||
});
|
||||
|
||||
test('a skipped run cannot veto: a pull_request run created in the same second with every job skipped leaves the dispatch green (GST-3514)', () => {
|
||||
const w = world();
|
||||
const skipped = (over: Partial<ApiRun> = {}): ApiRun => ({ ...w.run, id: 101, event: 'pull_request', status: 'completed', conclusion: 'skipped', ...over });
|
||||
expect(reason(world({ others: [skipped()] }))).toBe('ok');
|
||||
expect(reason(world({ others: [skipped({ event: 'workflow_dispatch' })] }))).toBe('ok');
|
||||
expect(reason(world({ others: [skipped({ event: 'workflow_dispatch', conclusion: 'failure' })] }))).toBe('newer_run_vetoes');
|
||||
expect(reason(world({ others: [skipped({ event: 'workflow_dispatch', status: 'in_progress', conclusion: null })] }))).toBe('newer_run_vetoes');
|
||||
});
|
||||
|
||||
test('a newer failure on another head the consumer names (same tree, the lane\'s own head) vetoes too', () => {
|
||||
const w = world();
|
||||
const other = 'e'.repeat(40);
|
||||
|
||||
Reference in new issue
Block a user