Skip to content

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

TypeScript

ci: the Storybook build starts beside admission, so a run's wait and build overlap (AST-030 FR16, DEC-16) (#9338)

Cindy Zhangc2df49477317
diff --git a/.github/actions/ci-admission/action.yml b/.github/actions/ci-admission/action.yml
index 24ae96378c..dbca34dcb7 100644
--- a/.github/actions/ci-admission/action.yml
+++ b/.github/actions/ci-admission/action.yml
@@ -5,7 +5,8 @@
# (a `concurrency` group serializes runs, it does not count jobs), so each run
# waits for room before its jobs start:
#
-# - ci.yml's `admission` job, which every other ci.yml job needs, and the Main
+# - ci.yml's `admission` job, which every other ci.yml job but the Storybook
+# build needs (that build starts beside it, and every job using it waits), and the Main
# workflow's `main-commit` job run this first. A step that uses this action
# MUST be named "Wait for room under the CI ceiling": a waiting `main` run is
# found by that name.
@@ -21,8 +22,9 @@
# plus a random 0-20 s so runs that look together spread out, and then
# starts.
# - Each CI or Main run counts its live jobs, read once per look. A
-# pull-request run still waiting here counts only that waiting job, so
-# waiting runs never hold each other back by more than they use; a waiting
+# pull-request run still waiting here counts the jobs it runs, its waiting
+# job and the Storybook build that starts beside it, so waiting runs never
+# hold each other back by more than they use; a waiting
# `main` run counts its whole peak. A run admitted in the last 45 seconds,
# before its jobs appear, counts at least its planned most. Every other
# workflow's run counts an estimate. A run not updated in two hours is a
@@ -166,10 +168,11 @@ runs:
.flatMap(job => job.steps ?? [])
.find(step => step.name === STEP);
if (wait?.status === 'in_progress') {
- // Still waiting for room. A pull-request run holds only
- // the job that waits; a `main` run holds its whole peak,
- // ahead of this one.
- const holds = isMain(run) ? estimate(run) : 1;
+ // Still waiting for room. A `main` run holds its whole
+ // peak, ahead of this one. A pull-request run holds what
+ // it runs: the job that waits and its Storybook build,
+ // which starts beside it.
+ const holds = isMain(run) ? estimate(run) : Math.max(1, jobs.filter(job => LIVE.includes(job.status)).length);
if (isMain(run) && !main) mainWaiting = true;
large += holds;
counted.push(`${short(run)} ${run.id} ${run.event}: ${holds} waiting`);
diff --git a/.github/scripts/ci-admission.test.mjs b/.github/scripts/ci-admission.test.mjs
index 073b7e1abd..eb34ff501f 100644
--- a/.github/scripts/ci-admission.test.mjs
+++ b/.github/scripts/ci-admission.test.mjs
@@ -51,11 +51,17 @@ describe('where runs wait', () => {
expect(admission['runs-on']).toBe('ubuntu-slim');
expect(admission.permissions).toEqual({actions: 'read', contents: 'read'});
expect(wait.uses).toBe('./.ci-admission/.github/actions/ci-admission');
- // Directly, or through the jobs it needs.
+ // Directly, or through the jobs it needs. The Storybook build starts
+ // beside admission, so no job reaches admission only through it.
+ const BESIDE = 'build-storybook';
+ expect(needsOf(ci.jobs[BESIDE])).toEqual([]);
const reaches = id =>
- needsOf(ci.jobs[id]).some(need => need === 'admission' || reaches(need));
+ needsOf(ci.jobs[id]).some(
+ need => need === 'admission' || (need !== BESIDE && reaches(need)),
+ );
for (const id of Object.keys(ci.jobs)) {
- if (id !== 'admission') expect(reaches(id), id).toBe(true);
+ if (id !== 'admission' && id !== BESIDE)
+ expect(reaches(id), id).toBe(true);
}
});
@@ -552,6 +558,20 @@ describe('ci admission', () => {
maxLooks: 2,
});
expect(held.looks).toBe(2);
+ // A waiting pull-request run whose Storybook build started beside its
+ // wait holds both: 48 + 2 x 4 + 18 + 16 = 90 fits; a fifth does not.
+ const building = id => ({
+ ...waitingRun(id),
+ jobs: [...waitingRun(id).jobs, {status: 'in_progress', steps: []}],
+ });
+ const withBuilds = count =>
+ Array.from({length: count}, (_, i) => building(90 + i));
+ expect(
+ (await admit({active: [...prs(4), ...withBuilds(4)], peak: 16})).looks,
+ ).toBe(1);
+ expect(
+ (await admit({active: [...prs(4), ...withBuilds(5)], peak: 16})).looks,
+ ).toBeGreaterThan(1);
// Other pull-request runs waiting for room hold only their waiting jobs:
// 48 + 8 waiting + 18 + 16 = 90 fits; a ninth waiting run does not.
const waiting = count =>
diff --git a/.github/scripts/ci-interaction-webkit.test.mjs b/.github/scripts/ci-interaction-webkit.test.mjs
index d67eb68641..0646bf8bed 100644
--- a/.github/scripts/ci-interaction-webkit.test.mjs
+++ b/.github/scripts/ci-interaction-webkit.test.mjs
@@ -58,7 +58,8 @@ describe('WebKit interaction proof routing', () => {
expect(ungated(webkit.if)).toBe(
"github.event_name != 'workflow_dispatch' && always() && !cancelled()",
);
- expect(webkit.needs).toEqual(['build-storybook']);
+ // Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
+ expect(webkit.needs).toEqual(['admission', 'build-storybook']);
});
it('stays on a standard runner within the 15-minute budget', () => {
diff --git a/.github/scripts/ci-interaction.test.mjs b/.github/scripts/ci-interaction.test.mjs
index cd075ab859..118dcf5b43 100644
--- a/.github/scripts/ci-interaction.test.mjs
+++ b/.github/scripts/ci-interaction.test.mjs
@@ -49,7 +49,8 @@ describe('interaction proof routing', () => {
expect(ungated(proofs.if)).toBe(
"github.event_name != 'workflow_dispatch' && always() && !cancelled()",
);
- expect(proofs.needs).toEqual(['build-storybook']);
+ // Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
+ expect(proofs.needs).toEqual(['admission', 'build-storybook']);
});
it('decides its own scope first, and gates every later step on it', () => {
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjs
index 48944dd898..467e3e0ec0 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -778,7 +778,8 @@ describe('ci.yml interaction proofs', () => {
it('runs the interaction config in Chromium against the exact PR head', () => {
// One fixed runner: out of scope, every step after the scope step skips.
expect(KNOWN_RUNNERS.has(job['runs-on']), job['runs-on']).toBe(true);
- expect(job.needs).toEqual(['build-storybook']);
+ // Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
+ expect(job.needs).toEqual(['admission', 'build-storybook']);
const checkout = job.steps.find(
candidate =>
candidate.uses?.startsWith('actions/checkout@') &&
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f0ae0c27ce..ca2ca7bbc5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -93,8 +93,9 @@ concurrency:
jobs:
# Admits the whole run under CI's ceiling of about ninety concurrent jobs
- # (spec:AST-030 FR16, DEC-16). Every job here needs this one, directly or
- # through the jobs it needs. Like every other job it skips for a draft or an
+ # (spec:AST-030 FR16, DEC-16). Every job here but build-storybook needs this
+ # one, directly or through the jobs it needs; build-storybook starts beside
+ # it, and every job that uses the build needs this one too. Like every other job it skips for a draft or an
# unlabelled fork, which run no CI (FR17); the required contexts still report
# through their own status rules. Otherwise it never fails, so each job's own
# condition decides exactly as before. `peak` is the most jobs a run holds at once: a
@@ -979,7 +980,9 @@ jobs:
await decideRunLabels({github, context, core});
build-storybook:
- needs: [admission]
+ # Starts beside admission instead of after it: it is one job, and every
+ # job that uses its build also needs admission, so the run's heavy legs
+ # still wait for room (spec:AST-030 FR16, DEC-16).
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'))) && ((github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled()) }}
# Every browser lane waits for this job, and the package builds and the
# Storybook build run side by side (build-packages-and-storybook.mjs).
@@ -1442,7 +1445,7 @@ jobs:
# pr-a11y itself, so neither runs there.
pr-a11y-shard:
name: pr-a11y (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [build-storybook]
+ needs: [admission, build-storybook]
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
strategy:
fail-fast: false
@@ -1793,7 +1796,7 @@ jobs:
# pr-a11y.
a11y-contracts-shard:
name: Accessibility spec-test contracts (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [build-storybook]
+ needs: [admission, build-storybook]
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
# Six legs: at three, the slowest leg took ~20 minutes, held by its longest
# spec file; files longer than a leg's share are now cut across legs
@@ -1904,7 +1907,7 @@ jobs:
delete-merged: true
pr-interaction:
- needs: [build-storybook]
+ needs: [admission, build-storybook]
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'))) && (github.event_name != 'workflow_dispatch' && always() && !cancelled()) }}
# Frame evidence measures timing: four cores, one Playwright worker.
runs-on: ubuntu-latest
@@ -2022,7 +2025,7 @@ jobs:
# required context. Specs that need Chromium-only evidence skip themselves
# in WebKit.
pr-interaction-webkit:
- needs: [build-storybook]
+ needs: [admission, build-storybook]
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'))) && (github.event_name != 'workflow_dispatch' && always() && !cancelled()) }}
# Frame evidence measures timing: four cores, one Playwright worker.
runs-on: ubuntu-latest
diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.md
index dc614e8785..462bad99f8 100644
--- a/docs/specs/AST-030/spec.md
+++ b/docs/specs/AST-030/spec.md
@@ -340,13 +340,14 @@ they are separately named.
visual, accessibility and RTL owners a maintainer opts a pull request into
with their `ci:run-*` labels are unaffected by these per-author limits. Every
run of the CI and Main workflows, of any event, waits for room before its jobs
- start: it starts once the other active runs' estimated jobs plus its own most
- fit under about ninety, and a pull-request run also waits while a `main` full
- check, release re-check or baseline capture is waiting, looking twice on a
- pull request, at once and after twelve minutes, and every two minutes for at
- most fifteen for `main` (DEC-16). A pull request that may not run CI admits
- nothing, and waiting never fails a job, so every required context reports as
- before.
+ start, except the CI workflow's Storybook build, which starts beside the wait
+ while every job that uses it still waits: it starts once the other active
+ runs' estimated jobs plus its own most fit under about ninety, and a
+ pull-request run also waits while a `main` full check, release re-check or
+ baseline capture is waiting, looking twice on a pull request, at once and
+ after twelve minutes, and every two minutes for at most fifteen for `main`
+ (DEC-16). A pull request that may not run CI admits nothing, and waiting never
+ fails a job, so every required context reports as before.
- **FR17 — A pull request runs CI when it is ready and a maintainer can vouch
for it.** A draft pull request runs no CI, and marking it ready for review
starts its pull-request run, which runs what the change reaches (FR13,
@@ -739,17 +740,19 @@ its own fit under ninety. Small workflows that are not admitted (linting, review
bookkeeping, report publishing) always count at least the most they were
measured running at once, eighteen jobs, so the room they can take stays free.
Each CI or Main run counts its live jobs: a pull-request run still waiting
-counts only the job that waits, so waiting runs hold each other back by no more
-than they use, and a run admitted in the last forty-five seconds, before its
-jobs appear, counts at least its planned most. A run GitHub still lists as
-active but has not updated in two hours holds no runner and counts nothing. A
-look reads the active runs and each CI or Main run's jobs once, so it costs two
-run listings plus one call per active CI or Main run. A pull request looks at
-most twice, and a run starts rather than spend a low API budget. A `main` full
-check, release re-check or baseline capture (every dispatch of the CI workflow)
-goes first: while one waits, pull-request runs wait too. Every job ends within
-its fifteen-minute budget, so `main` fits within fifteen minutes. Nothing is
-reserved for `main` outside those minutes.
+counts the jobs it runs, the job that waits and the Storybook build that starts
+beside it, so waiting runs hold each other back by no more than they use, and a
+run admitted in the last forty-five seconds, before its jobs appear, counts at
+least its planned most. A run GitHub still lists as active but has not updated
+in two hours holds no runner and counts nothing. A look reads the active runs
+and each CI or Main run's jobs once, so it costs two run listings plus one call
+per active CI or Main run. A pull request looks at most twice, and a run starts
+rather than spend a low API budget. A `main` full check, release re-check or
+baseline capture (every dispatch of the CI workflow) goes first: while one
+waits, pull-request runs wait too, all but their Storybook builds, which the
+waiting check counts. Every job ends within its fifteen-minute budget, so `main`
+fits within fifteen minutes. Nothing is reserved for `main` outside those
+minutes.
CI can still pass ninety in three rare, bounded ways: