Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci: a re-run after a turn-away waits for room again (#10554)

Cindy Zhangde5127e2125a
diff --git a/.github/scripts/ci-admission.test.mjs b/.github/scripts/ci-admission.test.mjs
index 1f1fb50fc4..ffe59fb7ad 100644
--- a/.github/scripts/ci-admission.test.mjs
+++ b/.github/scripts/ci-admission.test.mjs
@@ -74,7 +74,9 @@ describe('where runs wait', () => {
}
expect(stepOf(room).with.phase).toBe('room');
expect(stepOf(room).id).toBe('room');
- expect(wait.with.phase).toBe('rest');
+ expect(wait.with.phase).toBe(
+ "${{ needs.room.outputs.attempt == github.run_attempt && 'rest' || 'whole' }}",
+ );
expect(needsOf(admission)).toEqual(['room']);
expect(room.permissions).toEqual({actions: 'read', contents: 'read'});
// The rest of the wait carries on from where room left off.
@@ -218,6 +220,23 @@ describe('where runs wait', () => {
]);
});
+ it('makes a re-run of the failed jobs wait again after a stop for no room', () => {
+ const room = ci.jobs.room;
+ // A stop for no room fails room itself, so a re-run of the failed jobs
+ // repeats room's look instead of reusing its earlier result.
+ const stop = room.steps.at(-1);
+ expect(stop.name).toBe('Stop when CI is full');
+ expect(stop.if).toBe("steps.room.outputs.full == 'true'");
+ expect(stop.run).toContain('CI is full: re-run all jobs or push later.');
+ expect(stop.run.trim().endsWith('exit 1')).toBe(true);
+ // A re-run of admission alone carries on no earlier attempt's clock: it
+ // waits for the whole run from its own start.
+ expect(room.outputs.attempt).toBe('${{ github.run_attempt }}');
+ expect(wait.with.phase).toBe(
+ "${{ needs.room.outputs.attempt == github.run_attempt && 'rest' || 'whole' }}",
+ );
+ });
+
it('skips only with every other job, and never fails, so every job and required check decides as before', () => {
// The pull-request gate every job carries: a draft or an unlabelled fork
// runs no CI (FR17). Every other event is admitted.
@@ -272,8 +291,11 @@ describe('where runs wait', () => {
name: 'Stop when CI is full at the longest wait',
}),
]);
+ // Room's only other steps: its checkout, and its stop when it found no
+ // room (above).
expect(ci.jobs.room.steps.filter(step => step.name !== STEP)).toEqual([
expect.objectContaining({uses: 'actions/checkout@v7'}),
+ expect.objectContaining({name: 'Stop when CI is full'}),
]);
});
diff --git a/.github/scripts/ci-native-swift.test.mjs b/.github/scripts/ci-native-swift.test.mjs
index 9564d63b3a..e48a520c21 100644
--- a/.github/scripts/ci-native-swift.test.mjs
+++ b/.github/scripts/ci-native-swift.test.mjs
@@ -76,7 +76,7 @@ describe('native Swift routing', () => {
it('fails closed when the runner cannot be decided', () => {
expect(step(swift, 'Require a decided Swift runner').if).toBe(
- "needs.admission.result != 'failure' && needs.native-swift-runner.result != 'success'",
+ "needs.admission.result != 'failure' && needs.admission.result != 'skipped' && needs.native-swift-runner.result != 'success'",
);
for (const candidate of swift.steps) {
if (
@@ -95,7 +95,11 @@ describe('native Swift routing', () => {
it('fails a run CI admission turned away with that reason, not as a Swift failure', () => {
const refused = step(swift, 'Stop when CI admission refused the run');
expect(swift.steps[0]).toBe(refused);
- expect(refused.if).toBe("needs.admission.result == 'failure'");
+ // Admission fails at its own stop, and skips when room stopped the run.
+ expect(refused.if).toBe(
+ "needs.admission.result == 'failure' || needs.admission.result == 'skipped'",
+ );
+ expect(ci.jobs.room.steps.at(-1).name).toBe('Stop when CI is full');
expect(refused.run).toContain(
'CI admission refused this run (CI full); re-run all jobs.',
);
@@ -124,6 +128,9 @@ describe('native Swift routing', () => {
);
expect(evaluate(asJs(refused.if), 'failure', 'skipped')).toBe(true);
expect(evaluate(asJs(decided.if), 'failure', 'skipped')).toBe(false);
+ // Room stopped the run, so admission skipped.
+ expect(evaluate(asJs(refused.if), 'skipped', 'skipped')).toBe(true);
+ expect(evaluate(asJs(decided.if), 'skipped', 'skipped')).toBe(false);
expect(evaluate(asJs(refused.if), 'success', 'failure')).toBe(false);
expect(evaluate(asJs(decided.if), 'success', 'failure')).toBe(true);
expect(evaluate(asJs(decided.if), 'success', 'success')).toBe(false);
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 28309b130e..06d9db5541 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -129,6 +129,7 @@ jobs:
started: ${{ steps.room.outputs.started }}
looks: ${{ steps.room.outputs.looks }}
next: ${{ steps.room.outputs.next }}
+ attempt: ${{ github.run_attempt }}
steps:
- name: Check out the admission action
uses: actions/checkout@v7
@@ -150,6 +151,14 @@ jobs:
max-looks: ${{ github.event_name == 'workflow_dispatch' && 30 || 2 }}
label-legs: '{"ci:run-visual": 6, "ci:run-rtl": 9, "ci:run-a11y": 5}'
+ # A run stopped for no room fails here, so a re-run of its failed jobs
+ # waits again from this job, not from this look's result.
+ - name: Stop when CI is full
+ if: steps.room.outputs.full == 'true'
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. The run found no room under the CI ceiling."
+ exit 1
+
admission:
needs: [room]
if: (github.event_name != 'pull_request' || !github.event.pull_request.draft && (github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')))
@@ -181,8 +190,11 @@ jobs:
uses: ./.ci-admission/.github/actions/ci-admission
continue-on-error: true
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 125 || 13 }}
+ # A re-run of this job alone reuses an earlier attempt's room
+ # outputs, whose clock has run out, so it waits for the whole run on
+ # its own clock.
with:
- phase: rest
+ phase: ${{ needs.room.outputs.attempt == github.run_attempt && 'rest' || 'whole' }}
fits: ${{ needs.room.outputs.fits }}
started: ${{ needs.room.outputs.started }}
looks: ${{ needs.room.outputs.looks }}
@@ -1206,15 +1218,16 @@ jobs:
contents: read
steps:
# A run CI admission turned away decides no runner either; say so, so the
- # required check fails with the true reason.
+ # required check fails with the true reason. Admission skips when the
+ # first wait (room) stopped the run.
- name: Stop when CI admission refused the run
- if: needs.admission.result == 'failure'
+ if: needs.admission.result == 'failure' || needs.admission.result == 'skipped'
run: |
echo "::error title=CI is full::CI admission refused this run (CI full); re-run all jobs."
exit 1
- name: Require a decided Swift runner
- if: needs.admission.result != 'failure' && needs.native-swift-runner.result != 'success'
+ if: needs.admission.result != 'failure' && needs.admission.result != 'skipped' && needs.native-swift-runner.result != 'success'
run: |
echo "The Swift runner could not be decided; refusing to skip required work."
exit 1
diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.md
index 00e2a83319..741c522f6a 100644
--- a/docs/specs/AST-030/spec.md
+++ b/docs/specs/AST-030/spec.md
@@ -415,7 +415,9 @@ they are separately named.
longest wait looks once more and starts only if no other pull-request run
started at its longest wait in the last ten minutes and no run that waited
longer still waits; otherwise it stops with "CI is full: re-run all jobs or
- push later", and its required checks report the stopped run. A pull request that may not run CI admits nothing, and
+ push later", and its required checks report the stopped run. A run stopped
+ for no room fails its waiting job, so a re-run of its failed jobs waits again
+ from the start. A pull request that may not run CI admits nothing, and
waiting never fails a job, so every required context reports as before. A
tool that grants CI capacity reads it through the same count admission uses
(`.github/actions/ci-admission/count.mjs`), with no count of its own.
@@ -657,6 +659,7 @@ The nightly perf lane is the one scheduled measurement outside them (FR18).
| FR15 | workflow contract and reconciler tests | ENGOWNER spec PR; owner command; other comment; fork review; non-spec PR; run over the request budget; maintainer dispatch; fork PR, code-only: an owner's exact-head approval plus the owner command clears the code half | `review-required` succeeds while spec approval is missing, another workflow publishes a review context, a fork review starts the spec checks, a non-command comment starts a runner, an over-budget run decides, or a fork's approved code-only PR stays pending after the owner command |
| FR16 | `heavy-caps-action.test.mjs` cap cases and heavy-job contract; `ci-admission.test.mjs` | sixteenth-oldest PR; 101st heavy run of the day, beside cancelled, light and other-branch runs; agent lane and its five-PR and forty-run backstops; an engineering owner, including the shared login past those backstops, a commented-out or trailing-comment handle and an unreadable roster; bot; the deciding run; re-run; failed lookup; a run with room, without room, past its longest wait, beside a waiting `main` check, as a draft or unlabelled fork, with opt-in labels, beside small workflows past their measured most, and with the API unreadable; each workflow's most jobs; every required context's rule; a full queue: the capacity tool and admission agree there is no room | a heavy suite that runs ahead of the author's fifteen oldest PRs, or past the daily cap, a capped job that passes, an engineering owner or a re-run that is held, or a roster read from the pull request's head, a run that starts without room before its longest wait, a pull-request run that starts while `main` has waited under fifteen minutes, a job admission could skip, a peak below the jobs its run holds, or a job on a slim runner planned past its fifteen-minute cap fails |
| FR16 | `ci-admission.test.mjs` cases for one start at the longest wait at a time and the workflow contract | a pull-request run at its longest wait alone, within ten minutes of another pull-request run's start there and after them, behind a run that waited longer and ahead of a younger one; another run that found room earlier, a fork's stopped run and a `main` run that waited its longest; a `main` run and a merge-queue entry at their longest wait; the rest of a run whose Storybook build found room; ten runs out of time together; the required contexts and ci-full for either wait; a pull-request run that finds ten others waiting and room only for its Storybook build, and one at its longest wait behind more than ten that waited longer; two waiting `main` dispatches, the older and the younger, and two that began in the same second (each counting the other's peak fails) | two pull-request runs start at their longest wait within ten minutes, a younger run starts ahead of a longer waiter, a `main` run or merge-queue entry stops, a run CI is full for builds, or a required context passes or skips |
+| FR16 | `ci-admission.test.mjs` re-run case | a run stopped for no room; a re-run of its failed jobs; a re-run of the second wait alone | a re-run of the failed jobs that reuses an earlier attempt's room result or clock |
| FR17 | `ci-pr-gate.test.mjs` over every `pull_request` workflow and the shared conditions | branch here, fork with and without `ci:run`, another label, draft with the label, ready, push, merge group, dispatch | a job that can start on a pull request without the condition, a label trigger, a required job that skips for a pull request that may not run CI, or a draft or unlabelled fork that runs fails |
| FR18 | `perf-nightly-workflow.test.mjs`, `perf-trend.test.mjs` and `run-labels.test.mjs` | nightly and dispatch; labelled, unlabelled, draft and unvouched-fork pull requests; write, read and no access; newest label event; failed lookup; 10% boundary; metric floors; seven-day window edges; fewer than three runs; a metric over once, twice in a row, or a different metric before; recorded and pull request runs | a run on an unlabelled pull request, a label honoured from read access, a regression called at exactly 10%, under its floor or on one run alone, a run outside the window in the baseline, a pull request run that records, or a second regression issue fails |
| FR18 | `overlay-churn-settled` on one commit, five samples per run | medians within 1% between a standard run and a `PERF_CPU_THROTTLE=4` run on the same runner (Chromium's CPU slowed four times) | interaction-layout medians more than 1% apart fail |