An open source design system that's fully customizable and agent ready
TypeScript
ci: main's full unit run is about hourly and always finishes; a release needs one at its cut (AST-030 FR21) (#9213)
Cindy Zhanga5049dfd07c7
diff --git a/.github/actions/ci-admission/action.yml b/.github/actions/ci-admission/action.ymlindex 1cb6339cd1..86e2a9b394 100644--- a/.github/actions/ci-admission/action.yml+++ b/.github/actions/ci-admission/action.yml@@ -156,12 +156,13 @@ runs: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`+ // release-check and Main's runs (a push's fast checks or a unit run)+ // from their `peak`// (ci-admission.test.mjs), a pull-request ci.yml run from its// measured most, every other workflow's run one or two slim jobs.const ESTIMATE = {'.github/workflows/ci.yml': run => (run.event === 'workflow_dispatch' ? 37 : 16),- '.github/workflows/deploy.yml': () => 14,+ '.github/workflows/deploy.yml': run => (run.event === 'push' ? 4 : 14),'.github/workflows/review-signal.yml': () => 2,};const estimate = run => (ESTIMATE[run.path] ?? (() => 1))(run);diff --git a/.github/scripts/ci-admission.test.mjs b/.github/scripts/ci-admission.test.mjsindex 2ae4c468ab..68cf212536 100644--- a/.github/scripts/ci-admission.test.mjs+++ b/.github/scripts/ci-admission.test.mjs@@ -271,14 +271,31 @@ describe('peaks', () => {expect(estimateOf('ci.yml')).toContain(`'workflow_dispatch' ? ${peak} :`);});- it("gives Main's unit run a peak that covers all its jobs beside main-commit", () => {- const held = Object.keys(main.jobs)- .filter(name => name !== 'main-commit' && name !== 'test')- .map(name => legs(main.jobs[name]))- .reduce((sum, count) => sum + count, 0);- const peak = stepOf(main.jobs['main-commit']).with.peak;- expect(peak).toBeGreaterThanOrEqual(held);- expect(estimateOf('deploy.yml')).toContain(`() => ${peak},`);+ it("gives Main's unit run a peak that covers all its jobs, and a push one for its fast checks", () => {+ const [, push, unit] = /&& (\d+) \|\| (\d+)/+ .exec(stepOf(main.jobs['main-commit']).with.peak)+ .map(Number);+ const held = names =>+ names+ .map(name => legs(main.jobs[name]))+ .reduce((sum, count) => sum + count, 0);+ // A dispatched unit run holds every job beside main-commit and the join.+ expect(unit).toBeGreaterThanOrEqual(+ held(+ Object.keys(main.jobs).filter(+ name => name !== 'main-commit' && name !== 'test',+ ),+ ),+ );+ // A push skips the unit legs (spec:AST-030 FR21).+ const fast = Object.keys(main.jobs).filter(+ name => main.jobs[name].if !== "github.event_name != 'push'",+ );+ expect(push).toBeGreaterThanOrEqual(fast.length);+ expect(push).toBeLessThan(unit);+ expect(estimateOf('deploy.yml')).toContain(+ `run => (run.event === 'push' ? ${push} : ${unit}),`,+ );});it('gives a pull request a peak that covers every job it starts at once', () => {diff --git a/.github/scripts/ci-heavy-lanes.test.mjs b/.github/scripts/ci-heavy-lanes.test.mjsindex 430545f93d..c882dde53a 100644--- a/.github/scripts/ci-heavy-lanes.test.mjs+++ b/.github/scripts/ci-heavy-lanes.test.mjs@@ -143,7 +143,7 @@ describe('visual, accessibility and RTL owners', () => {});});-describe("main's release-check, about once an hour (DEC-11)", () => {+describe("main's release-check and full unit run, about once an hour (DEC-11, FR21)", () => {const job = heavy.jobs.dispatch;const script = job.steps[0].with.script;@@ -152,7 +152,11 @@ describe("main's release-check, about once an hour (DEC-11)", () => {push: {branches: ['main']},schedule: [{cron: '7,22,37,52 * * * *'}],});- expect(job.permissions).toEqual({actions: 'write', contents: 'read'});+ expect(job.permissions).toEqual({+ actions: 'write',+ contents: 'read',+ issues: 'write',+ });expect(job.steps[0].env.SHA).toBe('${{ github.sha }}');});@@ -180,21 +184,46 @@ describe("main's release-check, about once an hour (DEC-11)", () => {const sha = 'a'.repeat(40);const NOW = Date.parse('2026-10-31T12:00:00Z');const minutesAgo = minutes => new Date(NOW - minutes * 60000).toISOString();+ // A unit run that names main's tip, as the scheduler dispatches it (FR21).+ const unitAt = (minutes, overrides = {}) =>+ check(minutes, {+ head_sha: sha,+ display_title: `Main validation of ${sha}`,+ ...overrides,+ });const check = (minutes, overrides = {}) => ({head_sha: 'c'.repeat(40),created_at: minutesAgo(minutes),conclusion: 'success',actor: {login: 'github-actions[bot]'},status: 'completed',+ html_url: `https://github.com/meta/astryx/actions/runs/${minutes}`,...overrides,});/**- * Runs the step's script against a fake GitHub API with main at `tip` and- * `runs` as ci.yml's dispatched runs on main, newest first.+ * Runs the step's script against a fake GitHub API with main at `tip`,+ * `runs` as ci.yml's dispatched runs on main and `units` as deploy.yml's,+ * newest first. `issue` is an open guardian issue, if any, or+ * 'unavailable' when the issue search fails. `into` receives the calls even+ * when the script throws.*/- async function run({tip = sha, runs = [], eventName = 'push'} = {}) {- const calls = {dispatch: [], notices: [], listed: []};+ async function run({+ tip = sha,+ runs = [],+ units = [],+ issue,+ eventName = 'push',+ into = {},+ } = {}) {+ const calls = Object.assign(into, {+ dispatch: [],+ notices: [],+ warnings: [],+ listed: [],+ issues: [],+ comments: [],+ });const github = {rest: {repos: {@@ -213,10 +242,24 @@ describe("main's release-check, about once an hour (DEC-11)", () => {}),listWorkflowRuns: async args => {calls.listed.push(args);- return {data: {workflow_runs: runs}};+ return {+ data: {+ workflow_runs: args.workflow_id === 'deploy.yml' ? units : runs,+ },+ };},createWorkflowDispatch: async args => calls.dispatch.push(args),},+ search: {+ issuesAndPullRequests: async () => {+ if (issue === 'unavailable') throw new Error('search failed');+ return {data: {items: issue ? [issue] : []}};+ },+ },+ issues: {+ create: async args => calls.issues.push(args),+ createComment: async args => calls.comments.push(args),+ },},};const body = new Function(@@ -231,62 +274,87 @@ describe("main's release-check, about once an hour (DEC-11)", () => {await body(github,{repo: {owner: 'meta', repo: 'astryx'}, eventName},- {notice: m => calls.notices.push(m)},+ {+ notice: m => calls.notices.push(m),+ warning: m => calls.warnings.push(m),+ },{env: {SHA: sha}},FakeDate,);return calls;}- const dispatched = tip => [- {- owner: 'meta',- repo: 'astryx',- workflow_id: 'ci.yml',- ref: 'main',- inputs: {- operation: 'release-check',- 'release-branch': 'main',- 'expected-head': tip,- },+ const releaseCheck = tip => ({+ owner: 'meta',+ repo: 'astryx',+ workflow_id: 'ci.yml',+ ref: 'main',+ inputs: {+ operation: 'release-check',+ 'release-branch': 'main',+ 'expected-head': tip,},- ];+ });+ // A unit run names the commit it tests (FR21, FR22).+ const unitRunOf = tip => ({+ owner: 'meta',+ repo: 'astryx',+ workflow_id: 'deploy.yml',+ ref: 'main',+ inputs: {sha: tip},+ });+ const unitRun = unitRunOf(sha);- it("dispatches release-check for main's tip when no check started in the last 55 minutes", async () => {- const calls = await run({runs: [check(56), check(200)]});- expect(calls.dispatch).toEqual(dispatched(sha));- expect(calls.listed).toEqual([- {- owner: 'meta',- repo: 'astryx',- workflow_id: 'ci.yml',- event: 'workflow_dispatch',- branch: 'main',- per_page: 30,- },+ it("dispatches a release-check and a full unit run for main's tip when neither started in the last 55 minutes", async () => {+ const calls = await run({+ runs: [check(56), check(200)],+ units: [check(56)],+ });+ expect(calls.dispatch).toEqual([releaseCheck(sha), unitRun]);+ expect(calls.listed.map(args => args.workflow_id)).toEqual([+ 'ci.yml',+ 'deploy.yml',]);+ expect(calls.listed[0]).toEqual({+ owner: 'meta',+ repo: 'astryx',+ workflow_id: 'ci.yml',+ event: 'workflow_dispatch',+ branch: 'main',+ per_page: 30,+ });});- it('dispatches for the first check there is', async () => {- expect((await run()).dispatch).toEqual(dispatched(sha));+ it('dispatches both for the first checks there are', async () => {+ expect((await run()).dispatch).toEqual([releaseCheck(sha), unitRun]);});- it('leaves a push within 55 minutes of the last check to the next one', async () => {- const calls = await run({runs: [check(20)]});+ it('leaves a push within 55 minutes of the last checks to the next one', async () => {+ const calls = await run({runs: [check(20)], units: [check(20)]});expect(calls.dispatch).toEqual([]);expect(calls.notices).toEqual(['A release-check started 20 minutes ago; the next one, at most 50 minutes from now, covers aaaaaaa.',+ 'A full unit run started 20 minutes ago; the next one, at most 50 minutes from now, covers aaaaaaa.',]);});+ it('always brings a unit run of the commit a release-check checks', async () => {+ // The unit lane is inside its window, but the tip has no unit run.+ const calls = await run({runs: [check(60)], units: [check(30)]});+ expect(calls.dispatch).toEqual([releaseCheck(sha), unitRun]);+ // A unit run already at the tip is enough.+ const covered = await run({+ runs: [check(60)],+ units: [unitAt(30)],+ });+ expect(covered.dispatch).toEqual([releaseCheck(sha)]);+ });+it('counts a waiting or running check, but not one replaced while waiting or started by a person', async () => {- expect(- (- await run({- runs: [check(10, {status: 'in_progress', conclusion: null})],- })- ).dispatch,- ).toEqual([]);+ const running = check(10, {status: 'in_progress', conclusion: null});+ expect((await run({runs: [running], units: [running]})).dispatch).toEqual(+ [],+ );expect((await run({@@ -294,14 +362,76 @@ describe("main's release-check, about once an hour (DEC-11)", () => {check(5, {conclusion: 'cancelled'}),check(10, {actor: {login: 'someone'}}),],+ units: [check(10)],})).dispatch,- ).toEqual(dispatched(sha));+ ).toEqual([releaseCheck(sha), unitRun]);+ });++ it("brings a unit run for a person's own release-check of the tip, such as the release owner's", async () => {+ const own = jobs =>+ check(10, {id: 77, head_sha: sha, actor: {login: 'someone'}, jobs});+ const releaseCheck = own([+ {name: 'release-authority', conclusion: 'success'},+ ]);+ const calls = await run({+ runs: [releaseCheck, check(40)],+ units: [check(30)],+ });+ // The scheduler's own release-check is inside its window.+ expect(calls.dispatch).toEqual([unitRun]);+ // A run that names the tip, whoever started it, is enough.+ const covered = await run({+ runs: [releaseCheck, check(40)],+ units: [+ check(5, {+ head_sha: sha,+ actor: {login: 'someone'},+ display_title: `Main validation of ${sha}`,+ }),+ check(30),+ ],+ });+ expect(covered.dispatch).toEqual([]);+ // An unnamed run at the tip tests whatever was the tip when it started,+ // so it is no receipt, and the named run still goes out (FR21).+ const unnamed = await run({+ runs: [releaseCheck, check(40)],+ units: [check(5, {head_sha: sha, actor: {login: 'someone'}}), check(30)],+ });+ expect(unnamed.dispatch).toEqual([unitRun]);+ // A maintenance capture runs no release-authority job and brings none.+ const capture = await run({+ runs: [+ own([+ {name: 'release-authority', conclusion: 'skipped'},+ {name: 'maintenance-request', conclusion: 'success'},+ ]),+ check(40),+ ],+ units: [check(30)],+ });+ expect(capture.dispatch).toEqual([]);+ });++ it('reads the commit a unit run names exactly as the release receipt does', () => {+ const NAME = '/^Main validation of ([0-9a-f]{40})$/';+ expect(JSON.stringify(heavy)).toContain(JSON.stringify(NAME).slice(1, -1));+ expect(+ fs.readFileSync(+ new URL(+ '../../scripts/release/release-check-receipt.mjs',+ import.meta.url,+ ),+ 'utf8',+ ),+ ).toContain(NAME);});it('keeps counting a check a person re-runs', async () => {const calls = await run({runs: [check(90, {head_sha: sha, triggering_actor: {login: 'someone'}})],+ units: [unitAt(90)],});expect(calls.dispatch).toEqual([]);});@@ -319,6 +449,7 @@ describe("main's release-check, about once an hour (DEC-11)", () => {],}),],+ units: [unitAt(70, {conclusion: 'failure'})],});expect(calls.dispatch).toEqual([]);});@@ -333,11 +464,13 @@ describe("main's release-check, about once an hour (DEC-11)", () => {conclusion: 'failure',jobs: [{name: 'release-authority', conclusion: 'failure'}],});- expect((await run({runs: [mismatched(70)]})).dispatch).toEqual(- dispatched(sha),- );+ expect(+ (await run({runs: [mismatched(70)], units: [unitAt(70)]})).dispatch,+ ).toEqual([releaseCheck(sha)]);// ...but it still holds the window.- expect((await run({runs: [mismatched(20)]})).dispatch).toEqual([]);+ expect(+ (await run({runs: [mismatched(20)], units: [unitAt(20)]})).dispatch,+ ).toEqual([]);});it('leaves every run name as it was', () => {@@ -345,15 +478,23 @@ describe("main's release-check, about once an hour (DEC-11)", () => {});it('does not check a tip twice', async () => {- const calls = await run({runs: [check(90, {head_sha: sha})]});+ const calls = await run({+ runs: [check(90, {head_sha: sha})],+ units: [unitAt(90)],+ });expect(calls.dispatch).toEqual([]);expect(calls.notices[0]).toMatch(/already has a release-check/);});it("picks up the tip a burst left unchecked on the schedule's tick", async () => {const tip = 'b'.repeat(40);- const calls = await run({tip, eventName: 'schedule', runs: [check(60)]});- expect(calls.dispatch).toEqual(dispatched(tip));+ const calls = await run({+ tip,+ eventName: 'schedule',+ runs: [check(60)],+ units: [check(60)],+ });+ expect(calls.dispatch).toEqual([releaseCheck(tip), unitRunOf(tip)]);});it('leaves a commit main has moved past to the newer push', async () => {@@ -361,4 +502,153 @@ describe("main's release-check, about once an hour (DEC-11)", () => {expect(calls.dispatch).toEqual([]);expect(calls.notices[0]).toMatch(/newer push/);});++ describe('a full unit run that did not complete (FR21)', () => {+ const title = 'Main unit tests: an hourly run did not complete';++ it.each(['cancelled', 'skipped', 'timed_out', 'startup_failure'])(+ 'runs the next one at once after a %s run and opens the guardian issue',+ async conclusion => {+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [check(20, {conclusion})],+ });+ // Inside the window, but dispatched at once.+ expect(calls.dispatch).toEqual([unitRun]);+ expect(calls.issues).toEqual([+ expect.objectContaining({owner: 'meta', repo: 'astryx', title}),+ ]);+ expect(calls.issues[0].body).toContain(`ended ${conclusion}`);+ expect(calls.issues[0].body).toContain('spec:AST-030 FR21');+ },+ );++ it('comments on the open guardian issue instead of opening another', async () => {+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [check(20, {conclusion: 'cancelled'})],+ issue: {number: 42, title},+ });+ expect(calls.issues).toEqual([]);+ expect(calls.comments).toEqual([+ expect.objectContaining({issue_number: 42}),+ ]);+ });++ it.each(['skipped', 'timed_out', 'startup_failure'])(+ "runs the tip again and reports it when the scheduler's own run of the tip ended %s",+ async conclusion => {+ // No merge landed: the run names the tip itself.+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [unitAt(20, {conclusion})],+ });+ expect(calls.dispatch).toEqual([unitRun]);+ expect(calls.issues).toEqual([+ expect.objectContaining({owner: 'meta', repo: 'astryx', title}),+ ]);+ },+ );++ it('counts a failed run of the tip as its unit run, without a report', async () => {+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [unitAt(20, {conclusion: 'failure'})],+ });+ expect(calls.dispatch).toEqual([]);+ expect(calls.issues).toEqual([]);+ });++ it('dispatches the next run before reporting, so a failed report loses no run', async () => {+ const calls = {};+ const error = await run({+ runs: [check(20, {head_sha: sha})],+ units: [check(20, {conclusion: 'cancelled'})],+ issue: 'unavailable',+ into: calls,+ }).catch(caught => caught);+ expect(error.message).toBe('search failed');+ expect(calls.dispatch).toEqual([unitRun]);+ });++ it('leaves a run a newer one replaced, such as a recheck', async () => {+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [+ check(5, {status: 'in_progress', conclusion: null}),+ check(20, {conclusion: 'cancelled'}),+ ],+ });+ expect(calls.dispatch).toEqual([]);+ expect(calls.issues).toEqual([]);+ });++ it("leaves a run that a person's newer run of main's tip replaced", async () => {+ // Reported as nothing: a newer run took the group. An unnamed run is no+ // receipt, so the named run of the tip still goes out (FR21).+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [+ check(5, {head_sha: sha, actor: {login: 'someone'}}),+ check(20, {conclusion: 'cancelled'}),+ ],+ });+ expect(calls.issues).toEqual([]);+ expect(calls.dispatch).toEqual([unitRun]);+ // A person's run that names the tip is the receipt itself.+ const named = await run({+ runs: [check(20, {head_sha: sha})],+ units: [+ unitAt(5, {actor: {login: 'someone'}}),+ check(20, {conclusion: 'cancelled'}),+ ],+ });+ expect(named.issues).toEqual([]);+ expect(named.dispatch).toEqual([]);+ });++ it('still runs the next one when the newer run only validated an older commit', async () => {+ const older = 'd'.repeat(40);+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [+ check(5, {+ head_sha: sha,+ actor: {login: 'someone'},+ display_title: `Main validation of ${older}`,+ }),+ check(20, {conclusion: 'cancelled'}),+ ],+ });+ expect(calls.dispatch).toEqual([unitRun]);+ });++ it("takes the scheduler's own run that raced a merge as the newest", async () => {+ // main moved between the tip read and the dispatch: the newer run names+ // the older tip under a later event commit, in the same group.+ const older = 'd'.repeat(40);+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [+ check(5, {+ head_sha: sha,+ display_title: `Main validation of ${older}`,+ status: 'in_progress',+ conclusion: null,+ }),+ check(20, {conclusion: 'cancelled'}),+ ],+ });+ expect(calls.issues).toEqual([]);+ });++ it('does not count a failed run as incomplete', async () => {+ const calls = await run({+ runs: [check(20, {head_sha: sha})],+ units: [check(20, {conclusion: 'failure'})],+ });+ expect(calls.dispatch).toEqual([]);+ expect(calls.issues).toEqual([]);+ });+ });});diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjsindex e8ebf16018..0eb8d3e1c7 100644--- a/.github/scripts/ci-test-routing.test.mjs+++ b/.github/scripts/ci-test-routing.test.mjs@@ -297,11 +297,16 @@ describe.each(Object.entries(WORKFLOWS))();}} else {- const commands = runLines(join);+ // deploy.yml passes each result through the step's environment;+ // main-unit-run.test.mjs runs its pass and fail cases.+ const step = join.steps.find(+ candidate => candidate.name === 'Assert every push gate succeeded',+ );for (const lane of lanes) {- expect(commands, `join does not assert ${lane}`).toContain(- `needs.${lane}.result }}" = "success"`,- );+ expect(+ Object.values(step.env),+ `join does not assert ${lane}`,+ ).toContain(`\${{ needs.${lane}.result }}`);}}});@@ -708,9 +713,11 @@ describe('deploy.yml push gating', () => {]);const join = workflow.jobs.test.steps.find(step => step.name === 'Assert every push gate succeeded',- ).run;+ );for (const owner of ['test-ui', 'test-node', 'typecheck']) {- expect(join).toContain(`needs.${owner}.result`);+ expect(Object.values(join.env)).toContain(+ `\${{ needs.${owner}.result }}`,+ );}});diff --git a/.github/scripts/main-unit-run.test.mjs b/.github/scripts/main-unit-run.test.mjsnew file mode 100644index 0000000000..768ebf3eac--- /dev/null+++ b/.github/scripts/main-unit-run.test.mjs@@ -0,0 +1,149 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Main's full unit run is about hourly and always finishes+ * (spec:AST-030 FR21, DEC-15).+ *+ * @input deploy.yml (the Main workflow), parsed, and its join run in bash+ * @output proofs that a push runs only the fast checks, that a dispatched run+ * runs every unit leg unscoped on its exact commit in a group no push+ * cancels, and that the join reports that run's one pass or fail+ * @position Node contract for deploy.yml's unit lanes and join+ */++import {spawnSync} from 'node:child_process';+import fs from 'node:fs';+import path from 'node:path';++import {describe, expect, it} from 'vitest';+import yaml from 'yaml';++const main = yaml.parse(+ fs.readFileSync(+ path.resolve(import.meta.dirname, '../workflows/deploy.yml'),+ 'utf8',+ ),+);++describe("main's full unit run (spec:AST-030 FR21)", () => {+ it('runs the unit lanes only in a dispatched run, never on a push', () => {+ for (const lane of ['test-ui', 'test-node']) {+ expect(main.jobs[lane].if, lane).toBe("github.event_name != 'push'");+ // Every leg, unscoped: no --changed and no file list.+ const run = main.jobs[lane].steps.map(step => step.run ?? '').join('\n');+ expect(run, lane).not.toContain('--changed');+ expect(run, lane).toMatch(/--shard=\$\{\{ matrix\.shard \}\}/);+ }+ });++ it('keeps the fast checks on every push', () => {+ for (const job of ['main-commit', 'sync-exports', 'typecheck'])+ expect(main.jobs[job].if, job).toBeUndefined();+ expect(main.on.push).toEqual({branches: ['main']});+ expect(main.on.workflow_dispatch.inputs.sha).toBeDefined();+ });++ it('tests the exact commit a dispatch names, or the pushed one', () => {+ const script = main.jobs['main-commit'].steps[0].with.script;+ expect(script).toContain('let sha = context.sha;');+ expect(script).toContain("context.payload.inputs?.sha ?? ''");+ expect(script).toContain('sha = requested;');+ });++ it('gives the unit runs a group no push cancels', () => {+ expect(main.concurrency.group).toBe(+ "${{ github.event_name == 'push' && 'main-validation' || (inputs.sha != '' && github.triggering_actor != 'github-actions[bot]' && format('main-validation-sha-{0}', github.run_id)) || 'main-unit-tests' }}",+ );+ });++ describe('the join reports one pass or fail', () => {+ const step = main.jobs.test.steps.find(+ candidate => candidate.name === 'Assert every push gate succeeded',+ );+ const run = env =>+ spawnSync('bash', ['-eo', 'pipefail', '-c', step.run], {+ encoding: 'utf8',+ env: {...process.env, ...env},+ }).status;++ it('needs every lane and always runs', () => {+ expect(main.jobs.test.needs).toEqual([+ 'test-ui',+ 'test-node',+ 'typecheck',+ ]);+ expect(main.jobs.test.if).toBe('${{ always() && !cancelled() }}');+ expect(step.env).toEqual({+ EVENT: '${{ github.event_name }}',+ TEST_UI: '${{ needs.test-ui.result }}',+ TEST_NODE: '${{ needs.test-node.result }}',+ TYPECHECK: '${{ needs.typecheck.result }}',+ });+ });++ it.each([+ [+ 'a push with the unit lanes skipped',+ {+ EVENT: 'push',+ TEST_UI: 'skipped',+ TEST_NODE: 'skipped',+ TYPECHECK: 'success',+ },+ 0,+ ],+ [+ 'a push whose typecheck failed',+ {+ EVENT: 'push',+ TEST_UI: 'skipped',+ TEST_NODE: 'skipped',+ TYPECHECK: 'failure',+ },+ 1,+ ],+ [+ 'a push that somehow ran a unit lane',+ {+ EVENT: 'push',+ TEST_UI: 'success',+ TEST_NODE: 'skipped',+ TYPECHECK: 'success',+ },+ 1,+ ],+ [+ 'a unit run where every lane passed',+ {+ EVENT: 'workflow_dispatch',+ TEST_UI: 'success',+ TEST_NODE: 'success',+ TYPECHECK: 'success',+ },+ 0,+ ],+ [+ 'a unit run with a failed leg',+ {+ EVENT: 'workflow_dispatch',+ TEST_UI: 'success',+ TEST_NODE: 'failure',+ TYPECHECK: 'success',+ },+ 1,+ ],+ [+ 'a unit run with a skipped lane',+ {+ EVENT: 'workflow_dispatch',+ TEST_UI: 'skipped',+ TEST_NODE: 'success',+ TYPECHECK: 'success',+ },+ 1,+ ],+ ])('%s', (_, env, status) => {+ expect(run(env)).toBe(status);+ });+ });+});diff --git a/.github/scripts/main-validation-workflow.test.mjs b/.github/scripts/main-validation-workflow.test.mjsindex 8edc4c3ece..39f5241aca 100644--- a/.github/scripts/main-validation-workflow.test.mjs+++ b/.github/scripts/main-validation-workflow.test.mjs@@ -70,26 +70,39 @@ describe('main validation dispatch', () => {};}- it('keeps one validation of main at a time, and lets only a workflow-token re-check cancel it', () => {- for (const event of ['push', 'workflow_dispatch'])- expect(concurrencyFor({event})).toEqual({- group: 'main-validation',- cancel: false,- });- expect(concurrencyFor({recheck: true})).toEqual({+ it('keeps one full unit run of main at a time, apart from the fast checks of pushes, and lets only a workflow-token re-check cancel it', () => {+ // A push's fast checks queue among themselves (spec:AST-030 FR21).+ expect(concurrencyFor({event: 'push'})).toEqual({group: 'main-validation',- cancel: true,+ cancel: false,});+ // The scheduler's unit run, which names main's tip, and a person's run of+ // the tip queue in the unit-run group, which no push cancels.+ for (const options of [{sha: OLDER}, {}, {actor: 'someone'}])+ expect(concurrencyFor(options)).toEqual({+ group: 'main-unit-tests',+ cancel: false,+ });+ // A release re-check names main's tip and takes the unit-run group.+ for (const options of [{recheck: true}, {recheck: true, sha: OLDER}])+ expect(concurrencyFor(options)).toEqual({+ group: 'main-unit-tests',+ cancel: true,+ });// A person's re-check waits like any other validation.expect(concurrencyFor({recheck: true, actor: 'someone'})).toEqual({- group: 'main-validation',+ group: 'main-unit-tests',cancel: false,});});- it('runs a dispatch that names a commit in a group of its own, which cancels and replaces nothing', () => {+ it("runs a person's dispatch that names a commit in a group of its own, which cancels and replaces nothing", () => {for (const recheck of [false, true]) {- const {group, cancel} = concurrencyFor({sha: OLDER, recheck});+ const {group, cancel} = concurrencyFor({+ sha: OLDER,+ recheck,+ actor: 'someone',+ });expect(group).toBe('main-validation-sha-77');expect(cancel).toBe(false);}diff --git a/.github/scripts/release-check-shape.test.mjs b/.github/scripts/release-check-shape.test.mjsindex 22306d2c9e..17ccb09d71 100644--- a/.github/scripts/release-check-shape.test.mjs+++ b/.github/scripts/release-check-shape.test.mjs@@ -244,8 +244,9 @@ describe('release re-check trigger', () => {repo: 'r',workflow_id: 'deploy.yml',ref: 'main',- // Without `sha`: only a tip re-check takes the validation group.- inputs: {recheck: 'true'},+ // Naming the tip, so the run is that commit's unit-run receipt+ // (spec:AST-030 FR21).+ inputs: {sha: TIP, recheck: 'true'},},]);});diff --git a/.github/scripts/release-publish-workflow.test.mjs b/.github/scripts/release-publish-workflow.test.mjsindex c85017d983..688df918f7 100644--- a/.github/scripts/release-publish-workflow.test.mjs+++ b/.github/scripts/release-publish-workflow.test.mjs@@ -497,6 +497,8 @@ describe('stable publish requires the cut commit release-check (spec:AST-030 FR1expect(script).toContain('scripts/release/release-check-receipt.mjs');expect(script).toContain('.release/active.json');expect(script).toContain('requireReleaseCheck(');+ // The cut commit also needs a passing full unit run (FR21).+ expect(script).toContain('requireUnitRun(');expect(stable.steps[guard]['continue-on-error']).toBeUndefined();expect(stable.permissions.actions).toBe('read');});diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.ymlindex 6957081c44..d7c2b2045e 100644--- a/.github/workflows/deploy.yml+++ b/.github/workflows/deploy.yml@@ -23,16 +23,18 @@ on:permissions: {}-# One validation of main at a time; a newer one waits and replaces any older-# waiting one. A dispatch that names `sha` validates an older commit in a group-# of its own, so it never replaces or cancels main's validations. Only a release-# re-check, which the release re-check workflow sends with the workflow token-# and without `sha`, cancels the running validation: it is itself a full-# validation of main's tip, so the cancelled run's commits stay covered-# (spec:AST-030 FR22).+# Push runs (the fast checks) share one group, and a newer push replaces an+# older waiting one. Full unit runs have a group of their own that no push+# cancels: the scheduler's (main-heavy-lanes.yml, which names the commit) and a+# person's run of main's tip queue there, one at a time (spec:AST-030 FR21).+# A person's dispatch that names an older `sha` validates it in a group of its+# own, so it never replaces or cancels another run. Only a release re-check,+# which the release re-check workflow sends with the workflow token, naming+# main's tip, cancels the running unit run: it is itself a full validation of+# that commit, so the cancelled run's commits stay covered (spec:AST-030 FR22).concurrency:- group: "${{ github.event_name == 'workflow_dispatch' && inputs.sha != '' && format('main-validation-sha-{0}', github.run_id) || 'main-validation' }}"- cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.recheck && inputs.sha == '' && github.triggering_actor == 'github-actions[bot]' }}+ group: "${{ github.event_name == 'push' && 'main-validation' || (inputs.sha != '' && github.triggering_actor != 'github-actions[bot]' && format('main-validation-sha-{0}', github.run_id)) || 'main-unit-tests' }}"+ cancel-in-progress: ${{ github.event_name == 'workflow_dispatch' && inputs.recheck && github.triggering_actor == 'github-actions[bot]' }}jobs:# The one commit every lane and leg of this run tests. A push validates the@@ -109,7 +111,9 @@ jobs:continue-on-error: truetimeout-minutes: 16with:- peak: 14+ # A push runs only the fast checks (main-commit, sync-exports,+ # typecheck, test); a dispatched unit run holds every leg.+ peak: ${{ github.event_name == 'push' && 4 || 14 }}main: true# Verify package.json exports match the source tree.@@ -148,8 +152,11 @@ jobs:# (~5 minutes); the leg that holds the longest Node test file (~6 minutes on# its own) sets the floor, and more legs would not move it. `test` joins the# legs.+ # The unit lanes run the full suites only in a dispatched run (about hourly,+ # from main-heavy-lanes.yml; spec:AST-030 FR21), never on a push.test-ui:needs: [main-commit]+ if: github.event_name != 'push'timeout-minutes: 15strategy:fail-fast: false@@ -176,6 +183,7 @@ jobs:test-node:needs: [main-commit]+ if: github.event_name != 'push'timeout-minutes: 15strategy:fail-fast: false@@ -270,11 +278,21 @@ jobs:runs-on: ubuntu-slimpermissions: {}steps:+ # A push runs only the fast checks; a dispatched run is the full unit+ # run, and passes only when every unit leg passed.- name: Assert every push gate succeeded+ env:+ EVENT: ${{ github.event_name }}+ TEST_UI: ${{ needs.test-ui.result }}+ TEST_NODE: ${{ needs.test-node.result }}+ TYPECHECK: ${{ needs.typecheck.result }}run: |- echo "test-ui: ${{ needs.test-ui.result }}"- echo "test-node: ${{ needs.test-node.result }}"- echo "typecheck: ${{ needs.typecheck.result }}"- [ "${{ needs.test-ui.result }}" = "success" ] || exit 1- [ "${{ needs.test-node.result }}" = "success" ] || exit 1- [ "${{ needs.typecheck.result }}" = "success" ] || exit 1+ echo "test-ui: $TEST_UI"+ echo "test-node: $TEST_NODE"+ echo "typecheck: $TYPECHECK"+ [ "$TYPECHECK" = success ] || exit 1+ if [ "$EVENT" = push ]; then+ [ "$TEST_UI" = skipped ] && [ "$TEST_NODE" = skipped ] || exit 1+ else+ [ "$TEST_UI" = success ] && [ "$TEST_NODE" = success ] || exit 1+ fidiff --git a/.github/workflows/main-heavy-lanes.yml b/.github/workflows/main-heavy-lanes.ymlindex 71cd59335d..b86b8667a0 100644--- a/.github/workflows/main-heavy-lanes.yml+++ b/.github/workflows/main-heavy-lanes.yml@@ -1,14 +1,21 @@# Copyright (c) Meta Platforms, Inc. and affiliates.-# Visual, accessibility and RTL run on main, not on every pull request update-# (spec:AST-030 FR12, DEC-7): this workflow dispatches ci.yml's canonical-# release-check on main's tip; that run is main's visual/a11y/RTL result, and a-# failure is fixed forward. A check covers every merge up to its commit, so-# main is checked about once an hour (DEC-11): a push dispatches at once when-# no check has started in the last 55 minutes, and a quarter-hourly schedule-# picks up the tip a burst of merges left unchecked. Main's own fast checks-# (deploy.yml) still run for every push. The release gate's exact-commit-# release-check before a cut is dispatched separately and is unchanged.+# Main's scheduled checks (spec:AST-030 FR12, FR21, DEC-11, DEC-15). This+# workflow dispatches, for main's tip and about once an hour each:+#+# - ci.yml's canonical release-check: main's visual/a11y/RTL result, fixed+# forward on failure (DEC-7, DEC-11);+# - deploy.yml's full unit run: every unit suite of every package, on that+# exact commit, never cancelled by a push (FR21).+#+# A check covers every merge up to its commit. A push dispatches at once when+# none started in the last 55 minutes, and a quarter-hourly schedule picks up+# the tip a burst of merges left unchecked. A release-check always brings a+# unit run of the same commit, so a release cut has both. A unit run that did+# not complete is run again at once, and the guardian's issue says so. Main's+# fast checks (deploy.yml typecheck, build and export sync) still run for+# every push. The release gate's exact-commit checks are dispatched+# separately and are unchanged.name: Main heavy laneson:@@ -32,8 +39,10 @@ jobs:permissions:actions: writecontents: read+ # The guardian's issue when a unit run did not complete.+ issues: writesteps:- - name: Dispatch the visual, accessibility and RTL release-check for main's tip+ - name: Dispatch main's release-check and full unit run for its tipuses: actions/github-script@v9env:SHA: ${{ github.sha }}@@ -63,56 +72,142 @@ jobs:// A check starts at most once in this window; the schedule's// quarter-hour cadence adds up to 15 minutes to it.const WINDOW_MINUTES = 55;+ const BOT = 'github-actions[bot]';const {data: branch} = await github.rest.repos.getBranch({...context.repo, branch: 'main'});const tip = branch.commit.sha;+ const short = tip.slice(0, 7);if (context.eventName === 'push' && tip !== process.env.SHA) {core.notice(`main moved past ${process.env.SHA.slice(0, 7)}; the newer push's check covers it.`);return;}- // This workflow's checks: ci.yml runs dispatched on main by the- // workflow token, which stays a run's actor when a person re-runs- // it. A cancelled one was replaced while waiting, or stopped by a- // release re-check of main's tip, which is itself a full check.- const {data} = await github.rest.actions.listWorkflowRuns({- ...context.repo, workflow_id: 'ci.yml', event: 'workflow_dispatch', branch: 'main', per_page: 30,- });- const checks = data.workflow_runs.filter(run =>- run.actor?.login === 'github-actions[bot]' && run.conclusion !== 'cancelled');- // A run that checked out a newer commit than it was asked to check- // (a merge landed between the tip read and the dispatch) fails its- // release-authority job and is no check of that commit; it still- // holds the window. Any other run at the tip, failed included, is.+ // A workflow's runs dispatched on main, newest first; the workflow+ // token stays a run's actor when a person re-runs it.+ const dispatchedRuns = async workflow => {+ const {data} = await github.rest.actions.listWorkflowRuns({+ ...context.repo, workflow_id: workflow, event: 'workflow_dispatch', branch: 'main', per_page: 30,+ });+ return data.workflow_runs;+ };+ const byBot = runs => runs.filter(run => run.actor?.login === BOT);+ // Whether a lane is due for the tip. A cancelled run was replaced+ // while waiting, or stopped by a release re-check of main's tip,+ // which is itself a full check. A release-check that checked out a newer commit+ // than it was asked to check (a merge landed between the tip read+ // and the dispatch) fails its release-authority job and is no check+ // of that commit; it still holds the window. A unit run counts only+ // for the commit it names (FR21).const authorityRefused = async run => {const {data: {jobs}} = await github.rest.actions.listJobsForWorkflowRun({...context.repo, run_id: run.id, filter: 'latest', per_page: 100,});return jobs.some(job => job.name === 'release-authority' && job.conclusion === 'failure');};- let checked = false;- for (const run of checks.filter(item => item.head_sha === tip)) {- if (run.status !== 'completed' || run.conclusion === 'success' || !(await authorityRefused(run))) {- checked = true;- break;+ // The commit a Main run names (`Main validation of <sha>`, a+ // dispatch with `sha`; FR22).+ // A run without one tests main's tip when it starts, which can be+ // later than its event's commit, so it covers no commit; the+ // release receipt reads the name the same way (FR21).+ const tested = run => /^Main validation of ([0-9a-f]{40})$/.exec(run.display_title ?? '')?.[1] ?? null;+ const covered = async (runs, checkAuthority) => {+ // A release-check (checkAuthority) is of its event commit; a unit run of the commit it names.+ for (const run of runs.filter(item => item.conclusion !== 'cancelled' && (checkAuthority ? item.head_sha : tested(item)) === tip)) {+ // A unit run covers its commit while it runs, or once it passed+ // or failed; a skipped, timed-out or unstarted one tested+ // nothing, so the tip is due again (FR21).+ if (!checkAuthority) {+ if (run.status !== 'completed' || ['success', 'failure'].includes(run.conclusion)) return true;+ continue;+ }+ if (run.status !== 'completed' || run.conclusion === 'success' || !(await authorityRefused(run))) return true;+ }+ return false;+ };+ const due = async (runs, label, checkAuthority, coverRuns = runs) => {+ const counted = runs.filter(run => run.conclusion !== 'cancelled');+ if (await covered(coverRuns, checkAuthority)) {+ core.notice(`main's tip ${short} already has a ${label}.`);+ return false;+ }+ const latest = counted.map(run => Date.parse(run.created_at)).sort((a, b) => b - a)[0];+ const minutes = latest == null ? Infinity : (Date.now() - latest) / 60000;+ if (minutes < WINDOW_MINUTES) {+ core.notice(`A ${label} started ${Math.floor(minutes)} minutes ago; the next one, at most ${WINDOW_MINUTES - Math.floor(minutes) + 15} minutes from now, covers ${short}.`);+ return false;}+ return true;+ };+ const allChecks = await dispatchedRuns('ci.yml');+ const allUnits = await dispatchedRuns('deploy.yml');+ const checks = byBot(allChecks);+ const units = byBot(allUnits);+ const heavy = await due(checks, 'release-check', true);+ // A person's run of main's tip covers it too.+ let unit = await due(units, 'full unit run', false, allUnits);++ // A full unit run that did not complete (FR21): run the next one at+ // once and tell the guardian, after the dispatches below. A newer+ // run, such as a recheck that replaced it, leaves nothing to do.+ const INCOMPLETE = ['cancelled', 'skipped', 'timed_out', 'startup_failure', 'stale', 'action_required'];+ // The newest run in the unit-run group, which may have replaced it:+ // every dispatched run but a person's that names a commit, which+ // runs in a group of its own (deploy.yml).+ const named = run => /^Main validation of /.test(run.display_title ?? '');+ const newest = allUnits.find(run => !(named(run) && (run.triggering_actor ?? run.actor)?.login !== BOT));+ // A tip that already has a run naming it is covered: nothing to redo.+ const incomplete = newest?.status === 'completed' && INCOMPLETE.includes(newest.conclusion) && !(await covered(allUnits, false));+ if (incomplete) unit = true;++ // ci.yml queues release-checks in one group (one running, one+ // waiting; a newer one replaces the waiting one). A merge landing+ // between the tip read above and this call makes the run check out+ // the newer commit and fail its exact-head check; the next dispatch+ // checks that commit.+ if (heavy) {+ await github.rest.actions.createWorkflowDispatch({+ ...context.repo,+ workflow_id: 'ci.yml',+ ref: 'main',+ inputs: {operation: 'release-check', 'release-branch': 'main', 'expected-head': tip},+ });}- if (checked) {- core.notice(`main's tip ${tip.slice(0, 7)} already has a release-check.`);- return;+ // A release-check always brings a full unit run of the same commit,+ // so a release cut from it has both: this one, or one a person+ // dispatched for the tip, such as the release owner's own check,+ // while that commit is still the tip. A maintenance capture runs+ // no release-authority job and is not a release-check.+ const unitAtTip = await covered(allUnits, false);+ const isReleaseCheck = async run => {+ const {data: {jobs}} = await github.rest.actions.listJobsForWorkflowRun({+ ...context.repo, run_id: run.id, filter: 'latest', per_page: 100,+ });+ return jobs.some(job => job.name === 'release-authority' && job.conclusion !== 'skipped');+ };+ let personCheckAtTip = false;+ if (!unitAtTip && !unit && !heavy) {+ for (const run of allChecks.filter(item => item.actor?.login !== BOT && item.conclusion !== 'cancelled' && item.head_sha === tip)) {+ if (await isReleaseCheck(run)) {+ personCheckAtTip = true;+ break;+ }+ }}- const latest = checks.map(run => Date.parse(run.created_at)).sort((a, b) => b - a)[0];- const minutes = latest == null ? Infinity : (Date.now() - latest) / 60000;- if (minutes < WINDOW_MINUTES) {- core.notice(`A release-check started ${Math.floor(minutes)} minutes ago; the next one, at most ${WINDOW_MINUTES - Math.floor(minutes) + 15} minutes from now, covers ${tip.slice(0, 7)}.`);- return;+ if (unit || ((heavy || personCheckAtTip) && !unitAtTip)) {+ // Named, so the run tests exactly this commit even if main moves+ // before it starts.+ await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'deploy.yml', ref: 'main', inputs: {sha: tip}});+ }++ if (incomplete) {+ const title = 'Main unit tests: an hourly run did not complete';+ const note = `The full unit run ${newest.html_url} for ${newest.head_sha.slice(0, 7)} ended ${newest.conclusion}. The next run was dispatched for ${short}.`;+ core.warning(note);+ const {data: found} = await github.rest.search.issuesAndPullRequests({+ q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open in:title "${title}"`,+ });+ const issue = found.items.find(item => item.title === title);+ if (issue) {+ await github.rest.issues.createComment({...context.repo, issue_number: issue.number, body: note});+ } else {+ await github.rest.issues.create({...context.repo, title, body: `${note}\n\nClose this issue once main's full unit runs complete again (spec:AST-030 FR21).`});+ }}- // ci.yml queues these dispatches in one group (one running, one- // waiting; a newer one replaces the waiting one). A merge landing- // between the tip read above and this call makes the run check out- // the newer commit and fail its exact-head check; the next- // dispatch checks that commit.- await github.rest.actions.createWorkflowDispatch({- ...context.repo,- workflow_id: 'ci.yml',- ref: 'main',- inputs: {operation: 'release-check', 'release-branch': 'main', 'expected-head': tip},- });diff --git a/.github/workflows/release-recheck.yml b/.github/workflows/release-recheck.ymlindex f5ca3f7d2b..4498c14cdc 100644--- a/.github/workflows/release-recheck.yml+++ b/.github/workflows/release-recheck.yml@@ -123,9 +123,9 @@ jobs:});await github.rest.actions.createWorkflowDispatch({...context.repo, workflow_id: 'deploy.yml', ref: 'main',- // Without `sha`: a re-check validates main's tip, which takes- // the validation group; a `sha` run never does.- inputs: {recheck: 'true'},+ // Naming the commit, so the run is the commit's unit-run receipt+ // (spec:AST-030 FR21); a re-check takes the unit-run group.+ inputs: {sha, recheck: 'true'},});await core.summary.addHeading('Release re-check started')diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 1a180d19f7..ae2edeae80 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -126,19 +126,21 @@ jobs:| tee release-publish-receipt.json# A release is built from a main commit whose canonical release-check- # passed (spec:AST-030 FR12, DEC-11): main is checked about hourly, so- # the cut commit's own check is required here, before anything builds.+ # and full unit run passed (spec:AST-030 FR12, FR21, DEC-11, DEC-15):+ # main is checked about hourly, so the cut commit's own checks are+ # required here, before anything builds.- name: Require a passing release-check at the exact cut commituses: actions/github-script@v9with:retries: 3script: |const {pathToFileURL} = require('node:url');- const {requireReleaseCheck} = await import(+ const {requireReleaseCheck, requireUnitRun} = await import(pathToFileURL(`${process.env.GITHUB_WORKSPACE}/scripts/release/release-check-receipt.mjs`).href);const {cutSha} = require(`${process.env.GITHUB_WORKSPACE}/.release/active.json`);- await requireReleaseCheck({github, core, ...context.repo, sha: cutSha});+ const check = await requireReleaseCheck({github, core, ...context.repo, sha: cutSha});+ if (check) await requireUnitRun({github, core, ...context.repo, sha: cutSha});- name: Upload exact release authority receiptuses: actions/upload-artifact@v7diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 0949a4c2d8..f46c1cbe18 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -796,9 +796,12 @@ slugs and docs routes, are data and may change.### How a release is cut-First, the canonical full-scope `release-check` must pass on an exact commit from-current `main`; the release branch is cut only from that checked SHA while it remains-in current main history. A minor cut also requires Cindy, the release owner, to+First, the canonical full-scope `release-check` and a full unit run of the Main+workflow must both pass on an exact commit from current `main`. Main's scheduler+dispatches the unit run with every release-check of main's tip, a person's included,+while that commit is still the tip. The release branch is cut only from a SHA with+both while it remains in current main history; the stable publish refuses one+without them. A minor cut also requires Cindy, the release owner, toexplicitly sign off on the exact `vX.Y.0` immediately before the branch is created.Scheduled or standing authority does not cover a minor.diff --git a/docs/release.md b/docs/release.mdindex 1bce425610..1055b95709 100644--- a/docs/release.md+++ b/docs/release.md@@ -10,8 +10,14 @@ stable package is built from an immutable release tag and published with provena## Release sequence1. Run the canonical full-scope `release-check` on an exact commit from current- `main`. Cut only from that checked SHA while it remains in current `main`- history. A minor cut additionally requires Cindy, the release owner, to+ `main`. That commit also needs a passing full unit run of the Main workflow:+ main's scheduler dispatches one with every release-check of main's tip, a+ person's included, within about 15 minutes while that commit is still the+ tip. A release owner can also dispatch the Main workflow beside their own+ check with `sha` set to the checked commit, which tests exactly that+ commit; a dispatch without `sha` tests whatever is main's tip when it+ starts and is no receipt. Cut only from a SHA with both while it remains in current `main`+ history; the stable publish refuses a cut commit without both. A minor cut additionally requires Cindy, the release owner, toexplicitly sign off on the exact `vX.Y.0` immediately before the branch iscreated; scheduled or standing authority never substitutes for that sign-off.2. Create the single marked `release/vX.Y.Z` branch. Its version is the fixed-groupdiff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.mdindex 8b48125e65..1c4af52bc8 100644--- a/docs/specs/AST-030/spec.md+++ b/docs/specs/AST-030/spec.md@@ -244,7 +244,10 @@ they are separately named.(FR23): at most one runs and one waits. A push whose commit `main` has alreadymoved past leaves its check to the newer push. That release-check run ismain's result, and a failure is fixed forward by an atomic pull request.- Main's own fast checks still run for every push. Release checks MUST NOT+ Main's own fast checks (typecheck, the package build with its per-commit size+ record, and export sync) still run for every push; its full unit suites run+ about hourly on their own schedule, and with every release-check, as FR21+ says. Release checks MUST NOTcapture baseline candidates, publish baselines, or use a separate dailyworkflow or retroactive acceptance status. Deployment, accessibility, RTL, andvibe evidence MAY retain their workflows and artifacts when they do not@@ -399,6 +402,25 @@ they are separately named.minutes added to time to green. A flag asks the reviewer to weigh the cost;it fails no check.+- **FR21 — Main's full unit run is about hourly and always finishes.** The+ Main workflow runs its unit suites (every Vitest project of every package,+ never scoped to a change) only in a dispatched run, such as the one main's+ heavy-lane workflow dispatches for `main`'s tip, naming that commit, about+ once an hour on its own schedule: a push+ dispatches it at once when none started in the last 55 minutes, and the+ quarter-hourly schedule picks up the tip a burst left. Every release-check of+ `main`'s tip (FR12), the scheduler's or one a person dispatches such as the+ release owner's own, brings a unit run of that commit while it is still the+ tip; a person may also dispatch the Main workflow beside their check, naming+ the commit as `sha`. A unit run counts only for the commit it names. That run reports one pass or+ fail for that exact commit. It runs to completion: it+ has its own concurrency group, which no push cancels, and a newer dispatch+ queues behind it; only a release re-check replaces it (FR22, DEC-18). A unit run that is skipped, cancelled or otherwise does not+ complete makes the next one dispatch at once and is reported in the+ guardian's issue; a newer run that replaced it, such as a recheck, leaves+ nothing to report. A stable release publishes only from a cut commit with+ both a passing release-check and a passing full unit run (DEC-15).+- **FR22 — Main's full unit run finishes in minutes.** The Main workflow runsevery Vitest leg of `main`'s full unit run at once, with no `max-parallel`hold: six UI legs and six Node legs beside the build-and-typecheck lane, each@@ -408,12 +430,13 @@ they are separately named.floor; a file with no recorded time counts as the median, and which files runnever depends on the times. A dispatch may name `sha`, a commit in `main`'shistory that has the size records the build lane keeps, and every lane checks- that commit out; without it the run validates `main`'s tip. A `sha` run waits- for no other validation and replaces nothing; like every Main run, it waits- for room under CI's ceiling (FR16). One validation of `main` runs at a time- and a newer one waits. Only a release re-check, which the workflow token sends- with `recheck` and no `sha`, cancels the running validation, because the- re-check validates `main`'s tip in full itself. Pull-request legs keep their+ that commit out; without it the run validates `main`'s tip. A person's `sha` run+ waits for no other validation and replaces nothing; like every Main run, it+ waits for room under CI's ceiling (FR16). One full unit run of `main` runs at+ a time and a newer one waits (FR21); a push's fast checks run beside it. Only+ a release re-check, which the workflow token sends with `recheck` and `main`'s+ tip as `sha`, cancels the running unit run, because the re-check validates+ that commit in full itself. Pull-request legs keep theirshape.- **FR23 — A release-check finishes in minutes, and the release owner can@@ -467,26 +490,27 @@ The nightly perf lane is the one scheduled measurement outside them (FR18).## Verification-| Contract | Verification | Representative states | Mutation or failure expectation |-| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| FR1–FR2 | classifier unit tests expose the surface set | knowledge; docsite; admitted tool; Core/Lab/Charts/Rich Text/Vega source; shared config; unknown | an unclassified path receives a specialized lane or a category has no check owner |-| FR3–FR4 | workflow contract tests execute an isolated trusted-base classifier | valid base; missing merge base; missing matcher/registry; classifier self-change; merge group | PR-controlled policy grants a lane, or missing trust data skips checks |-| FR5 | mixed-surface and incomplete-owner routing tests | spec+component; tooling+component; named surface without admitted lane; docsite+shared | one surface hides another owner or a named-but-incomplete surface skips broad CI |-| FR6–FR8 | Node-tooling dependency, CI workflow, and trusted post-CI workflow tests | both admitted score-ledger paths; Sandbox projection imports; test/build joins; preview/visual publisher | UI/browser/build work or preview publication runs for the singleton tool set, an operational consumer is untested, a visual status stays pending, or a required context disappears |-| FR9 | mutation-sensitive classifier and workflow fixtures | unknown path; rename from unknown; truncated list; package-specific public paths | weakening a fail-closed rule leaves the suite green |-| FR10 | surface-admission and routing contract tests | existing surface; proposed surface with and without the full admission contract | a new surface adds lanes without its approved paths, commands, ownership, projections, and routing tests |-| FR11 | surface owner, internal-job, and required-join contract tests | Build package browser behavior; CLI; theme-family broad fallback; mixed Core+CLI | a second owner is routed for one surface, an internal job masquerades as a lane, an owned failure misses its join, or an unrelated owner runs |-| FR12 | Storybook visual-plan, canonical workflow, and repository-owner guard tests | PR scope; full-plan maintenance; report-only publication; deployment/a11y/RTL/vibe artifacts | another workflow captures or compares pixels, a renamed or aliased owner escapes the guard, or legitimate non-visual artifacts are rejected |-| FR12 | `touched-components.test.mjs` changed-spec routing; `a11y-pr-contracts.test.mjs` `changedOnly` cases | a pull request that adds a browser accessibility spec; one that changes an `always` spec; one that changes a `release-only` or an `audit` spec; one that changes more spec files than the limit; a component change with no spec change | a pull request that adds a browser accessibility spec that fails is not caught on that pull request, an unchanged, `release-only` or `audit` spec runs in the default check, a file over the limit is reported as passed, or the default check widens past the changed spec files |-| FR13 | classifier, workflow contract, component-analysis and RTL-scope tests | component change; shared module; Changeset beside code; infrastructure path; incomplete list; no build | an infrastructure path is scoped, a file-system guard test is skipped, a reverse dependent leaves visual/RTL or enters PR accessibility, or a full-suite event is narrowed |-| FR14 | `workflow-paths.test.mjs` over every workflow | path allowlist; required-context workflow | a `paths-ignore`, a match-all or exclusion glob, or a path filter on a workflow that reports a required context fails |-| 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 | `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, or an over-budget run decides |-| 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 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` waits, a job admission could skip, or a peak below the jobs its run holds fails |-| 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 |-| FR19 | `ci-impact.test.mjs`, `pr-preview.test.mjs` and the maintenance template | CI change and non-CI change; standard, non-standard and expression runners; added, removed and changed jobs; trigger change | a CI change reports no impact, a move onto a non-standard runner or a pool or time-to-green rise past its threshold goes unflagged, or the section names a price |-| FR22 | `main-validation-workflow.test.mjs` over the Main workflow and its commit resolver; `vitest-shard-sequencer.test.mjs` over the recorded Node times | six UI and six Node legs; dispatch without a commit, with a commit in main's history, with a commit outside it and with a malformed one; a re-check from the workflow token and from a person, and one that names `sha`; a `sha` before the size records, and one of only spaces; four and six Node legs over the recorded suite, a file with no recorded time, a project other than `node` | a hold, a leg past the fifteen-minute budget, a commit outside main's history that validates, a person's dispatch or a `sha` run that cancels or replaces a validation of main, a `sha` lane that checks out another commit, or a `sha` run named for main's tip, or two of the slowest Node files in one leg, a file run by no leg or by two, or a split that depends on collection order fails |-| FR23 | `release-check-shape.test.mjs`, `a11y-contract-shard.test.mjs` and the release-check workflow contract | release-check and pull-request legs; a contract file longer than a leg's share, one it cannot name exactly, and a serial one; the recorded suite; a re-check from an admin, a maintainer and a writer, from another branch, with a short SHA and with an older commit; failed-only beside a passed, a running and a missing run | a narrower release-check, a held or over-budget leg, a test selected by no leg or by two, a re-check that a writer can start, that waits for main's running check, or that re-runs jobs of another commit fails |+| Contract | Verification | Representative states | Mutation or failure expectation |+| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1–FR2 | classifier unit tests expose the surface set | knowledge; docsite; admitted tool; Core/Lab/Charts/Rich Text/Vega source; shared config; unknown | an unclassified path receives a specialized lane or a category has no check owner |+| FR3–FR4 | workflow contract tests execute an isolated trusted-base classifier | valid base; missing merge base; missing matcher/registry; classifier self-change; merge group | PR-controlled policy grants a lane, or missing trust data skips checks |+| FR5 | mixed-surface and incomplete-owner routing tests | spec+component; tooling+component; named surface without admitted lane; docsite+shared | one surface hides another owner or a named-but-incomplete surface skips broad CI |+| FR6–FR8 | Node-tooling dependency, CI workflow, and trusted post-CI workflow tests | both admitted score-ledger paths; Sandbox projection imports; test/build joins; preview/visual publisher | UI/browser/build work or preview publication runs for the singleton tool set, an operational consumer is untested, a visual status stays pending, or a required context disappears |+| FR9 | mutation-sensitive classifier and workflow fixtures | unknown path; rename from unknown; truncated list; package-specific public paths | weakening a fail-closed rule leaves the suite green |+| FR10 | surface-admission and routing contract tests | existing surface; proposed surface with and without the full admission contract | a new surface adds lanes without its approved paths, commands, ownership, projections, and routing tests |+| FR11 | surface owner, internal-job, and required-join contract tests | Build package browser behavior; CLI; theme-family broad fallback; mixed Core+CLI | a second owner is routed for one surface, an internal job masquerades as a lane, an owned failure misses its join, or an unrelated owner runs |+| FR12 | Storybook visual-plan, canonical workflow, and repository-owner guard tests | PR scope; full-plan maintenance; report-only publication; deployment/a11y/RTL/vibe artifacts | another workflow captures or compares pixels, a renamed or aliased owner escapes the guard, or legitimate non-visual artifacts are rejected |+| FR12 | `touched-components.test.mjs` changed-spec routing; `a11y-pr-contracts.test.mjs` `changedOnly` cases | a pull request that adds a browser accessibility spec; one that changes an `always` spec; one that changes a `release-only` or an `audit` spec; one that changes more spec files than the limit; a component change with no spec change | a pull request that adds a browser accessibility spec that fails is not caught on that pull request, an unchanged, `release-only` or `audit` spec runs in the default check, a file over the limit is reported as passed, or the default check widens past the changed spec files |+| FR13 | classifier, workflow contract, component-analysis and RTL-scope tests | component change; shared module; Changeset beside code; infrastructure path; incomplete list; no build | an infrastructure path is scoped, a file-system guard test is skipped, a reverse dependent leaves visual/RTL or enters PR accessibility, or a full-suite event is narrowed |+| FR14 | `workflow-paths.test.mjs` over every workflow | path allowlist; required-context workflow | a `paths-ignore`, a match-all or exclusion glob, or a path filter on a workflow that reports a required context fails |+| 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 | `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, or an over-budget run decides |+| 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 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` waits, a job admission could skip, or a peak below the jobs its run holds fails |+| 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 |+| FR19 | `ci-impact.test.mjs`, `pr-preview.test.mjs` and the maintenance template | CI change and non-CI change; standard, non-standard and expression runners; added, removed and changed jobs; trigger change | a CI change reports no impact, a move onto a non-standard runner or a pool or time-to-green rise past its threshold goes unflagged, or the section names a price |+| FR21 | `ci-heavy-lanes.test.mjs` dispatch cases, `main-unit-run.test.mjs` over deploy.yml, `release-check-receipt.test.mjs` | push run; dispatched unit run; tip with the scheduler's or a person's release-check, or a person's maintenance capture; unit run cancelled, skipped or timed out; newer recheck or person's run of the tip; a person's validation of an older commit; cut commit with and without a passing unit run | a push runs the unit suites, a push cancels a unit run, a release-check comes without a unit run of its commit, an incomplete run goes unreported or waits a window, or a cut publishes without a passing unit run |+| FR22 | `main-validation-workflow.test.mjs` over the Main workflow and its commit resolver; `vitest-shard-sequencer.test.mjs` over the recorded Node times | six UI and six Node legs; dispatch without a commit, with a commit in main's history, with a commit outside it and with a malformed one; a re-check from the workflow token and from a person, and one that names `sha`; a `sha` before the size records, and one of only spaces; four and six Node legs over the recorded suite, a file with no recorded time, a project other than `node` | a hold, a leg past the fifteen-minute budget, a commit outside main's history that validates, a person's dispatch or a person's `sha` run that cancels or replaces a validation of main, a `sha` lane that checks out another commit, or a `sha` run named for main's tip, or two of the slowest Node files in one leg, a file run by no leg or by two, or a split that depends on collection order fails |+| FR23 | `release-check-shape.test.mjs`, `a11y-contract-shard.test.mjs` and the release-check workflow contract | release-check and pull-request legs; a contract file longer than a leg's share, one it cannot name exactly, and a serial one; the recorded suite; a re-check from an admin, a maintainer and a writer, from another branch, with a short SHA and with an older commit; failed-only beside a passed, a running and a missing run | a narrower release-check, a held or over-budget leg, a test selected by no leg or by two, a re-check that a writer can start, that waits for main's running check, or that re-runs jobs of another commit fails |## Decision log@@ -716,6 +740,26 @@ quiet, so the check would starve); holding a runner to wait out each push (itis billed while it waits); a daily check (main's result would lag a wholeday).+### DEC-15 — Main's unit suites run about hourly, in full, to completion++**Reference:** `spec:AST-030/DEC-15`+**Decider:** `cixzhang`++Main ran both unit suites after every push, about a hundred full runs a day,+to catch the rare break two pull requests that pass alone make together. One+full run about an hour, beside the release-check of the same commit, catches+that break within about an hour and a half. The run is never scoped, and no push+cancels it; one that does not finish is run again at once and reported, unless+a release re-check replaced it (DEC-18), so every merge is covered by a unit+run that completed. The fast checks that+pull requests rely on, typecheck and the build with its size record, stay on+every push.++Rejected: running the unit suites on main's push cadence with a scope (a+scoped run on main would miss the cross-change break it exists for);+cancelling an older unit run for a newer push (a run that never finishes+covers nothing).+### DEC-17 — Main's full runs spend runner-minutes to finish in minutes**Reference:** `spec:AST-030/DEC-17`diff --git a/scripts/release/release-check-receipt.mjs b/scripts/release/release-check-receipt.mjsindex 0c6be9129e..f535e6d752 100644--- a/scripts/release/release-check-receipt.mjs+++ b/scripts/release/release-check-receipt.mjs@@ -54,9 +54,15 @@ export async function findReleaseCheck({github, owner, repo, sha}) {/** The newest main commit with a passing release-check, or null. */export async function lastCheckedMain({github, owner, repo}) {+ // A cut needs both receipts (FR12, FR21), so the commit to re-cut from is+ // the newest with a passing release-check and a passing full unit run.for (const run of await dispatchedRuns({github, owner, repo})) {- if (await passedReleaseCheck({github, owner, repo, run}))+ if (+ (await passedReleaseCheck({github, owner, repo, run})) &&+ (await findUnitRun({github, owner, repo, sha: run.head_sha}))+ ) {return run.head_sha;+ }}return null;}@@ -76,14 +82,98 @@ export async function requireReleaseCheck({github, core, owner, repo, sha}) {core.info(`Cut commit ${sha} passed release-check in ${run.html_url}.`);return run;}- const last = await lastCheckedMain({github, owner, repo});// A check can only be dispatched for main's tip, so the way forward is a// cut from a commit that has one.core.setFailed(`No passing release-check for the cut commit ${sha}. ` +- (last- ? `Re-cut the release from main's last commit with a passing release-check, ${last}, or wait for main's next check and cut from it.`- : "No main commit has a passing release-check in the recent runs; wait for main's next check and cut from it."),+ (await recutAdvice({github, owner, repo})),+ );+ return null;+}++async function recutAdvice({github, owner, repo}) {+ const last = await lastCheckedMain({github, owner, repo});+ return last+ ? `Re-cut the release from main's last commit with both a passing release-check and a passing full unit run, ${last}, or wait for main's next checks and cut from them.`+ : "No recent main commit has both a passing release-check and a passing full unit run; wait for main's next checks and cut from them.";+}++/**+ * Whether a run of the Main workflow (deploy.yml) is a passing full unit run:+ * the run succeeded and every unit leg ran and passed. A push run, whose unit+ * legs skip, is not one (spec:AST-030 FR21).+ */+async function passedUnitRun({github, owner, repo, run}) {+ if (run.conclusion !== 'success') return false;+ const {+ data: {jobs},+ } = await github.rest.actions.listJobsForWorkflowRun({+ owner,+ repo,+ run_id: run.id,+ per_page: 100,+ });+ const legs = prefix => jobs.filter(job => job.name.startsWith(prefix));+ return ['test-ui (', 'test-node ('].every(+ prefix =>+ legs(prefix).length > 0 &&+ legs(prefix).every(job => job.conclusion === 'success'),+ );+}++/**+ * The commit a Main run names (`Main validation of <sha>`, a dispatch with+ * `sha`), or null. A run without one tests main's tip when it starts, which+ * can be later than its event's commit, so it is no receipt for any commit+ * (spec:AST-030 FR21, FR22).+ */+function testedSha(run) {+ return (+ /^Main validation of ([0-9a-f]{40})$/.exec(run.display_title ?? '')?.[1] ??+ null+ );+}++/** The passing full unit run that tested exactly `sha`, or null. */+export async function findUnitRun({github, owner, repo, sha}) {+ const list = async extra => {+ const {data} = await github.rest.actions.listWorkflowRuns({+ owner,+ repo,+ workflow_id: 'deploy.yml',+ branch: 'main',+ status: 'success',+ ...extra,+ });+ return data.workflow_runs.filter(item => testedSha(item) === sha);+ };+ // The scheduler's run of main's tip names it under the same event commit; a+ // validation of an older commit names it under a later one.+ for (const runs of [+ await list({head_sha: sha, per_page: 30}),+ await list({event: 'workflow_dispatch', per_page: 100}),+ ]) {+ for (const run of runs) {+ if (await passedUnitRun({github, owner, repo, run})) return run;+ }+ }+ return null;+}++/**+ * Fails the step unless the cut commit has a passing full unit run. Main's+ * scheduler dispatches one with every release-check, so a commit with a+ * passing release-check normally has one too.+ */+export async function requireUnitRun({github, core, owner, repo, sha}) {+ const run = await findUnitRun({github, owner, repo, sha});+ if (run) {+ core.info(`Cut commit ${sha} passed the full unit run in ${run.html_url}.`);+ return run;+ }+ core.setFailed(+ `No passing full unit run for the cut commit ${sha}. ` ++ (await recutAdvice({github, owner, repo})),);return null;}diff --git a/scripts/release/release-check-receipt.test.mjs b/scripts/release/release-check-receipt.test.mjsindex 758ce14ca5..be6fe21cca 100644--- a/scripts/release/release-check-receipt.test.mjs+++ b/scripts/release/release-check-receipt.test.mjs@@ -15,6 +15,7 @@ import {describe, expect, it} from 'vitest';import {findReleaseCheck,requireReleaseCheck,+ requireUnitRun,} from './release-check-receipt.mjs';const CUT = 'c'.repeat(40);@@ -27,9 +28,14 @@ const run = (id, headSha, conclusion = 'success') => ({html_url: `https://github.com/o/r/actions/runs/${id}`,});const join = conclusion => ({name: 'release-check', conclusion});+/** A Main run dispatched for `sha`, as the scheduler names it. */+const unitRunFor = (id, headSha, conclusion = 'success') => ({+ ...run(id, headSha, conclusion),+ display_title: `Main validation of ${headSha}`,+});/** `runs` are newest first; `jobs` maps a run id to its jobs. */-function fake({runs = [], jobs = {}} = {}) {+function fake({runs = [], units, jobs = {}} = {}) {const listed = [];return {listed,@@ -40,7 +46,10 @@ function fake({runs = [], jobs = {}} = {}) {listed.push(params);return {data: {- workflow_runs: runs.filter(+ workflow_runs: (params.workflow_id === 'deploy.yml'+ ? (units ?? runs)+ : runs+ ).filter(item =>(!params.head_sha || item.head_sha === params.head_sha) &&item.conclusion === params.status,@@ -107,14 +116,25 @@ describe('the release-check receipt for a cut commit', () => {).toBe(7);});- it("fails naming main's last checked commit when the cut commit has no passing release-check", async () => {+ it("fails naming main's last commit with both receipts when the cut commit has no passing release-check", async () => {+ const NEWER = 'e'.repeat(40);const {result, messages} = await require_({- runs: [run(9, CUT, 'failure'), run(8, OTHER)],- jobs: {9: [join('failure')], 8: [join('success')]},+ // NEWER passed its release-check but its unit run failed.+ runs: [run(10, NEWER), run(9, CUT, 'failure'), run(8, OTHER)],+ units: [unitRunFor(21, NEWER, 'failure'), unitRunFor(20, OTHER)],+ jobs: {+ 10: [join('success')],+ 9: [join('failure')],+ 8: [join('success')],+ 20: [+ {name: 'test-ui (1/4)', conclusion: 'success'},+ {name: 'test-node (1/4)', conclusion: 'success'},+ ],+ },});expect(result).toBeNull();expect(messages.failed).toEqual([- `No passing release-check for the cut commit ${CUT}. Re-cut the release from main's last commit with a passing release-check, ${OTHER}, or wait for main's next check and cut from it.`,+ `No passing release-check for the cut commit ${CUT}. Re-cut the release from main's last commit with both a passing release-check and a passing full unit run, ${OTHER}, or wait for main's next checks and cut from them.`,]);});@@ -128,7 +148,7 @@ describe('the release-check receipt for a cut commit', () => {/^No passing release-check for the cut commit/,);expect(messages.failed[0]).toMatch(- /No main commit has a passing release-check/,+ /No recent main commit has both a passing release-check and a passing full unit run/,);});@@ -141,3 +161,98 @@ describe('the release-check receipt for a cut commit', () => {]);});});++describe('the full unit run receipt for a cut commit (spec:AST-030 FR21)', () => {+ const legs = conclusion => [+ ...[1, 2, 3, 4].map(n => ({name: `test-ui (${n})`, conclusion})),+ ...[1, 2, 3, 4].map(n => ({name: `test-node (${n})`, conclusion})),+ {name: 'typecheck', conclusion: 'success'},+ ];+ async function unit(options, sha = CUT) {+ const {github, listed} = fake(options);+ const messages = {info: [], failed: []};+ const core = {+ info: message => messages.info.push(message),+ setFailed: message => messages.failed.push(message),+ };+ const result = await requireUnitRun({+ github,+ core,+ owner: 'o',+ repo: 'r',+ sha,+ });+ return {result, messages, listed};+ }++ it("accepts the cut commit's run where every unit leg passed", async () => {+ const {result, messages, listed} = await unit({+ runs: [unitRunFor(5, CUT)],+ jobs: {5: legs('success')},+ });+ expect(result.id).toBe(5);+ expect(messages.failed).toEqual([]);+ expect(listed[0]).toEqual({+ owner: 'o',+ repo: 'r',+ workflow_id: 'deploy.yml',+ branch: 'main',+ status: 'success',+ head_sha: CUT,+ per_page: 30,+ });+ });++ it('does not take an unnamed run, which tests whatever was the tip when it started', async () => {+ const {result} = await unit({+ runs: [run(9, CUT)],+ jobs: {9: legs('success')},+ });+ expect(result).toBeNull();+ });++ it('takes a validation that names the cut commit, and not one that names another', async () => {+ const LATER = 'f'.repeat(40);+ const named = (id, tested) => ({+ ...run(id, LATER),+ display_title: `Main validation of ${tested}`,+ });+ const {result} = await unit({+ runs: [named(31, OTHER), named(30, CUT)],+ jobs: {30: legs('success'), 31: legs('success')},+ });+ expect(result.id).toBe(30);+ const none = await unit({+ runs: [{...run(32, CUT), display_title: `Main validation of ${OTHER}`}],+ jobs: {32: legs('success')},+ });+ expect(none.result).toBeNull();+ });++ it('does not take a push run, whose unit legs skipped, for a unit run', async () => {+ const {result, messages} = await unit({+ runs: [run(6, CUT)],+ jobs: {6: legs('skipped')},+ });+ expect(result).toBeNull();+ expect(messages.failed).toEqual([+ `No passing full unit run for the cut commit ${CUT}. No recent main commit has both a passing release-check and a passing full unit run; wait for main's next checks and cut from them.`,+ ]);+ });++ it('refuses a run with no unit legs at all', async () => {+ const {result} = await unit({+ runs: [run(7, CUT)],+ jobs: {7: [{name: 'typecheck', conclusion: 'success'}]},+ });+ expect(result).toBeNull();+ });++ it("ignores another commit's passing run", async () => {+ const {result} = await unit({+ runs: [run(8, OTHER)],+ jobs: {8: legs('success')},+ });+ expect(result).toBeNull();+ });+});