Skip to content

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

TypeScript

ci: a waiting run holds one slim job: the Storybook build starts with room, and at most ten pull-request runs wait (AST-030 FR16, DEC-16) (#9352)

Cindy Zhangf1c23674e8b1
diff --git a/.github/actions/ci-admission/action.yml b/.github/actions/ci-admission/action.yml
index dbca34dcb7..f7bd68f757 100644
--- a/.github/actions/ci-admission/action.yml
+++ b/.github/actions/ci-admission/action.yml
@@ -5,11 +5,17 @@
# (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 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.
+# - ci.yml runs it twice. Its first job, `room` (`phase: room`), waits until
+# there is room for one job, the Storybook build, which then starts, and
+# records whether the whole run fit on that look. `admission`
+# (`phase: rest`), which every other ci.yml job needs, waits for the rest of
+# the run unless it already fit. The Main workflow's `main-commit` runs it once
+# (`phase: whole`). A waiting run so holds only its one waiting job, plus a
+# Storybook build that found room. A step that uses this action MUST be named
+# "Wait for room under the CI ceiling": a waiting run is found by that name.
+# - A pull-request run that finds no room and ten other pull-request runs
+# already waiting is turned away (`full`): CI is full, and the run stops with
+# that message. `main` runs are never turned away.
# - A run starts once the other active runs' estimated jobs plus `peak` fit
# under the ceiling. Small workflows that are not admitted (one or two slim
# jobs a run) always count at least their measured most at once, so the room
@@ -23,8 +29,8 @@
# starts.
# - Each CI or Main run counts its live jobs, read once per look. A
# 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
+# job and a Storybook build that found room, 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
@@ -59,12 +65,47 @@ inputs:
description: JSON map of a pull-request label to the jobs it adds to `peak`.
required: false
default: '{}'
+ phase:
+ description: "'whole' waits for the whole run; 'room' waits for room for one job and records whether the whole run fit; 'rest' waits for the rest of the run after 'room'."
+ required: false
+ default: whole
+ fits:
+ description: "For 'rest': 'true' when the whole run fit on the 'room' look."
+ required: false
+ default: ''
+ started:
+ description: "For 'rest': when 'room' started, in milliseconds since the epoch."
+ required: false
+ default: ''
+ looks:
+ description: "For 'rest': how many looks 'room' made."
+ required: false
+ default: ''
+
+outputs:
+ fits:
+ description: "'true' when the whole run fit on the last look."
+ value: ${{ steps.wait.outputs.fits }}
+ full:
+ description: "'true' when CI is full and this pull-request run is turned away."
+ value: ${{ steps.wait.outputs.full }}
+ started:
+ description: When the wait started, in milliseconds since the epoch.
+ value: ${{ steps.wait.outputs.started }}
+ looks:
+ description: How many looks the wait made.
+ value: ${{ steps.wait.outputs.looks }}
runs:
using: composite
steps:
- - uses: actions/github-script@v9
+ - id: wait
+ uses: actions/github-script@v9
env:
+ PHASE: ${{ inputs.phase }}
+ FITS: ${{ inputs.fits }}
+ STARTED: ${{ inputs.started }}
+ LOOKS: ${{ inputs.looks }}
PEAK: ${{ inputs.peak }}
MAIN: ${{ inputs.main }}
LABEL_LEGS: ${{ inputs.label-legs }}
@@ -82,6 +123,10 @@ runs:
const MAX_LOOKS = Math.max(1, Number(process.env.MAX_LOOKS || '8'));
const LOOK_MS = MAX_LOOKS > 1 ? (MAX_WAIT_MS - JITTER_MS) / (MAX_LOOKS - 1) : MAX_WAIT_MS;
const STEP = 'Wait for room under the CI ceiling';
+ // At most this many pull-request runs wait at once; one more finding
+ // no room is turned away (spec:AST-030 DEC-16).
+ const MAX_WAITING = 10;
+ const PHASE = process.env.PHASE || 'whole';
// The most jobs a run holds at once, by workflow: ci.yml's
// release-check and Main's unit run from their `peak`
// (ci-admission.test.mjs), a pull-request ci.yml run from its
@@ -126,14 +171,34 @@ runs:
for (const label of labels) peak += extra[label] ?? 0;
}
- const started = Date.now();
+ // 'rest' carries on the wait 'room' began: its clock and its looks.
+ const started = PHASE === 'rest' && Number(process.env.STARTED) > 0 ? Number(process.env.STARTED) : Date.now();
+ const looked = PHASE === 'rest' ? Math.max(0, Number(process.env.LOOKS) || 0) : 0;
+ core.setOutput('started', String(started));
+ // The rest waits only when room measured that the run did not fit;
+ // when room started on an API error or a low budget, so does the rest.
+ if (PHASE === 'rest' && process.env.FITS !== 'false') {
+ core.info(process.env.FITS === 'true' ? 'The whole run fit when its first job found room.' : 'Room did not measure the run; starting.');
+ return;
+ }
let calls = 0;
try {
- for (let look = 1; ; look += 1) {
+ if (looked > 0) {
+ // The next look falls where the wait's schedule puts it.
+ const next = started + looked * LOOK_MS - Date.now();
+ if (looked >= MAX_LOOKS || next > MAX_WAIT_MS - (Date.now() - started)) {
+ core.warning(`Still no room after ${MAX_WAIT_MS / 60_000} minutes; starting.`);
+ return;
+ }
+ if (next > 0) await new Promise(resolve => setTimeout(resolve, next + Math.floor(Math.random() * JITTER_MS)));
+ }
+ for (let look = looked + 1; ; look += 1) {
+ core.setOutput('looks', String(look));
const seen = new Set();
let large = 0;
let small = 0;
let mainWaiting = false;
+ let waitingPulls = 0;
// What each run counted, logged on every look.
const counted = [];
const smallBy = {};
@@ -164,22 +229,25 @@ runs:
const {data: {jobs}} = await github.rest.actions.listJobsForWorkflowRun({
...context.repo, run_id: run.id, filter: 'latest', per_page: 100,
});
- const wait = jobs
+ // A CI run waits in `room`, then in `admission`.
+ const waits = jobs
.flatMap(job => job.steps ?? [])
- .find(step => step.name === STEP);
- if (wait?.status === 'in_progress') {
+ .filter(step => step.name === STEP);
+ if (waits.some(step => step.status === 'in_progress')) {
// 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;
+ if (!isMain(run)) waitingPulls += 1;
large += holds;
counted.push(`${short(run)} ${run.id} ${run.event}: ${holds} waiting`);
continue;
}
const live = jobs.filter(job => LIVE.includes(job.status)).length;
- const admittedAt = Date.parse(wait?.completed_at ?? '');
+ const ended = waits.map(step => Date.parse(step.completed_at ?? '')).filter(Number.isFinite);
+ const admittedAt = ended.length > 0 ? Math.max(...ended) : NaN;
const fresh = Date.now() - admittedAt < JUST_ADMITTED_MS;
const holds = fresh ? Math.max(live, estimate(run)) : live;
large += holds;
@@ -189,10 +257,24 @@ runs:
const others = large + Math.max(small, SMALL_MOST);
const smallList = Object.entries(smallBy).map(([name, count]) => `${name} ${count}`).join(', ');
core.info(`Look ${look}: ${counted.join('; ') || 'no CI or Main runs'}. Small workflows ${small}${smallList ? ` (${smallList})` : ''}, counted as ${Math.max(small, SMALL_MOST)}.${stale ? ` Ignored ${stale} stale run${stale === 1 ? '' : 's'}.` : ''}`);
- if (others + peak <= CI_CEILING && !mainWaiting) {
+ const fits = others + peak <= CI_CEILING && !mainWaiting;
+ core.setOutput('fits', String(fits));
+ if (fits) {
core.info(`Room under the CI ceiling: about ${others} other jobs + ${peak} <= ${CI_CEILING}.`);
return;
}
+ if (PHASE === 'room') {
+ // Pull requests only: merge-queue entries and `main` runs are never turned away.
+ if (pr != null && look === 1 && waitingPulls >= MAX_WAITING) {
+ core.setOutput('full', 'true');
+ core.warning(`CI is full: ${waitingPulls} pull-request runs are already waiting and there is no room (about ${others} other jobs + ${peak}).`);
+ return;
+ }
+ if (others + 1 <= CI_CEILING && !mainWaiting) {
+ core.info(`Room for the Storybook build: about ${others} other jobs + 1 <= ${CI_CEILING}; the rest of the run waits.`);
+ return;
+ }
+ }
// The time left decides, not the look's own API time: a slow
// look still waits the rest of the way for its next one.
const left = MAX_WAIT_MS - (Date.now() - started);
diff --git a/.github/scripts/ci-admission.test.mjs b/.github/scripts/ci-admission.test.mjs
index eb34ff501f..ac138936a0 100644
--- a/.github/scripts/ci-admission.test.mjs
+++ b/.github/scripts/ci-admission.test.mjs
@@ -46,32 +46,100 @@ describe('where runs wait', () => {
const admission = ci.jobs.admission;
const wait = stepOf(admission);
- it('admits a whole ci.yml run in a first slim job that every other job needs', () => {
- expect(Object.keys(ci.jobs)[0]).toBe('admission');
- 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. The Storybook build starts
- // beside admission, so no job reaches admission only through it.
+ it('waits in two slim jobs: room for the Storybook build, then the rest of the run', () => {
+ const room = ci.jobs.room;
+ expect(Object.keys(ci.jobs).slice(0, 2)).toEqual(['room', 'admission']);
+ for (const job of [room, admission]) {
+ expect(job['runs-on']).toBe('ubuntu-slim');
+ expect(stepOf(job).uses).toBe(
+ './.ci-admission/.github/actions/ci-admission',
+ );
+ }
+ expect(stepOf(room).with.phase).toBe('room');
+ expect(stepOf(room).id).toBe('room');
+ expect(wait.with.phase).toBe('rest');
+ 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.
+ for (const key of ['fits', 'started', 'looks'])
+ expect(wait.with[key]).toBe(`\${{ needs.room.outputs.${key} }}`);
+ for (const key of ['fits', 'full', 'started', 'looks'])
+ expect(room.outputs[key]).toBe(`\${{ steps.room.outputs.${key} }}`);
+ // Every job but the Storybook build reaches admission, directly or through
+ // the jobs it needs, never only through the build.
const BESIDE = 'build-storybook';
- expect(needsOf(ci.jobs[BESIDE])).toEqual([]);
+ expect(needsOf(ci.jobs[BESIDE])).toEqual(['room']);
const reaches = id =>
needsOf(ci.jobs[id]).some(
need => need === 'admission' || (need !== BESIDE && reaches(need)),
);
for (const id of Object.keys(ci.jobs)) {
- if (id !== 'admission' && id !== BESIDE)
+ if (!['room', 'admission', 'ci-full', BESIDE].includes(id))
expect(reaches(id), id).toBe(true);
}
});
+ it('stops a pull-request run that CI is full for, with the reason, and builds nothing', () => {
+ const job = ci.jobs['ci-full'];
+ expect(needsOf(job)).toEqual(['room']);
+ expect(job.if).toBe(
+ "github.event_name == 'pull_request' && needs.room.outputs.full == 'true'",
+ );
+ expect(job.permissions).toEqual({actions: 'write'});
+ const [stop] = job.steps;
+ expect(stop['continue-on-error']).toBeUndefined();
+ expect(stop.run).toContain('CI is full: re-run all jobs or push later.');
+ // It cancels the run when its token can, and fails either way.
+ expect(stop.run).toContain('gh run cancel "$GITHUB_RUN_ID"');
+ expect(stop.run.trim().split('\n').at(-1)).toBe('exit 1');
+ expect(admission.permissions).toEqual({actions: 'read', contents: 'read'});
+ expect(String(ci.jobs['build-storybook'].if)).toContain(
+ "needs.room.outputs.full != 'true'",
+ );
+ });
+
+ it("fails a fork's run that CI is full for, which cannot cancel itself, in every required context", () => {
+ const isStop = step =>
+ step.name === 'Stop when CI is full' &&
+ step.if === "needs.room.outputs.full == 'true'" &&
+ step.run.includes('CI is full: re-run all jobs or push later.') &&
+ step.run.trim().endsWith('exit 1') &&
+ step['continue-on-error'] === undefined;
+ // Admission fails first, so every job behind it without its own status
+ // rule skips.
+ expect(isStop(admission.steps[0])).toBe(true);
+ // The required contexts run, and fail with the reason before any work.
+ for (const id of ['build', 'test', 'docsite-test']) {
+ const job = ci.jobs[id];
+ expect(needsOf(job), id).toContain('room');
+ expect(job.steps[0].name, id).toBe(
+ 'Require a branch in this repository or the ci:run label',
+ );
+ expect(isStop(job.steps[1]), id).toBe(true);
+ }
+ // build runs although the Storybook build it reads skipped.
+ expect(String(ci.jobs.build.if)).toContain(
+ "needs.room.outputs.full == 'true'",
+ );
+ // The jobs that would still run behind a failed admission build nothing.
+ for (const id of ['typecheck', 'pr-interaction', 'pr-interaction-webkit']) {
+ expect(needsOf(ci.jobs[id]), id).toContain('room');
+ expect(String(ci.jobs[id].if), id).toContain(
+ "needs.room.outputs.full != 'true'",
+ );
+ }
+ });
+
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.
+ expect(ci.jobs.room.if).toBe(PR_CI_GATE);
expect(admission.if).toBe(PR_CI_GATE);
- expect(needsOf(admission)).toEqual([]);
- // Whatever the step does, a lookup error or its own time limit, the job
- // succeeds, and it finishes before the job's own limit.
+ expect(needsOf(ci.jobs.room)).toEqual([]);
+ // Whatever a wait does, a lookup error or its own time limit, its job
+ // succeeds, and it finishes before the job's own limit. Only a run CI is
+ // full for stops (above).
+ expect(stepOf(ci.jobs.room)['continue-on-error']).toBe(true);
expect(wait['continue-on-error']).toBe(true);
const limit = (value, event) => {
const split = /&& (\d+) \|\| (\d+)/.exec(String(value));
@@ -79,14 +147,24 @@ describe('where runs wait', () => {
? Number(split[event === 'workflow_dispatch' ? 1 : 2])
: Number(value);
};
- for (const event of ['workflow_dispatch', 'pull_request']) {
- // The wait ends before the step's limit, and the step's before the job's.
- expect(limit(wait.with['max-wait-minutes'], event)).toBeLessThan(
- limit(wait['timeout-minutes'], event),
- );
- expect(limit(wait['timeout-minutes'], event)).toBeLessThan(
- limit(admission['timeout-minutes'], event),
- );
+ for (const job of [ci.jobs.room, admission]) {
+ const step = stepOf(job);
+ expect(step.with).toMatchObject({
+ peak: wait.with.peak,
+ main: wait.with.main,
+ 'max-wait-minutes': wait.with['max-wait-minutes'],
+ 'max-looks': wait.with['max-looks'],
+ 'label-legs': wait.with['label-legs'],
+ });
+ for (const event of ['workflow_dispatch', 'pull_request']) {
+ // The wait ends before the step's limit, and the step's before the job's.
+ expect(limit(step.with['max-wait-minutes'], event)).toBeLessThan(
+ limit(step['timeout-minutes'], event),
+ );
+ expect(limit(step['timeout-minutes'], event)).toBeLessThan(
+ limit(job['timeout-minutes'], event),
+ );
+ }
}
// A pull request's admission stays inside the fifteen-minute job budget.
expect(
@@ -97,6 +175,10 @@ describe('where runs wait', () => {
expect(limit(wait.with['max-looks'], 'pull_request')).toBe(2);
expect(limit(wait.with['max-looks'], 'workflow_dispatch')).toBe(8);
expect(admission.steps.filter(step => step !== wait)).toEqual([
+ expect.objectContaining({name: 'Stop when CI is full'}),
+ expect.objectContaining({uses: 'actions/checkout@v7'}),
+ ]);
+ expect(ci.jobs.room.steps.filter(step => step.name !== STEP)).toEqual([
expect.objectContaining({uses: 'actions/checkout@v7'}),
]);
});
@@ -156,7 +238,7 @@ describe('peaks', () => {
const visit = name => {
for (const need of needsOf(ci.jobs[name])) {
if (
- ['maintenance-request', 'admission'].includes(need) ||
+ ['maintenance-request', 'room', 'admission'].includes(need) ||
closure.has(need)
)
continue;
@@ -200,11 +282,14 @@ describe('peaks', () => {
});
it('gives a pull request a peak that covers every job it starts at once', () => {
- // The jobs that need only admission start together the moment it ends.
+ // The jobs that need only the waits start together the moment admission
+ // ends; the Storybook build may still be running then.
+ const waits = ['room', 'admission'];
const first = Object.keys(ci.jobs).filter(
name =>
- name !== 'admission' &&
- needsOf(ci.jobs[name]).every(need => need === 'admission'),
+ !waits.includes(name) &&
+ name !== 'ci-full' &&
+ needsOf(ci.jobs[name]).every(need => waits.includes(need)),
);
const onPullRequest = first.filter(name => {
const condition = String(ci.jobs[name].if ?? '');
@@ -297,6 +382,7 @@ describe('ci admission', () => {
active = [],
peak = 12,
isMain = false,
+ merge = false,
labels = [],
pull = {},
error,
@@ -305,6 +391,10 @@ describe('ci admission', () => {
budget = 4000,
latencyMs = 0,
random = 0,
+ phase = 'whole',
+ fits = '',
+ started = '',
+ looked = '',
} = {}) {
vi.useFakeTimers({now: NOW});
vi.spyOn(Math, 'random').mockReturnValue(random);
@@ -312,6 +402,7 @@ describe('ci admission', () => {
let looks = 0;
let calls = 0;
const logs = {info: [], warning: []};
+ const outputs = {};
const runs = () => (typeof active === 'function' ? active(looks) : active);
const github = {
rest: {
@@ -346,20 +437,22 @@ describe('ci admission', () => {
const core = {
info: message => logs.info.push(message),
warning: message => logs.warning.push(message),
+ setOutput: (name, value) => (outputs[name] = value),
};
const context = {
repo: {owner: 'o', repo: 'r'},
runId: OWN,
- payload: isMain
- ? {}
- : {
- pull_request: {
- draft: false,
- head: {repo: {full_name: 'o/r'}},
- labels: labels.map(name => ({name})),
- ...pull,
+ payload:
+ isMain || merge
+ ? {}
+ : {
+ pull_request: {
+ draft: false,
+ head: {repo: {full_name: 'o/r'}},
+ labels: labels.map(name => ({name})),
+ ...pull,
+ },
},
- },
};
Object.assign(process.env, {
PEAK: String(peak),
@@ -367,6 +460,10 @@ describe('ci admission', () => {
LABEL_LEGS: '{"ci:run-visual": 6}',
MAX_WAIT_MINUTES: String(maxWait),
MAX_LOOKS: String(maxLooks),
+ PHASE: phase,
+ FITS: fits,
+ STARTED: started,
+ LOOKS: looked,
});
const done = new AsyncFunction('github', 'context', 'core', script)(
github,
@@ -377,7 +474,7 @@ describe('ci admission', () => {
done.catch(() => {});
await vi.advanceTimersByTimeAsync(20 * 60_000);
await done;
- return {...logs, looks, calls, lookTimes};
+ return {...logs, looks, calls, lookTimes, outputs};
}
it("admits at once at today's load: 56 live jobs and many pull-request runs waiting", async () => {
@@ -498,6 +595,189 @@ describe('ci admission', () => {
expect(result.info.at(-2)).toContain('about 62 other jobs + 16 <= 90');
});
+ describe('room for the Storybook build, then the rest of the run', () => {
+ it('lets the build start when it fits alone, and records that the run did not', async () => {
+ // 5 x 12 + 18 + 1 = 79 fits the build; + 16 = 94 does not fit the run.
+ const result = await admit({
+ active: prs(5),
+ peak: 16,
+ phase: 'room',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(result.looks).toBe(1);
+ expect(result.outputs).toMatchObject({fits: 'false', looks: '1'});
+ expect(result.outputs.full).toBeUndefined();
+ expect(result.info.at(-2)).toContain('Room for the Storybook build');
+ });
+
+ it('holds the build too when there is no room even for it', async () => {
+ // 6 x 12 + 18 = 90: not one more job fits, so nothing of the run starts.
+ const result = await admit({
+ active: prs(6),
+ peak: 16,
+ phase: 'room',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(result.looks).toBe(2);
+ expect(result.warning[0]).toContain('Still no room');
+ });
+
+ it('records that the whole run fit, so the rest starts without a look', async () => {
+ const room = await admit({active: prs(2), peak: 16, phase: 'room'});
+ expect(room.outputs.fits).toBe('true');
+ const rest = await admit({
+ active: prs(2),
+ peak: 16,
+ phase: 'rest',
+ fits: 'true',
+ started: String(NOW),
+ looked: '1',
+ });
+ expect(rest).toMatchObject({looks: 0, calls: 0});
+ });
+
+ it('starts the rest at once when room did not measure the run', async () => {
+ // Room started on an API error or a low budget: it set no `fits`.
+ for (const fits of ['']) {
+ const rest = await admit({
+ active: prs(6),
+ peak: 16,
+ phase: 'rest',
+ fits,
+ started: String(NOW),
+ looked: '1',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(rest).toMatchObject({looks: 0, calls: 0});
+ expect(rest.info).toContain('Room did not measure the run; starting.');
+ }
+ // A failed room lookup sets looks but not fits.
+ const room = await admit({
+ active: prs(6),
+ peak: 16,
+ phase: 'room',
+ error: new Error('rate limited'),
+ });
+ expect(room.outputs.fits).toBeUndefined();
+ });
+
+ it('carries the wait on from room: its clock and its looks', async () => {
+ // Room looked at once and found room for the build only; the rest looks
+ // once more at the second look of the same twelve-minute wait.
+ const rest = await admit({
+ active: prs(5),
+ peak: 16,
+ phase: 'rest',
+ fits: 'false',
+ started: String(NOW),
+ looked: '1',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(rest.looks).toBe(1);
+ expect(rest.lookTimes[0]).toBeGreaterThan(11 * 60_000);
+ expect(rest.lookTimes[0]).toBeLessThanOrEqual(12 * 60_000);
+ // Room already spent both looks: the rest starts at once.
+ const spent = await admit({
+ active: prs(6),
+ peak: 16,
+ phase: 'rest',
+ fits: 'false',
+ started: String(NOW),
+ looked: '2',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(spent).toMatchObject({looks: 0, calls: 0});
+ });
+
+ it('sees a run as waiting while either of its waits is in progress', async () => {
+ // Room is done and admission waits: a waiting pull-request run that holds
+ // its waiting job and the build that found room.
+ const twoWaits = {
+ id: 77,
+ status: 'in_progress',
+ event: 'pull_request',
+ path: '.github/workflows/ci.yml',
+ jobs: [
+ {
+ status: 'completed',
+ steps: [{name: STEP, status: 'completed', completed_at: ago(3)}],
+ },
+ {status: 'in_progress', steps: [{name: STEP, status: 'in_progress'}]},
+ {status: 'in_progress', steps: []},
+ ],
+ };
+ const result = await admit({active: [twoWaits], peak: 16});
+ expect(result.info.find(line => line.startsWith('Look 1:'))).toContain(
+ 'ci 77 pull_request: 2 waiting',
+ );
+ });
+ });
+
+ describe('CI is full', () => {
+ const waiting = count =>
+ Array.from({length: count}, (_, i) => waitingRun(300 + i));
+
+ it('turns away a pull-request run that finds no room and ten others waiting', async () => {
+ // 5 x 12 + 10 waiting + 18 + 16 = 104: no room, and ten already wait.
+ const result = await admit({
+ active: [...prs(5), ...waiting(10)],
+ peak: 16,
+ phase: 'room',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(result.looks).toBe(1);
+ expect(result.outputs.full).toBe('true');
+ expect(result.warning[0]).toContain(
+ 'CI is full: 10 pull-request runs are already waiting',
+ );
+ });
+
+ it('never turns away a merge-queue entry', async () => {
+ // A merge-queue run is not `main`, and carries no pull request.
+ const entry = await admit({
+ active: [...prs(5), ...waiting(12)],
+ peak: 16,
+ phase: 'room',
+ merge: true,
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(entry.outputs.full).toBeUndefined();
+ expect(entry.looks).toBe(2);
+ });
+
+ it('lets the tenth waiter wait, and never turns away a run that fits or a main run', async () => {
+ const ninth = await admit({
+ active: [...prs(5), ...waiting(9)],
+ peak: 16,
+ phase: 'room',
+ maxWait: 12,
+ maxLooks: 2,
+ });
+ expect(ninth.outputs.full).toBeUndefined();
+ const fits = await admit({
+ active: [...prs(1), ...waiting(12)],
+ peak: 16,
+ phase: 'room',
+ });
+ expect(fits.outputs).toMatchObject({fits: 'true'});
+ expect(fits.outputs.full).toBeUndefined();
+ const mainRun = await admit({
+ active: [...prs(5), ...waiting(12)],
+ peak: 37,
+ isMain: true,
+ phase: 'room',
+ });
+ expect(mainRun.outputs.full).toBeUndefined();
+ });
+ });
+
it("keeps room for small workflows' measured most", async () => {
expect((await admit({active: [...prs(5), ...slims(18)]})).looks).toBe(1);
expect(
diff --git a/.github/scripts/ci-docsite-browser.test.mjs b/.github/scripts/ci-docsite-browser.test.mjs
index cea8ec4931..3976f35723 100644
--- a/.github/scripts/ci-docsite-browser.test.mjs
+++ b/.github/scripts/ci-docsite-browser.test.mjs
@@ -30,7 +30,8 @@ describe('docsite-test', () => {
expect(jobs['docsite-data']).toBeUndefined();
expect(jobs['docsite-browser']).toBeUndefined();
// Only CI's run admission, which never skips (ci-admission.test.mjs).
- expect(owner.needs).toEqual(['admission']);
+ // room tells it when CI is full (ci-admission.test.mjs).
+ expect(owner.needs).toEqual(['room', 'admission']);
expect(owner['continue-on-error']).toBeUndefined();
// A required context keeps only the draft skip in its condition; an
// outside contributor's run stops at the first step with the reason.
@@ -43,7 +44,9 @@ describe('docsite-test', () => {
expect(owner.steps[0].name).toBe(
'Require a branch in this repository or the ci:run label',
);
- expect(owner.steps.findIndex(s => s.id === 'scope')).toBe(2);
+ // After the FR17 gate and the CI-is-full stop (ci-admission.test.mjs).
+ expect(owner.steps[1].name).toBe('Stop when CI is full');
+ expect(owner.steps.findIndex(s => s.id === 'scope')).toBe(3);
const builds = owner.steps.filter(s =>
/pnpm -F @astryxdesign\/docsite build/.test(s.run ?? ''),
diff --git a/.github/scripts/ci-interaction-webkit.test.mjs b/.github/scripts/ci-interaction-webkit.test.mjs
index e508637992..707e94dc10 100644
--- a/.github/scripts/ci-interaction-webkit.test.mjs
+++ b/.github/scripts/ci-interaction-webkit.test.mjs
@@ -56,10 +56,10 @@ describe('WebKit interaction proof routing', () => {
it('always reports, behind the same pull-request gate as the Chromium proofs', () => {
expect(webkit.if).toBe(chromium.if);
expect(ungated(webkit.if)).toBe(
- "github.event_name != 'workflow_dispatch' && always() && !cancelled()",
+ "github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.room.outputs.full != 'true'",
);
// Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
- expect(webkit.needs).toEqual(['admission', 'build-storybook']);
+ expect(webkit.needs).toEqual(['room', '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 118dcf5b43..cf7a52b76d 100644
--- a/.github/scripts/ci-interaction.test.mjs
+++ b/.github/scripts/ci-interaction.test.mjs
@@ -47,10 +47,10 @@ describe('interaction proof routing', () => {
// Behind the pull-request gate (spec:AST-030 FR17).
expect(proofs.if).toMatch(/^\$\{\{ \(github\.event_name != 'pull_request'/);
expect(ungated(proofs.if)).toBe(
- "github.event_name != 'workflow_dispatch' && always() && !cancelled()",
+ "github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.room.outputs.full != 'true'",
);
// Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
- expect(proofs.needs).toEqual(['admission', 'build-storybook']);
+ expect(proofs.needs).toEqual(['room', '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 467e3e0ec0..e8ebf16018 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -779,7 +779,7 @@ describe('ci.yml interaction proofs', () => {
// 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);
// Admission too: the Storybook build starts beside it (spec:AST-030 FR16).
- expect(job.needs).toEqual(['admission', 'build-storybook']);
+ expect(job.needs).toEqual(['room', 'admission', 'build-storybook']);
const checkout = job.steps.find(
candidate =>
candidate.uses?.startsWith('actions/checkout@') &&
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index c6ea276028..db33e2c47e 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -190,7 +190,9 @@ describe('Node-tooling CI routing', () => {
});
it('preserves the historical joins and fails them on owned-lane failure', () => {
+ // room only tells test when CI is full (ci-admission.test.mjs).
expect(ci.jobs.test.needs).toEqual([
+ 'room',
'release-bump',
'test-ui',
'test-node',
@@ -199,7 +201,11 @@ describe('Node-tooling CI routing', () => {
'pr-interaction',
'pr-interaction-webkit',
]);
- expect(ci.jobs.build.needs).toEqual(['build-storybook', 'typecheck']);
+ expect(ci.jobs.build.needs).toEqual([
+ 'room',
+ 'build-storybook',
+ 'typecheck',
+ ]);
const testJoin = step(ci.jobs.test, 'Require expected test-owner outcomes');
expect(testJoin.run).toBe('node .github/scripts/ci-test-join.mjs');
expect(ci.jobs.test.permissions).toEqual({
diff --git a/.github/scripts/release-check-workflow.test.mjs b/.github/scripts/release-check-workflow.test.mjs
index c6e07fe7f5..1d44463e7e 100644
--- a/.github/scripts/release-check-workflow.test.mjs
+++ b/.github/scripts/release-check-workflow.test.mjs
@@ -24,7 +24,8 @@ const packageJson = JSON.parse(
fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'),
);
const releaseJobs = [
- // Admits every CI run under CI's ceiling (ci-admission.test.mjs).
+ // Admit every CI run under CI's ceiling (ci-admission.test.mjs).
+ 'room',
'admission',
'release-authority',
'test-registry-e2e',
diff --git a/.github/scripts/visual-maintenance-workflow.test.mjs b/.github/scripts/visual-maintenance-workflow.test.mjs
index e919ae1842..cc1831b335 100644
--- a/.github/scripts/visual-maintenance-workflow.test.mjs
+++ b/.github/scripts/visual-maintenance-workflow.test.mjs
@@ -104,7 +104,9 @@ describe('CI baseline maintenance routing', () => {
it('does not run non-maintenance CI jobs for capture', () => {
for (const [name, job] of Object.entries(workflow.jobs)) {
// admission admits every run, a capture's included (ci-admission.test.mjs).
- if (['maintenance-request', 'pr-visual', 'admission'].includes(name))
+ if (
+ ['maintenance-request', 'pr-visual', 'room', 'admission'].includes(name)
+ )
continue;
expect(
runs(job, {operation: 'capture', needs: dependencies(job)}),
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 31d6ad412a..9512e6bece 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -92,17 +92,58 @@ concurrency:
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' || (inputs.recheck && github.triggering_actor == 'github-actions[bot]') }}
jobs:
- # Admits the whole run under CI's ceiling of about ninety concurrent jobs
- # (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
- # release-check's from its legs, a pull request's from its measured most plus
- # the suites its labels opt into (ci-admission.test.mjs). A pull request
- # waits at most twelve minutes, inside the fifteen-minute job budget.
+ # Admit the whole run under CI's ceiling of about ninety concurrent jobs
+ # (spec:AST-030 FR16, DEC-16), in two slim jobs: `room` waits until the
+ # Storybook build has room and starts it, and `admission` waits for the rest
+ # of the run unless it already fit. Every job here but build-storybook and
+ # ci-full needs admission, directly or through the jobs it needs, so a
+ # waiting run holds only its one waiting job and a build that found room.
+ # Like every other job both skip for a draft or an unlabelled fork, which run
+ # no CI (FR17); the required contexts still report through their own status
+ # rules. Neither fails, so each job's own condition decides exactly as before,
+ # except for a pull-request run CI is full for, which ci-full stops. `peak` is
+ # the most jobs a run holds at once: a release-check's from its legs, a pull
+ # request's from its measured most plus the suites its labels opt into
+ # (ci-admission.test.mjs). A pull request waits at most twelve minutes in all,
+ # inside the fifteen-minute job budget.
+ room:
+ # Finds room for the run's first job, its Storybook build, and records
+ # whether the whole run fit on that look. A pull-request run finding ten
+ # others already waiting, and no room, is turned away: CI is full.
+ 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')))
+ runs-on: ubuntu-slim
+ timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 20 || 15 }}
+ permissions:
+ actions: read
+ contents: read
+ outputs:
+ fits: ${{ steps.room.outputs.fits }}
+ full: ${{ steps.room.outputs.full }}
+ started: ${{ steps.room.outputs.started }}
+ looks: ${{ steps.room.outputs.looks }}
+ steps:
+ - name: Check out the admission action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/ci-admission
+ path: .ci-admission
+ persist-credentials: false
+
+ - name: Wait for room under the CI ceiling
+ id: room
+ uses: ./.ci-admission/.github/actions/ci-admission
+ continue-on-error: true
+ timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 16 || 13 }}
+ with:
+ phase: room
+ peak: ${{ github.event_name == 'workflow_dispatch' && 37 || 16 }}
+ main: ${{ github.event_name == 'workflow_dispatch' }}
+ max-wait-minutes: ${{ github.event_name == 'workflow_dispatch' && 15 || 12 }}
+ max-looks: ${{ github.event_name == 'workflow_dispatch' && 8 || 2 }}
+ label-legs: '{"ci:run-visual": 6, "ci:run-rtl": 9, "ci:run-a11y": 3}'
+
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')))
runs-on: ubuntu-slim
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 20 || 15 }}
@@ -110,6 +151,12 @@ jobs:
actions: read
contents: read
steps:
+ - name: Stop when CI is full
+ if: needs.room.outputs.full == 'true'
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. Ten pull-request runs were already waiting for room."
+ exit 1
+
- name: Check out the admission action
uses: actions/checkout@v7
with:
@@ -122,12 +169,38 @@ jobs:
continue-on-error: true
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 16 || 13 }}
with:
+ phase: rest
+ fits: ${{ needs.room.outputs.fits }}
+ started: ${{ needs.room.outputs.started }}
+ looks: ${{ needs.room.outputs.looks }}
peak: ${{ github.event_name == 'workflow_dispatch' && 37 || 16 }}
main: ${{ github.event_name == 'workflow_dispatch' }}
max-wait-minutes: ${{ github.event_name == 'workflow_dispatch' && 15 || 12 }}
max-looks: ${{ github.event_name == 'workflow_dispatch' && 8 || 2 }}
label-legs: '{"ci:run-visual": 6, "ci:run-rtl": 9, "ci:run-a11y": 3}'
+ # Stops a pull-request run that CI is full for (room found no room and ten
+ # other pull-request runs waiting), with the reason, so it builds nothing.
+ # It cancels the run when its token can. A fork's read-only token cannot;
+ # then admission fails, the jobs behind it skip, and build, test and
+ # docsite-test fail with the same reason, never skip or pass.
+ ci-full:
+ needs: [room]
+ if: github.event_name == 'pull_request' && needs.room.outputs.full == 'true'
+ runs-on: ubuntu-slim
+ timeout-minutes: 5
+ permissions:
+ # actions: write lets the run cancel itself.
+ actions: write
+ steps:
+ - name: Stop, CI is full
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. Ten pull-request runs were already waiting for room."
+ gh run cancel "$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY" || true
+ exit 1
+
maintenance-request:
needs: [admission]
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'capture'
@@ -415,7 +488,7 @@ jobs:
# only the production build has the opaque-origin sandbox at all. The
# spec-only lane validates spec records here, where it always has.
docsite-test:
- needs: [admission]
+ needs: [room, admission]
if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && !startsWith(github.base_ref, 'release/v') && !cancelled()) }}
# The Next.js production build uses every core it gets.
runs-on: ubuntu-latest
@@ -432,6 +505,12 @@ jobs:
# This job decides its own scope (no separate scope job): the step
# reads the PR's file list and the base's trusted classifier, and
# everything is in scope when it cannot decide.
+ - name: Stop when CI is full
+ if: needs.room.outputs.full == 'true'
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. Ten pull-request runs were already waiting for room."
+ exit 1
+
- name: Check out the scope action
uses: actions/checkout@v7
with:
@@ -879,6 +958,7 @@ jobs:
test:
needs:
[
+ room,
release-bump,
test-ui,
test-node,
@@ -901,6 +981,12 @@ jobs:
# This job decides its own scope (no separate scope job): the step
# reads the PR's file list and the base's trusted classifier, and
# everything is in scope when it cannot decide.
+ - name: Stop when CI is full
+ if: needs.room.outputs.full == 'true'
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. Ten pull-request runs were already waiting for room."
+ exit 1
+
- name: Check out the scope action
uses: actions/checkout@v7
with:
@@ -980,10 +1066,11 @@ jobs:
await decideRunLabels({github, context, core});
build-storybook:
- # 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()) }}
+ # Starts once there is room for it, beside admission's wait for the rest of
+ # the run; every job that uses its build also needs admission, so the heavy
+ # legs still wait for room (spec:AST-030 FR16, DEC-16).
+ 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'))) && ((github.event_name != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled() && needs.room.outputs.full != 'true') }}
# Every browser lane waits for this job, and the package builds and the
# Storybook build run side by side (build-packages-and-storybook.mjs).
runs-on: ${{ (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && github.triggering_actor != 'github-actions[bot]') && '4-core-ubuntu' || 'ubuntu-latest' }}
@@ -1395,8 +1482,8 @@ jobs:
# ~1.5 minutes sooner. The build and release-check joins require this job,
# so a type error still fails both.
typecheck:
- needs: [admission]
- 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()) }}
+ needs: [room, admission]
+ 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() && needs.room.outputs.full != 'true') }}
runs-on: ${{ (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && github.triggering_actor != 'github-actions[bot]') && '2-core-ubuntu-arm' || 'ubuntu-24.04-arm' }}
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }}
permissions:
@@ -1463,8 +1550,8 @@ jobs:
# gate passes. A skipped build-storybook job (a draft) skips this gate too;
# a fork pull request without `ci:run` still reports here.
build:
- needs: [build-storybook, typecheck]
- if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && !cancelled() && (needs.build-storybook.result != 'skipped' || github.event_name == 'pull_request' && !(github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')))) }}
+ needs: [room, build-storybook, typecheck]
+ if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && !cancelled() && (needs.build-storybook.result != 'skipped' || needs.room.outputs.full == 'true' || github.event_name == 'pull_request' && !(github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')))) }}
runs-on: ubuntu-slim
permissions: {}
steps:
@@ -1473,6 +1560,12 @@ jobs:
run: |
echo "::error::Waiting for a maintainer's ci:run label: an outside contributor's pull request runs CI once a maintainer adds it (spec:AST-030 FR17)."
exit 1
+ - name: Stop when CI is full
+ if: needs.room.outputs.full == 'true'
+ run: |
+ echo "::error title=CI is full::CI is full: re-run all jobs or push later. Ten pull-request runs were already waiting for room."
+ exit 1
+
- name: Assert parallel builds succeeded
run: |
echo "build-storybook: ${{ needs.build-storybook.result }}"
@@ -1955,8 +2048,8 @@ jobs:
delete-merged: true
pr-interaction:
- 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()) }}
+ needs: [room, 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() && needs.room.outputs.full != 'true') }}
# Frame evidence measures timing: four cores, one Playwright worker.
runs-on: ubuntu-latest
timeout-minutes: 15
@@ -2073,8 +2166,8 @@ jobs:
# required context. Specs that need Chromium-only evidence skip themselves
# in WebKit.
pr-interaction-webkit:
- 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()) }}
+ needs: [room, 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() && needs.room.outputs.full != 'true') }}
# Frame evidence measures timing: four cores, one Playwright worker.
runs-on: ubuntu-latest
timeout-minutes: 15
diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.md
index 462bad99f8..c383c92101 100644
--- a/docs/specs/AST-030/spec.md
+++ b/docs/specs/AST-030/spec.md
@@ -340,14 +340,17 @@ 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, 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.
+ start, except the CI workflow's Storybook build, which starts as soon as there
+ is room for it while every job that uses it waits for room for the run: 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). At most ten pull-request runs wait at once: one
+ more that finds no room stops at once 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 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,
@@ -740,21 +743,23 @@ 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 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
+counts the jobs it runs, the job that waits and a Storybook build that found
+room, 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.
+waits, pull-request runs wait too, their Storybook builds included. Every job
+ends within its fifteen-minute budget, so `main` fits within fifteen minutes.
+Nothing is reserved for `main` outside those minutes. At most ten pull-request
+runs wait at once; one more that finds no room stops at once, "CI is full:
+re-run all jobs or push later", rather than add a waiting job to a full CI. A
+`main` run is never stopped.
-CI can still pass ninety in three rare, bounded ways:
+CI can still pass ninety in four bounded ways, the first three rare:
- A run that has waited its longest (fifteen minutes for `main`, twelve for a
pull request) starts whatever the load, even while a `main` check waits. That
@@ -765,6 +770,11 @@ CI can still pass ninety in three rare, bounded ways:
jobs until its next look.
- A run starts when the GitHub API cannot be read, a rate limit included. It is
over by at most its own jobs.
+- A waiting run's own waiting job starts before it finds room; its Storybook
+ build starts only once there is room for it. CI is over by at most one slim
+ job per waiting run: at most ten for pull requests, plus one for each waiting
+ merge-queue entry and `main` run, which are never turned away, for at most a
+ wait (twelve minutes for a pull request, fifteen for `main`).
Rejected: a fixed reserve for `main` (it left about half the ceiling idle and
stalled the pull-request queue); starting `main`'s checks at once (a burst would