Skip to content

Commit 6903a73

Browse files
committed
ci: fail fast on the test, test-ui and dogfood matrices in the merge queue only
`strategy.fail-fast: ${{ github.event_name == 'merge_group' }}` on the three matrices: a red queue shard cancels its siblings, so the aggregate reads red when that shard ends rather than when the slowest one does. Pull request, push and schedule runs keep every shard running to its end. The A1 comments say the queue is the exception and why. check-shard-attestation's self-test gains the fail-fast shape (one shard red, the rest cancelled by the strategy, the measured cancel annotation of run 30271824408), and ci-shard-matrix's fixture spells the new strategy. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSkaG5iii6WC7w4qSX
1 parent f2abd47 commit 6903a73

3 files changed

Lines changed: 90 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,24 @@ jobs:
10411041
# simply never created. The literal after `||` is the full roster, read
10421042
# when the plan job published nothing (it died or timed out), and the gate
10431043
# reads this same expression, so the two cannot count different rosters.
1044+
#
1045+
# ⭐ FAIL-FAST IN THE MERGE QUEUE ONLY (#31517, ruling record 6730013883).
1046+
# On a `merge_group` run the first shard to go red cancels its siblings,
1047+
# so `Test Core` reads red when that shard ends instead of when the
1048+
# slowest shard ends, and the queue ejects the entry and rebuilds the
1049+
# entries behind it that much sooner. On every other event the
1050+
# expression is false and every shard runs to its end: the pull_request
1051+
# run is where an author reads every red shard in one round (#23177
1052+
# ruling B, item A1, comment 6139629628), and push and schedule runs stay
1053+
# complete. The queue is the exception because its job is a fast
1054+
# mergeable-or-not answer, and the PR run of the same diff already
1055+
# showed every red. It is the matrix's own `fail-fast`, ⛔ never a
1056+
# run-level cancel: a real red dominates the matrix result (`failure`,
1057+
# never `cancelled`, measured on run 30271824408, a fail-fast matrix),
1058+
# and `Test Core` reads `failure` as a veto, whereas a matrix cancelled
1059+
# with zero attestations passes its aggregate (#3668).
10441060
strategy:
1045-
fail-fast: false
1061+
fail-fast: ${{ github.event_name == 'merge_group' }}
10461062
matrix:
10471063
shard: ${{ fromJSON(needs.test-plan.outputs.shards || '[1, 2, 3, 4, 5, 6, 7, 8]') }}
10481064

@@ -1580,6 +1596,11 @@ jobs:
15801596
# non-zero exit, and the step exits with it, so the shard is red
15811597
# exactly when it was before — and now names every red package of the
15821598
# shard in one run instead of the first one turbo reached.
1599+
# A1 holds inside a shard on every event. Across shards the merge
1600+
# queue is the exception (#31517, ruling record 6730013883): there
1601+
# the matrix is fail-fast, so the first red shard cancels the
1602+
# others, and the queue run names that shard's reds only. The
1603+
# pull_request run of the same diff names every shard's.
15831604
#
15841605
# Measured before this was written: a three-package probe (turbo
15851606
# 2.11.5, `a#test` exits 1, `c` depends on `a`) ran `b` and `c` to
@@ -2716,8 +2737,13 @@ jobs:
27162737
timeout-minutes: 30
27172738
permissions:
27182739
contents: read
2740+
# Fail-fast on `merge_group` only, as on Test Core (#31517, ruling record
2741+
# 6730013883; the reasons are on the `test` job's strategy). Push and
2742+
# schedule, the other events this matrix runs on, run all three shards to
2743+
# their end. A red shard dominates the matrix result over the siblings it
2744+
# cancels, and `Dogfood Regression Gate` reads `failure` as a veto.
27192745
strategy:
2720-
fail-fast: false
2746+
fail-fast: ${{ github.event_name == 'merge_group' }}
27212747
matrix:
27222748
shard: [1, 2, 3]
27232749

@@ -3083,7 +3109,11 @@ jobs:
30833109
# 30271824408, a fail-fast matrix with one real failure + one cancelled
30843110
# sibling): a real shard failure DOMINATES the aggregate — it reads
30853111
# "failure", never "cancelled" — so passing `cancelled` masks no
3086-
# regression. That dominance is what does NOT hold for `abandoned`, which
3112+
# regression. That run is the merge queue's own shape since #31517: the
3113+
# dogfood matrix is fail-fast on `merge_group`, and the sibling a red
3114+
# shard cancels records "The strategy configuration was canceled
3115+
# because …" on its check run, which the cause read classifies as no
3116+
# supersession: a partially attested matrix it cut short reads red. That dominance is what does NOT hold for `abandoned`, which
30873117
# is why `abandoned` gets counting rather than a place in a word list.
30883118
name: Dogfood Regression Gate
30893119
needs: [dogfood, dogfood-verify, filter, queue-verdict]
@@ -4147,8 +4177,15 @@ jobs:
41474177
timeout-minutes: 30
41484178
permissions:
41494179
contents: read
4180+
# Fail-fast on `merge_group` only, as on Test Core (#31517, ruling record
4181+
# 6730013883; the reasons are on the `test` job's strategy). Every other
4182+
# event runs all sixteen shards to their end. The `Test UI` aggregate
4183+
# passes only `success` or a skip `filter` explains, so the matrix of a
4184+
# red shard and the siblings it cancelled reads red there. A fail-fast queue run is red, so a push never
4185+
# borrows it: `queue-verdict` takes only a `success` queue run, and
4186+
# `ui_full_green` counts only shards that concluded `success`.
41504187
strategy:
4151-
fail-fast: false
4188+
fail-fast: ${{ github.event_name == 'merge_group' }}
41524189
matrix:
41534190
shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
41544191

@@ -4373,7 +4410,9 @@ jobs:
43734410
# That is #4928's skipped-only-when-filter-succeeded guard, and it makes a
43744411
# queue build or PR that touches no ui path read green here the way Lint
43754412
# UI and Build & E2E UI read `skipped` there. Everything else is red:
4376-
# `failure`; `cancelled`, which is also what a shard killed by its own
4413+
# `failure`, which is also what the matrix reads when a red shard on a
4414+
# `merge_group` run cancelled its siblings by fail-fast (#31517);
4415+
# `cancelled`, which is also what a shard killed by its own
43774416
# `timeout-minutes` reads (on a superseded push this paints the OLD sha
43784417
# red, which no required check reads); a `skipped` that `filter` does not
43794418
# explain; and any lifecycle value such as the `abandoned` test-gate met

‎scripts/check-shard-attestation.mjs‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@
8080
* `cancelled`. So a superseded matrix masks no regression, and demanding
8181
* credentials there would paint the false red on the superseded SHA that
8282
* #3668 removed.
83+
* Since #31517 (ruling record 6730013883) the merge queue's `test` and
84+
* `dogfood` matrices are fail-fast, which is run 30271824408's own shape:
85+
* the red shard's `failure` dominates the leg, the leg's declared negative
86+
* vetoes the gate, and the shards the strategy cancelled are missing from
87+
* the count. Such a shard records `The strategy configuration was
88+
* canceled because "…" failed` on its check run, which
89+
* `classifyCancelAnnotations` reads as `other`, never a supersession.
8390
* ⛔ That argument covers a shard that RAN AND FAILED. It does not cover a
8491
* shard killed while still executing, which produces no verdict at all —
8592
* there is no `failure` to dominate (#16157, run 34007386254: `Test Core
@@ -1740,11 +1747,12 @@ const SELF_TEST_BATTERIES = Object.freeze({
17401747
'#26084 a planned roster: only the shards the plan started are counted': 16,
17411748
'#26084 the static guard holds the planned matrix and the gate to one expression': 10,
17421749
'#31519 a borrowed push: the gate skip and the seed-only credential guard': 8,
1750+
'#31517 merge-queue fail-fast: one shard red, the rest cancelled by the strategy': 8,
17431751
});
17441752

17451753
// DELETING an entry silences that battery's floor exactly as effectively as
17461754
// zeroing it, so the roster's own size is pinned too.
1747-
const SELF_TEST_BATTERY_FLOOR = 25;
1755+
const SELF_TEST_BATTERY_FLOOR = 26;
17481756

17491757
// The key an assertion is filed under when no battery is open. It is not a
17501758
// declared battery, so it reds by the same set difference rather than silently
@@ -2293,6 +2301,40 @@ async function selfTest() {
22932301
"#22653 control: the single-leg path keeps #22606's verdict and words — a killed CLI leg is red beside a superseded matrix shard",
22942302
);
22952303

2304+
// ── #31517: the merge queue's matrices are fail-fast ─────────────────────
2305+
// On `merge_group` the `test` and `dogfood` matrices stop their remaining
2306+
// shards once one is red (ruling record 6730013883). The shape is run
2307+
// 30271824408's: the red shard concludes `failure`, the shards the strategy
2308+
// cancelled conclude `cancelled` and attest nothing, and the matrix result
2309+
// reads `failure`. The annotation below is that run's cancelled shard (check
2310+
// run 89995981782), read from the check-run annotations endpoint.
2311+
battery('#31517 merge-queue fail-fast: one shard red, the rest cancelled by the strategy');
2312+
const FAIL_FAST_ANNOTATIONS = [annotation('The strategy configuration was canceled because "matrix._1" failed'), annotation('The operation was canceled.')];
2313+
const failFast = (ids) => testCore(ids, undefined, { result: 'failure' });
2314+
const fastShardsFirst = failFast([1, 3].map((n) => attest('test', n, 6)));
2315+
assert(!fastShardsFirst.ok, '#31517: shard 2 red, 1 and 3 attested before it, 4-6 cancelled by fail-fast ⇒ red');
2316+
assert(
2317+
fastShardsFirst.errors.some((e) => e.includes("reported result 'failure'")) &&
2318+
fastShardsFirst.errors.some((e) => [2, 4, 5, 6].every((n) => e.includes(`test-${n}-of-6`))),
2319+
'#31517: …by the declared negative AND by the count, which names the red shard and every shard it cancelled',
2320+
);
2321+
assert(!failFast([]).ok, '#31517: the first shard red before any sibling attested, all cancelled ⇒ red — `failure` is never the zero-attestation #3668 pass');
2322+
assert(
2323+
shardsNeedingCancelCause(testLegs('failure'), new Map([1, 3].map((n) => attest('test', n, 6)))).length === 0,
2324+
'#31517: a fail-fast matrix reads `failure`, so the gate asks no cancel cause — no API read can turn it green',
2325+
);
2326+
assert(classifyCancelAnnotations(FAIL_FAST_ANNOTATIONS).kind === 'other', "#31517: a shard cancelled by its matrix's fail-fast is never read as a supersession");
2327+
const ifItEverReadCancelled = testCore(only5, new Map([1, 2, 3, 4, 6].map((n) => [attestationId('test', n, 6), classifyCancelAnnotations(FAIL_FAST_ANNOTATIONS)])));
2328+
assert(
2329+
!ifItEverReadCancelled.ok && ifItEverReadCancelled.errors.some((e) => e.includes('The strategy configuration was canceled')),
2330+
'#31517: were the matrix ever to read `cancelled` after a sibling attested, the fail-fast cause still reds it, quoting the record',
2331+
);
2332+
assert(
2333+
!judge({ gate: 'Test Core', legs: [{ job: 'test', total: 8, result: 'failure', shards: [2, 5, 7], planResult: 'success' }], filterResult: 'success', present: new Map([attest('test', 5, 8)]), runId: '99' }).ok,
2334+
'#31517 × #26084: a planned roster cut short by fail-fast ⇒ red',
2335+
);
2336+
assert(!dogfood('failure', 'success', [fullDogfood[0], fullDogfood[3]]).ok, '#31517: dogfood 2/3 red, 3/3 cancelled by fail-fast, the CLI leg green ⇒ the Dogfood Regression Gate reads red');
2337+
22962338
// ── #22653: the per-shard cause read itself, offline ─────────────────────
22972339
battery('#22653 the cause read, offline: one jobs list, then one annotations read per unattested shard');
22982340
const CI_TEXT = readFileSync(join(scriptRepoRoot(), '.github', 'workflows', 'ci.yml'), 'utf8');

‎scripts/ci-shard-matrix.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ function selfTest() {
217217
check(`${label} ⇒ refused naming '${needle}' (got ${JSON.stringify(message)})`, message !== null && message.includes(needle) && message.includes(`job '${job}'`));
218218
};
219219
const workflow = (body) => `on: push\njobs:\n${body}`;
220-
const matrixJob = (id, shardLine, extra = '') => ` ${id}:\n runs-on: ubuntu-latest\n${extra} strategy:\n fail-fast: false\n matrix:\n ${shardLine}\n steps:\n - run: echo\n`;
220+
// The strategy spells ci.yml's sharded jobs' `fail-fast` (merge-queue only, #31517), so the
221+
// reader is exercised over an expression line between `strategy:` and `matrix:`.
222+
const matrixJob = (id, shardLine, extra = '') => ` ${id}:\n runs-on: ubuntu-latest\n${extra} strategy:\n fail-fast: \${{ github.event_name == 'merge_group' }}\n matrix:\n ${shardLine}\n steps:\n - run: echo\n`;
221223

222224
battery('the live ci.yml');
223225
const live = readFileSync(join(REPO_ROOT, CI_WORKFLOW), 'utf8');

0 commit comments

Comments
 (0)