Skip to content

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

TypeScript

ci: the heavy lanes decide their component scope; drop the scope jobs (#8919)

Cindy Zhang8361437c7250
diff --git a/.github/actions/test-scope/action.yml b/.github/actions/test-scope/action.yml
index d2ad16af58..b583b0b315 100644
--- a/.github/actions/test-scope/action.yml
+++ b/.github/actions/test-scope/action.yml
@@ -37,6 +37,13 @@ inputs:
default) or `skip`, for evidence that already ran on the pull request.
required: false
default: run
+ component-audit:
+ description: >-
+ `true` to also classify which component audits apply (the trusted
+ component-audit-scope.cjs from the base) and to list the changed files,
+ for the visual and RTL jobs.
+ required: false
+ default: 'false'
requires-head-file:
description: >-
Optional path the work needs at the PR head. A head cut before that file
@@ -69,6 +76,23 @@ outputs:
touches:
description: A changed path matches `paths` (true when `paths` is empty or undecidable).
value: ${{ steps.scope.outputs.touches }}
+ has_components:
+ description: A component audit applies (with `component-audit`).
+ value: ${{ steps.scope.outputs.has_components }}
+ has_rtl_components:
+ description: An RTL-audited component changed (with `component-audit`).
+ value: ${{ steps.scope.outputs.has_rtl_components }}
+ has_rtl_harness:
+ description: The RTL harness changed (with `component-audit`).
+ value: ${{ steps.scope.outputs.has_rtl_harness }}
+ force_full_component_audits:
+ description: Component audits must run in full (with `component-audit`).
+ value: ${{ steps.scope.outputs.force_full_component_audits }}
+ changed_files_path:
+ description: >-
+ A file listing the PR's changed paths, one per line (with
+ `component-audit`); empty when the step could not list them.
+ value: ${{ steps.scope.outputs.changed_files_path }}
applies:
description: >-
The job's work applies: not a specialized lane (spec, docsite or tooling
@@ -84,6 +108,7 @@ runs:
SCOPE_PATHS: ${{ inputs.paths }}
SCOPE_OUTSIDE_PR: ${{ inputs.outside-pull-request }}
SCOPE_HEAD_FILE: ${{ inputs.requires-head-file }}
+ SCOPE_COMPONENT_AUDIT: ${{ inputs.component-audit }}
with:
retries: 3
script: |
@@ -102,6 +127,22 @@ runs:
applies: 'true',
decided: 'true',
};
+ // Outside a pull request, or when undecidable, every component audit
+ // applies in full; a specialized lane has none.
+ const auditAll = {
+ has_components: 'true',
+ has_rtl_components: 'true',
+ has_rtl_harness: 'true',
+ force_full_component_audits: 'true',
+ };
+ const auditNone = {
+ has_components: 'false',
+ has_rtl_components: 'false',
+ has_rtl_harness: 'false',
+ force_full_component_audits: 'false',
+ };
+ const audit = process.env.SCOPE_COMPONENT_AUDIT === 'true';
+ Object.assign(everything, audit ? auditAll : {});
const report = values => {
for (const [key, value] of Object.entries(values)) core.setOutput(key, value);
core.info(Object.entries(values).map(([k, v]) => `${k}=${v}`).join(' '));
@@ -117,6 +158,7 @@ runs:
core.info('Release-branch pull request: the generated version bump.');
report({
...everything,
+ ...(audit ? auditNone : {}),
spec_only: 'true',
tooling_only: 'true',
release_bump: 'true',
@@ -142,6 +184,7 @@ runs:
'.github/scripts/change-scope.cjs',
'.github/scripts/knowledge-paths.cjs',
'scripts/component-packages.cjs',
+ ...(audit ? ['.github/scripts/component-audit-scope.cjs'] : []),
]) {
const {data} = await github.rest.repos.getContent({...context.repo, path: file, ref: pr.base.sha});
fs.mkdirSync(path.join(root, path.dirname(file)), {recursive: true});
@@ -193,4 +236,33 @@ runs:
}
}
}
- report({...everything, ...classified, release_bump: 'false', touches, applies});
+ let componentScope = {};
+ if (audit) {
+ if (specialized) {
+ componentScope = auditNone;
+ } else {
+ const auditFile = path.join(root, 'component-audit');
+ fs.writeFileSync(auditFile, '');
+ try {
+ execFileSync('node', [
+ path.join(root, '.github/scripts/component-audit-scope.cjs'),
+ '--registry',
+ path.join(root, 'scripts/component-packages.cjs'),
+ '--github-output',
+ ], {input: `${nameStatus}\n`, env: {...process.env, GITHUB_OUTPUT: auditFile}, stdio: ['pipe', 'inherit', 'inherit']});
+ componentScope = Object.fromEntries(
+ fs.readFileSync(auditFile, 'utf8').split('\n').filter(Boolean).map(line => line.split('=')),
+ );
+ } catch (error) {
+ core.warning(`Component audit scope could not be decided (${error.message}); every audit runs in full.`);
+ componentScope = auditAll;
+ }
+ }
+ // A file, not an output value: a large pull request's list would
+ // not fit an environment variable.
+ const changedFilesPath = path.join(process.env.RUNNER_TEMP || os.tmpdir(), 'test-scope-changed-files.txt');
+ const changed = [...new Set(files.flatMap(f => [f.filename, f.previous_filename].filter(Boolean)))];
+ fs.writeFileSync(changedFilesPath, `${changed.join('\n')}\n`);
+ componentScope.changed_files_path = changedFilesPath;
+ }
+ report({...everything, ...classified, ...componentScope, release_bump: 'false', touches, applies});
diff --git a/.github/scripts/ci-rtl-d7.test.mjs b/.github/scripts/ci-rtl-d7.test.mjs
index 09a88fef21..99aeffb572 100644
--- a/.github/scripts/ci-rtl-d7.test.mjs
+++ b/.github/scripts/ci-rtl-d7.test.mjs
@@ -73,7 +73,9 @@ describe('ci.yml RTL D7 regression step', () => {
it('runs only for the first core RTL shard, in the browser mode', () => {
const step = d7Step();
- expect(step.if).toBe("matrix.package == 'core' && matrix.part == 1");
+ expect(step.if).toBe(
+ "(matrix.package == 'core' && matrix.part == 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')",
+ );
expect(step.env).toEqual({ASTRYX_RTL_BROWSER: '1'});
});
diff --git a/.github/scripts/ci-test-join.mjs b/.github/scripts/ci-test-join.mjs
index 5d6efa898d..4625517a5c 100644
--- a/.github/scripts/ci-test-join.mjs
+++ b/.github/scripts/ci-test-join.mjs
@@ -27,12 +27,6 @@ function fail(message) {
process.exitCode = 1;
}
-// check-scope still feeds the heavy lanes and release-check, so a failed
-// classification must still fail the required join.
-if (process.env.CHECK_SCOPE_RESULT !== 'success') {
- fail(`check-scope: ${process.env.CHECK_SCOPE_RESULT ?? 'missing'}`);
-}
-
for (const [name, result] of requiredSuccess) {
if (result !== 'success') fail(`${name}: ${result ?? 'missing'}`);
}
diff --git a/.github/scripts/ci-test-join.test.mjs b/.github/scripts/ci-test-join.test.mjs
index 83c7527bd2..2028163c7e 100644
--- a/.github/scripts/ci-test-join.test.mjs
+++ b/.github/scripts/ci-test-join.test.mjs
@@ -9,7 +9,6 @@ import {describe, expect, it} from 'vitest';
const script = path.join(import.meta.dirname, 'ci-test-join.mjs');
const broad = {
- CHECK_SCOPE_RESULT: 'success',
DOCSITE_ONLY: 'false',
SPEC_ONLY: 'false',
TOOLING_ONLY: 'false',
@@ -73,11 +72,6 @@ describe('pull-request test join', () => {
},
);
- it('fails closed when classification failed or omitted', () => {
- expect(run({CHECK_SCOPE_RESULT: 'failure'})).toMatchObject({status: 1});
- expect(run({CHECK_SCOPE_RESULT: ''})).toMatchObject({status: 1});
- });
-
it('requires the release bump only on a release-branch pull request', () => {
const release = {
RELEASE_BUMP: 'true',
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjs
index 5aa416bca3..a8cacdfe43 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -23,7 +23,9 @@
* the commands are checked with each script expanded to its body.
*/
+import {spawnSync} from 'node:child_process';
import fs from 'node:fs';
+import os from 'node:os';
import path from 'node:path';
import {describe, expect, it} from 'vitest';
@@ -365,7 +367,9 @@ describe('ci.yml pr-a11y browser specs', () => {
});
it("runs the merge commit's runner against the PR head", () => {
- expect(run.if).toBe('${{ !cancelled() }}');
+ expect(run.if).toBe(
+ "(!cancelled()) && steps.scope.outputs.has_components == 'true'",
+ );
// The merge commit the steps come from, not the PR's recorded base, which
// can lag main and predate the runner.
expect(run.env.WORKFLOW_SHA).toBe('${{ github.sha }}');
@@ -381,7 +385,9 @@ describe('ci.yml pr-a11y browser specs', () => {
});
it('uploads every spec receipt in one head-bound artifact', () => {
- expect(upload.if).toBe('${{ !cancelled() }}');
+ expect(upload.if).toBe(
+ "(!cancelled()) && steps.scope.outputs.has_components == 'true'",
+ );
expect(upload.with.name).toBe(
'pr-a11y-evidence-${{ needs.build-storybook.outputs.short_hash }}',
);
@@ -402,21 +408,43 @@ describe('ci.yml RTL package sharding', () => {
const shard = workflow.jobs['pr-rtl-shard'];
const join = workflow.jobs['pr-rtl'];
- it('skips component discovery for spec-only changes and classifies other lightweight lanes', () => {
- const classification = workflow.jobs['check-components'];
- expect(classification.if).toContain("github.event_name == 'pull_request'");
- expect(classification.if).toContain(
- "needs.check-scope.outputs.spec_only != 'true'",
- );
- const commands = runLines(classification);
- for (const lane of ['docsite_only', 'tooling_only']) {
- expect(commands).toContain(`needs.check-scope.outputs.${lane}`);
+ it('decides component scope inside each audit job, with no classification job', () => {
+ expect(workflow.jobs['check-components']).toBeUndefined();
+ for (const job of Object.values(workflow.jobs)) {
+ expect(JSON.stringify(job)).not.toContain('needs.check-components');
}
- expect(commands).toContain('has_components=false');
- expect(commands).toContain('has_rtl_components=false');
- expect(commands).toContain('has_rtl_harness=false');
- expect(commands).toContain('force_full_component_audits=false');
- expect(commands).toContain('has_stable_visual=false');
+ // Every job that reads the step's audit outputs asks for them: without
+ // `component-audit`, those outputs are missing and the job would skip its
+ // audits while reporting success.
+ const auditOutput =
+ /steps\.scope\.outputs\.(has_components|has_rtl_components|has_rtl_harness|force_full_component_audits|changed_files_path)/;
+ const readers = Object.entries(workflow.jobs).filter(([, job]) =>
+ auditOutput.test(JSON.stringify(job)),
+ );
+ expect(readers.map(([name]) => name).sort()).toEqual(
+ [
+ 'pr-a11y-guards',
+ 'pr-a11y-specs',
+ 'pr-rtl',
+ 'pr-rtl-merge',
+ 'pr-rtl-shard',
+ 'pr-visual',
+ 'visual-scout',
+ ].sort(),
+ );
+ for (const [name, job] of readers) {
+ const scope = job.steps.find(step => step.id === 'scope');
+ expect(scope.with?.['component-audit'], name).toBe('true');
+ }
+ expect(runLines(shard)).toContain(
+ '--force-full "${{ steps.scope.outputs.force_full_component_audits }}"',
+ );
+ expect(runLines(shard)).toContain(
+ '--has-components "${{ steps.scope.outputs.has_rtl_components }}"',
+ );
+ expect(runLines(shard)).toContain(
+ '--has-harness "${{ steps.scope.outputs.has_rtl_harness }}"',
+ );
});
it('binds component evidence source, Storybook bytes, and RTL code to the PR head', () => {
@@ -510,7 +538,9 @@ describe('ci.yml RTL package sharding', () => {
expect(scope.run).toContain('--manifest rtl-shard-scope.json');
expect(audit.if).toContain("steps.rtl-scope.outputs.should_run == 'true'");
expect(audit['continue-on-error']).toBe(true);
- expect(validation.if).toBe('always()');
+ expect(validation.if).toBe(
+ "always() && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')",
+ );
expect(validation.run).toContain('steps.rtl-scope.outcome');
expect(validation.run).toContain(
'produced no explicit should_run decision',
@@ -526,16 +556,16 @@ describe('ci.yml RTL package sharding', () => {
});
it('keeps pr-rtl as a fail-closed join over every matrix shard', () => {
- expect(join.needs).toEqual(
- expect.arrayContaining(['check-components', 'pr-rtl-shard']),
- );
+ expect(join.needs).toEqual(expect.arrayContaining(['pr-rtl-shard']));
const commands = runLines(join);
- expect(commands).toContain('needs.check-components.result');
expect(commands).toContain('needs.pr-rtl-shard.result');
expect(commands).toContain('.github/scripts/rtl-join.mjs');
expect(commands).toContain('--reports-dir rtl-shard-reports');
expect(commands).toContain(
- '--force-full "${{ needs.check-components.outputs.force_full_component_audits }}"',
+ '--force-full "${{ steps.scope.outputs.force_full_component_audits }}"',
+ );
+ expect(commands).toContain(
+ '--check-components "${{ steps.scope.outcome }}"',
);
const download = join.steps.find(
step => step.name === 'Download applicable RTL shard reports',
@@ -552,13 +582,17 @@ describe('ci.yml RTL package sharding', () => {
const upload = shard.steps.find(
step => step.name === 'Upload RTL shard evidence',
);
- expect(upload.if).toBe('always() && matrix.parts == 1');
+ expect(upload.if).toBe(
+ "(always() && matrix.parts == 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')",
+ );
expect(upload.with.name).toBe('rtl-audit-report-${{ matrix.package }}');
expect(upload.with.path).toContain('rtl-shard-scope.json');
expect(upload.with.path).toContain('rtl-audit-report.json');
expect(upload.with['if-no-files-found']).toBe('error');
const part = shard.steps.find(step => step.name === 'Upload RTL part');
- expect(part.if).toBe('always() && matrix.parts > 1');
+ expect(part.if).toBe(
+ "(always() && matrix.parts > 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')",
+ );
expect(part.with.name).toBe(
'rtl-audit-part-${{ matrix.package }}-${{ matrix.part }}',
);
@@ -819,16 +853,137 @@ describe('scoped browser audits (spec:AST-030 FR9, FR13)', () => {
);
});
- it('scopes the visual classification only on a pull request check-scope scoped', () => {
- const check = stepNamed('Check for component changes');
- expect(check.env.SCOPED).toBe(
- "${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }}",
+ it("scopes the stable visual plan from the PR's own files", () => {
+ const visual = stepNamed('Run the visual gate for the touched components');
+ expect(visual.env.BROAD_STABLE_VISUAL).toBe(
+ '${{ steps.visual-scope.outputs.broad_stable_visual }}',
+ );
+ expect(visual.if).toContain(
+ "steps.visual-scope.outputs.has_stable_visual == 'true'",
+ );
+ const decide = stepNamed('Decide stable visual scope');
+ expect(decide.env.SCOPED).toBe(
+ "${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}",
);
- expect(check.run).toContain(
+ expect(decide.run).toContain(
'if [ "$SCOPED" = true ]; then VISUAL_ARGS=(--scoped); fi',
);
- expect(check.run).toContain(
+ expect(decide.run).toContain(
'visual-scope.mjs --github-output "$GITHUB_OUTPUT" "${VISUAL_ARGS[@]}"',
);
});
});
+
+describe('heavy lanes outside their component scope (spec:AST-030 FR9)', () => {
+ const workflow = load('ci.yml');
+ const RTL =
+ "(steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')";
+ const gates = {
+ 'pr-a11y-guards': "steps.scope.outputs.has_components == 'true'",
+ 'pr-a11y-specs': "steps.scope.outputs.has_components == 'true'",
+ 'pr-rtl-shard': RTL,
+ 'pr-visual': "steps.visual-scope.outputs.has_stable_visual == 'true'",
+ };
+
+ it.each(Object.entries(gates))(
+ '%s downloads the PR analysis only inside its component scope',
+ (name, gate) => {
+ const download = workflow.jobs[name].steps.find(
+ step => step.name === 'Download analysis artifact',
+ );
+ expect(download.if).toContain(gate);
+ },
+ );
+
+ it('installs nothing for the visual jobs outside their visual scope', () => {
+ const scout = workflow.jobs['visual-scout'].steps.find(
+ step => step.name === 'Setup Node and pnpm',
+ );
+ expect(scout.if).toBe(
+ "steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'",
+ );
+ for (const name of ['Setup Node and pnpm', 'Install Playwright']) {
+ const step = workflow.jobs['pr-visual'].steps.find(
+ candidate => candidate.name === name,
+ );
+ expect(step.if, name).toBe(
+ "github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true'",
+ );
+ }
+ });
+
+ it('gives the full visual plan when the file list is unreadable or there is no pull request', () => {
+ const decide = (job, {event, files, specialized = 'false'}) => {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'visual-scope-'));
+ try {
+ const output = path.join(dir, 'output');
+ const filesPath = path.join(dir, 'files');
+ fs.writeFileSync(output, '');
+ fs.writeFileSync(filesPath, files);
+ const step = workflow.jobs[job].steps.find(
+ candidate => candidate.name === 'Decide stable visual scope',
+ );
+ const result = spawnSync(
+ 'bash',
+ ['-e', '-c', step.run.replaceAll('${{ github.event_name }}', event)],
+ {
+ cwd: path.resolve(import.meta.dirname, '../..'),
+ env: {
+ ...process.env,
+ GITHUB_OUTPUT: output,
+ FILES_PATH: filesPath,
+ SCOPED: 'false',
+ SPECIALIZED: specialized,
+ },
+ encoding: 'utf8',
+ },
+ );
+ expect(result.status, result.stderr).toBe(0);
+ return fs.readFileSync(output, 'utf8');
+ } finally {
+ fs.rmSync(dir, {recursive: true, force: true});
+ }
+ };
+ const full = 'has_stable_visual=true\nbroad_stable_visual=true\n';
+ for (const job of ['visual-scout', 'pr-visual']) {
+ expect(decide(job, {event: 'pull_request', files: ''}), job).toBe(full);
+ expect(
+ decide(job, {event: 'workflow_dispatch', files: 'docs/x.md\n'}),
+ job,
+ ).toBe(full);
+ expect(
+ decide(job, {
+ event: 'pull_request',
+ files: 'packages/core/src/Button/Button.tsx\n',
+ specialized: 'true',
+ }),
+ job,
+ ).toBe('has_stable_visual=false\nbroad_stable_visual=false\n');
+ }
+ });
+
+ it('reports no stable visual work on a specialized lane', () => {
+ for (const name of ['visual-scout', 'pr-visual']) {
+ const decide = workflow.jobs[name].steps.find(
+ step => step.name === 'Decide stable visual scope',
+ );
+ expect(decide.env.SPECIALIZED, name).toContain(
+ "steps.scope.outputs.spec_only == 'true'",
+ );
+ const shortCircuit = decide.run.indexOf('"$SPECIALIZED" = true');
+ expect(shortCircuit, name).toBeGreaterThanOrEqual(0);
+ expect(shortCircuit, name).toBeLessThan(
+ decide.run.indexOf('!= pull_request'),
+ );
+ }
+ });
+
+ it('validates spec records whenever docsite-test cannot decide its scope', () => {
+ const validate = workflow.jobs['docsite-test'].steps.find(
+ step => step.name === 'Validate spec records',
+ );
+ expect(validate.if).toBe(
+ "(steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')",
+ );
+ });
+});
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index c0a70ea2b4..869d3d6e50 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -190,7 +190,6 @@ describe('Node-tooling CI routing', () => {
it('preserves the historical joins and fails them on owned-lane failure', () => {
expect(ci.jobs.test.needs).toEqual([
- 'check-scope',
'release-bump',
'test-ui',
'test-node',
@@ -212,7 +211,6 @@ describe('Node-tooling CI routing', () => {
"steps.scope.outputs.spec_only != 'true' || steps.scope.outputs.release_bump == 'true'",
);
expect(testJoin.env).toMatchObject({
- CHECK_SCOPE_RESULT: '${{ needs.check-scope.result }}',
RELEASE_BUMP: '${{ steps.scope.outputs.release_bump }}',
RELEASE_BUMP_RESULT: '${{ needs.release-bump.result }}',
DOCSITE_ONLY: '${{ steps.scope.outputs.docsite_only }}',
diff --git a/.github/scripts/component-audit-scope.test.mjs b/.github/scripts/component-audit-scope.test.mjs
index 10f1f3bc9f..6e3517bbfc 100644
--- a/.github/scripts/component-audit-scope.test.mjs
+++ b/.github/scripts/component-audit-scope.test.mjs
@@ -4,7 +4,6 @@
* @file Mutation-sensitive tests for trusted component-audit scope routing.
*/
-import fs from 'node:fs';
import {createRequire} from 'node:module';
import {describe, expect, it} from 'vitest';
@@ -30,23 +29,6 @@ const NO_COMPONENT_AUDIT_SCOPE = {
};
describe('component audit scope', () => {
- it('loads the classifier and registry from the trusted base ref', () => {
- const workflow = fs.readFileSync(
- new URL('../workflows/ci.yml', import.meta.url),
- 'utf8',
- );
- expect(workflow).toContain(
- 'origin/${{ github.base_ref }}:.github/scripts/component-audit-scope.cjs',
- );
- expect(workflow).toContain(
- 'origin/${{ github.base_ref }}:scripts/component-packages.cjs',
- );
- expect(workflow).toContain(
- 'origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs',
- );
- expect(workflow).toContain('force_full_component_audits=true');
- });
-
it.each([
['packages/core/src/Button/Button.tsx', 'core'],
['packages/lab/src/Stat/Stat.tsx', 'lab'],
diff --git a/.github/scripts/release-check-workflow.test.mjs b/.github/scripts/release-check-workflow.test.mjs
index 7002d615aa..5c8c4168b9 100644
--- a/.github/scripts/release-check-workflow.test.mjs
+++ b/.github/scripts/release-check-workflow.test.mjs
@@ -23,8 +23,7 @@ const packageJson = JSON.parse(
fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'),
);
const releaseJobs = [
- 'check-scope',
- 'check-components',
+ 'release-authority',
'build-storybook',
'typecheck',
'visual-scout',
@@ -98,10 +97,12 @@ function runs(
'always',
'cancelled',
'steps',
+ 'startsWith',
`return Boolean(${expression});`,
)(
{
event_name: event,
+ base_ref: event === 'pull_request' ? 'main' : '',
event: {pull_request: {labels: labels.map(name => ({name}))}},
},
{operation, 'release-branch': branch},
@@ -120,9 +121,14 @@ function runs(
touches: 'true',
applies: 'true',
decided: 'true',
+ has_components: 'true',
+ has_rtl_components: 'true',
+ has_rtl_harness: 'true',
+ force_full_component_audits: 'true',
},
},
},
+ (value, prefix) => String(value ?? '').startsWith(prefix),
);
}
@@ -344,7 +350,7 @@ describe('explicit release routing', () => {
describe('exact main pre-cut authority', () => {
const authority = step(
- 'check-scope',
+ 'release-authority',
'Validate exact main pre-cut authority',
);
@@ -352,7 +358,7 @@ describe('exact main pre-cut authority', () => {
expect(runs(authority, {branch: 'main'})).toBe(true);
expect(runs(authority)).toBe(false);
expect(runs(authority, {branch: 'main', operation: 'capture'})).toBe(false);
- expect(jobs['check-scope'].outputs.release_head).toContain(
+ expect(jobs['release-authority'].outputs.release_head).toContain(
'steps.main-authority.outputs.head',
);
});
@@ -441,8 +447,7 @@ describe('exact main and release branch completion', () => {
githubScript(join, {needs: complete}),
).resolves.toBeUndefined();
expect(jobs['release-check'].needs).toEqual([
- 'check-scope',
- 'check-components',
+ 'release-authority',
'build-storybook',
'typecheck',
'pr-visual',
@@ -559,58 +564,22 @@ describe('exact main and release branch completion', () => {
describe('full release scope without PR metadata or maintenance writes', () => {
it('forces broad scope before any changed-file classification', () => {
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-release-scope-'));
- try {
- for (const [job, name, expected] of [
- [
- 'check-scope',
- 'Determine change scope',
- {
- docsite_only: 'false',
- spec_only: 'false',
- tooling_only: 'false',
- full_suite: 'true',
- release_bump: 'false',
- },
- ],
- [
- 'check-components',
- 'Check for component changes',
- Object.fromEntries(
- Object.entries(fullOutputs).filter(
- ([key]) => !key.endsWith('_only'),
- ),
- ),
- ],
- ]) {
- const output = path.join(dir, `${job}.txt`);
- const script = step(job, name).run.replaceAll(
- '${{ github.event_name }}',
- 'workflow_dispatch',
- );
- const result = shell(
- script,
- {
- GITHUB_OUTPUT: output,
- ...(job === 'check-scope'
- ? {EVENT_NAME: 'workflow_dispatch', BASE_REF: ''}
- : {}),
- },
- 'git() { echo "must not inspect changed files" >&2; return 99; }',
- );
- expect(result.status, result.stderr).toBe(0);
- expect(
- Object.fromEntries(
- fs
- .readFileSync(output, 'utf8')
- .trim()
- .split('\n')
- .map(line => line.split('=')),
- ),
- ).toEqual(expected);
+ // No release job classifies changed files: the authority job has no
+ // classifier, and every job with a scope step runs the scope action,
+ // which puts everything in scope outside a pull request
+ // (test-scope-action.test.mjs).
+ expect(
+ jobs['release-authority'].steps.some(item => item.id === 'scope'),
+ ).toBe(false);
+ for (const job of releaseJobs) {
+ for (const item of jobs[job].steps ?? []) {
+ if (item.id === 'scope') {
+ expect(item.uses, job).toBe(
+ './.test-scope/.github/actions/test-scope',
+ );
+ expect(item.with?.['outside-pull-request'], job).not.toBe('skip');
+ }
}
- } finally {
- fs.rmSync(dir, {recursive: true, force: true});
}
});
@@ -737,7 +706,7 @@ describe('full release scope without PR metadata or maintenance writes', () => {
});
it('clones full history only where the release-branch validator reads it', () => {
- const checkout = jobs['check-scope'].steps.find(step =>
+ const checkout = jobs['release-authority'].steps.find(step =>
step.uses?.startsWith('actions/checkout@'),
);
const expression = String(checkout.with['fetch-depth']).replace(
@@ -756,9 +725,7 @@ describe('full release scope without PR metadata or maintenance writes', () => {
(value, prefix) => String(value).startsWith(prefix),
);
expect(depth('workflow_dispatch', releaseBranch)).toBe('0');
- expect(depth('pull_request', '', 'release/v0.6.5')).toBe('0');
expect(depth('workflow_dispatch', 'main')).toBe('50');
- expect(depth('pull_request', '', 'main')).toBe('50');
});
it('keeps exhaustive a11y contracts and their artifacts release-only', () => {
@@ -845,14 +812,15 @@ describe('full release scope without PR metadata or maintenance writes', () => {
jobs['pr-rtl-shard'].strategy.matrix.include.map(leg => leg.package),
),
]).toEqual(['core', 'lab', 'charts', 'richtext', 'vega']);
+ // Outside a pull request the scope step reports full scope.
expect(step('pr-rtl-shard', 'Resolve RTL shard scope').run).toContain(
- '--force-full "${{ needs.check-components.outputs.force_full_component_audits }}"',
+ '--force-full "${{ steps.scope.outputs.force_full_component_audits }}"',
);
expect(step('pr-rtl', 'Require every applicable RTL shard').run).toContain(
- '--force-full "${{ needs.check-components.outputs.force_full_component_audits }}"',
+ '--force-full "${{ steps.scope.outputs.force_full_component_audits }}"',
);
expect(step('pr-rtl-shard', 'Require completed RTL shard report').if).toBe(
- 'always()',
+ "always() && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')",
);
expect(step('pr-rtl-shard', 'Run RTL audit')['continue-on-error']).toBe(
true,
diff --git a/.github/scripts/release-publish-workflow.test.mjs b/.github/scripts/release-publish-workflow.test.mjs
index f6fb3c4cbb..73487339f1 100644
--- a/.github/scripts/release-publish-workflow.test.mjs
+++ b/.github/scripts/release-publish-workflow.test.mjs
@@ -41,7 +41,7 @@ describe('stable and canary publication authority', () => {
expect(gateInputs['release-version']).toBeDefined();
expect(gateInputs['plan-digest']).toBeDefined();
const gate = step(
- ci.jobs['check-scope'],
+ ci.jobs['release-authority'],
'Validate active release authority',
).run;
expect(gate).toContain('--release-version "$RELEASE_VERSION"');
diff --git a/.github/scripts/rtl-join.mjs b/.github/scripts/rtl-join.mjs
index 02166d97c4..39ba443b00 100644
--- a/.github/scripts/rtl-join.mjs
+++ b/.github/scripts/rtl-join.mjs
@@ -158,10 +158,18 @@ export function evaluateRtlJoin({
message: 'All applicable RTL package shards produced reports.',
};
}
- return shardResult === 'skipped'
+ // Out of scope, each shard job either did not start or decided its own
+ // scope and did no work, reporting success with no manifest or report. The
+ // shard and merge jobs can land on different sides (`skipped/success`).
+ const parts = String(shardResult ?? '').split('/');
+ const noOpShards =
+ parts.every(part => part === 'skipped' || part === 'success') &&
+ evidence.scopes.length === 0 &&
+ evidence.reports.length === 0;
+ return shardResult === 'skipped' || noOpShards
? {
ok: true,
- message: 'No RTL-owned scope; package shards correctly skipped.',
+ message: 'No RTL-owned scope; package shards did no RTL work.',
}
: {
ok: false,
diff --git a/.github/scripts/rtl-join.test.mjs b/.github/scripts/rtl-join.test.mjs
index c7ca535279..dbe8a5ba28 100644
--- a/.github/scripts/rtl-join.test.mjs
+++ b/.github/scripts/rtl-join.test.mjs
@@ -82,7 +82,7 @@ describe('RTL matrix join', () => {
}),
).toEqual({
ok: true,
- message: 'No RTL-owned scope; package shards correctly skipped.',
+ message: 'No RTL-owned scope; package shards did no RTL work.',
});
expect(
evaluateRtlJoin({
@@ -99,12 +99,40 @@ describe('RTL matrix join', () => {
shouldRun: false,
}).ok,
).toBe(false);
+ // Shards that decided their own scope and did nothing succeed with no
+ // manifest or report; any RTL output from them is unexpected.
expect(
evaluateRtlJoin({
checkComponentsResult: 'success',
shardResult: 'success',
shouldRun: false,
}).ok,
+ ).toBe(true);
+ expect(
+ evaluateRtlJoin({
+ checkComponentsResult: 'success',
+ shardResult: 'success',
+ shouldRun: false,
+ evidence: completeEvidence(),
+ }).ok,
+ ).toBe(false);
+ // The shard and merge jobs can land on different sides of the no-op.
+ for (const shardResult of ['skipped/success', 'success/skipped']) {
+ expect(
+ evaluateRtlJoin({
+ checkComponentsResult: 'success',
+ shardResult,
+ shouldRun: false,
+ }).ok,
+ shardResult,
+ ).toBe(true);
+ }
+ expect(
+ evaluateRtlJoin({
+ checkComponentsResult: 'success',
+ shardResult: 'skipped/failure',
+ shouldRun: false,
+ }).ok,
).toBe(false);
});
diff --git a/.github/scripts/spec-owner-workflow.test.mjs b/.github/scripts/spec-owner-workflow.test.mjs
index 2c674c80b0..f80c01f747 100644
--- a/.github/scripts/spec-owner-workflow.test.mjs
+++ b/.github/scripts/spec-owner-workflow.test.mjs
@@ -135,12 +135,9 @@ describe('spec-only workflow contract', () => {
"steps.scope.outputs.spec_only != 'true'",
);
}
- // The heavy lanes still read check-scope until they decide their own scope.
- for (const job of ['check-components', 'pr-rtl']) {
- expect(jobBlock(job), job).toContain(
- "needs.check-scope.outputs.spec_only != 'true'",
- );
- }
+ // No job reads a scope job any more.
+ expect(ci).not.toContain('needs.check-scope');
+ expect(ci).not.toContain('needs.check-components');
expect(jobBlock('build')).toContain(
"needs.build-storybook.result != 'skipped'",
);
diff --git a/.github/scripts/test-scope-action.test.mjs b/.github/scripts/test-scope-action.test.mjs
index 71c309026b..d87010c59f 100644
--- a/.github/scripts/test-scope-action.test.mjs
+++ b/.github/scripts/test-scope-action.test.mjs
@@ -39,6 +39,7 @@ const CLASSIFIER_FILES = new Set([
'.github/scripts/knowledge-paths.cjs',
'scripts/component-packages.cjs',
]);
+const AUDIT_FILE = '.github/scripts/component-audit-scope.cjs';
function pullRequestContext(baseRef = 'main') {
return {
@@ -66,6 +67,7 @@ async function decide({
headFiles = [],
headError,
missingBase = [],
+ baseOverrides = {},
} = {}) {
const outputs = {};
const messages = {info: [], warning: [], notice: [], failed: []};
@@ -90,8 +92,18 @@ async function decide({
repos: {
getContent: async ({path: file, ref}) => {
contentCalls.push({file, ref});
- if (ref === BASE_SHA && CLASSIFIER_FILES.has(file)) {
+ if (
+ ref === BASE_SHA &&
+ (CLASSIFIER_FILES.has(file) || file === AUDIT_FILE)
+ ) {
if (missingBase.includes(file)) throw notFound();
+ if (file in baseOverrides) {
+ return {
+ data: {
+ content: Buffer.from(baseOverrides[file]).toString('base64'),
+ },
+ };
+ }
return {
data: {
content: fs
@@ -115,6 +127,7 @@ async function decide({
SCOPE_PATHS: inputs.paths ?? '',
SCOPE_OUTSIDE_PR: inputs['outside-pull-request'] ?? 'run',
SCOPE_HEAD_FILE: inputs['requires-head-file'] ?? '',
+ SCOPE_COMPONENT_AUDIT: inputs['component-audit'] ?? 'false',
};
const saved = {...process.env};
Object.assign(process.env, env);
@@ -145,9 +158,14 @@ describe('per-job scope step', () => {
expect(Object.keys(action.outputs).sort()).toEqual(
[
'applies',
+ 'changed_files_path',
'decided',
'docsite_only',
+ 'force_full_component_audits',
'full_suite',
+ 'has_components',
+ 'has_rtl_components',
+ 'has_rtl_harness',
'release_bump',
'spec_only',
'tooling_only',
@@ -358,4 +376,94 @@ describe('per-job scope step', () => {
expect(outputs.applies).toBe('true');
});
});
+
+ describe('component-audit', () => {
+ const inputs = {'component-audit': 'true'};
+
+ it('runs every audit in full outside a pull request', async () => {
+ const {outputs} = await decide({
+ context: {
+ eventName: 'workflow_dispatch',
+ repo: {owner: 'o', repo: 'r'},
+ },
+ inputs,
+ });
+ expect(outputs).toMatchObject({
+ has_components: 'true',
+ has_rtl_components: 'true',
+ has_rtl_harness: 'true',
+ force_full_component_audits: 'true',
+ });
+ });
+
+ it('classifies a component change with the base classifier and lists its files', async () => {
+ const {outputs, contentCalls} = await decide({
+ files: changed('packages/core/src/Button/Button.tsx'),
+ inputs,
+ });
+ expect(outputs).toMatchObject({
+ has_components: 'true',
+ has_rtl_components: 'true',
+ force_full_component_audits: 'false',
+ });
+ // The list goes through a file: it can outgrow an environment variable.
+ expect(fs.readFileSync(outputs.changed_files_path, 'utf8')).toBe(
+ 'packages/core/src/Button/Button.tsx\n',
+ );
+ expect(contentCalls).toContainEqual({file: AUDIT_FILE, ref: BASE_SHA});
+ });
+
+ it('applies no audit to a release-branch pull request', async () => {
+ const {outputs} = await decide({
+ context: pullRequestContext('release/v1.2.3'),
+ inputs,
+ });
+ expect(outputs).toMatchObject({
+ has_components: 'false',
+ has_rtl_components: 'false',
+ has_rtl_harness: 'false',
+ force_full_component_audits: 'false',
+ });
+ });
+
+ it('applies no audit on a specialized lane', async () => {
+ const {outputs} = await decide({
+ files: changed('docs/specs/AST-030/spec.md'),
+ inputs,
+ });
+ expect(outputs).toMatchObject({
+ has_components: 'false',
+ has_rtl_components: 'false',
+ has_rtl_harness: 'false',
+ force_full_component_audits: 'false',
+ });
+ });
+
+ it('runs every audit in full when the base lacks the audit classifier', async () => {
+ const {outputs, messages} = await decide({
+ files: changed('packages/core/src/Button/Button.tsx'),
+ inputs,
+ missingBase: [AUDIT_FILE],
+ });
+ expect(outputs.force_full_component_audits).toBe('true');
+ expect(messages.warning).toHaveLength(1);
+ });
+
+ it('runs every audit in full when the audit classifier fails', async () => {
+ const {outputs, messages} = await decide({
+ files: changed('packages/core/src/Button/Button.tsx'),
+ inputs,
+ baseOverrides: {[AUDIT_FILE]: 'process.exit(3);\n'},
+ });
+ expect(outputs).toMatchObject({
+ has_components: 'true',
+ has_rtl_components: 'true',
+ has_rtl_harness: 'true',
+ force_full_component_audits: 'true',
+ });
+ expect(messages.warning).toEqual([
+ expect.stringContaining('Component audit scope could not be decided'),
+ ]);
+ });
+ });
});
diff --git a/.github/scripts/visual-gate/workflow-concurrency.test.mjs b/.github/scripts/visual-gate/workflow-concurrency.test.mjs
index 388d3d9eb7..9417f7a23a 100644
--- a/.github/scripts/visual-gate/workflow-concurrency.test.mjs
+++ b/.github/scripts/visual-gate/workflow-concurrency.test.mjs
@@ -150,7 +150,7 @@ describe('PR report and deployment workflow contracts', () => {
value.indexOf(' pr-rtl-shard:'),
);
expect(visual).toContain(
- '[build-storybook, check-components, maintenance-request, visual-scout]',
+ '[build-storybook, maintenance-request, visual-scout]',
);
expect(visual).toContain(
'name: storybook-${{ needs.build-storybook.outputs.short_hash }}',
diff --git a/.github/scripts/visual-maintenance-workflow.test.mjs b/.github/scripts/visual-maintenance-workflow.test.mjs
index c329b9ccc0..344258cce8 100644
--- a/.github/scripts/visual-maintenance-workflow.test.mjs
+++ b/.github/scripts/visual-maintenance-workflow.test.mjs
@@ -119,16 +119,14 @@ describe('CI baseline maintenance routing', () => {
expect(runs(visual, {needs})).toBe(false);
});
- it('preserves focused PR routing on an opted-in pull request when the maintenance guard is skipped', () => {
+ it('runs on an opted-in pull request when the maintenance guard is skipped', () => {
const needs = dependencies(visual);
needs['maintenance-request'].result = 'skipped';
const optedIn = {event: 'pull_request', needs, labels: ['ci:heavy-lanes']};
+ // The job decides its stable visual scope in its own steps.
expect(runs(visual, optedIn)).toBe(true);
// Without the opt-in label a pull request update runs no visual owner.
expect(runs(visual, {event: 'pull_request', needs})).toBe(false);
- needs['check-components'].outputs.has_stable_visual = 'false';
- expect(runs(visual, optedIn)).toBe(false);
- needs['check-components'].outputs.has_stable_visual = 'true';
needs['build-storybook'].result = 'failure';
expect(runs(visual, optedIn)).toBe(false);
expect(runs(visual, {event: 'merge_group', needs})).toBe(false);
@@ -173,7 +171,10 @@ describe('canonical capture and checked-in baseline separation', () => {
expect(capture.run).not.toMatch(
/--(?:sample|only|components|themes|max-shots|tiers)\b/,
);
- expect(visual.permissions).toEqual({contents: 'read'});
+ expect(visual.permissions).toEqual({
+ contents: 'read',
+ 'pull-requests': 'read',
+ });
});
it('keeps browser-refresh capture reachable, but only uploads validated full captures', () => {
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fcfa022ba5..b37f423d66 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -50,6 +50,11 @@ permissions: {}
# `ci-duration` reports each job's run time and the run's span. Split a job
# that nears the limit (shard, scope, cache); do not raise it.
#
+# There is no scope job. Each job that owns tests decides its own scope in its
+# first steps (.github/actions/test-scope: the PR's file list against the
+# base's trusted classifier) and skips its work, reporting success, when
+# nothing in its scope changed; anything undecidable runs everything.
+#
# Visual, accessibility and RTL owners (pr-a11y*, visual-scout, pr-visual,
# pr-rtl*) do not run on pull request updates: they run for release-check,
# which the Main heavy lanes workflow (main-heavy-lanes.yml) dispatches on every
@@ -63,8 +68,7 @@ permissions: {}
# (chore/merge-v*), and the build and audit jobs of a release-check a person or
# the release tooling dispatches (one dispatched by github-actions[bot] stays
# on standard runners). The release-check's short gating and join jobs
-# (check-scope, check-components, pr-a11y, a11y-contracts, pr-rtl,
-# release-check) stay on ubuntu-slim. Arm jobs stay arm and x64 stay x64 on
+# (release-authority, pr-a11y, a11y-contracts, pr-rtl, release-check) stay on ubuntu-slim. Arm jobs stay arm and x64 stay x64 on
# both pools, so visual baselines and native builds see the same architecture.
#
# One group per pull request (a fork's branch name can repeat across forks),
@@ -89,48 +93,36 @@ jobs:
exit 1
fi
- # Detect lightweight changes. Missing merge-base data fails closed.
- check-scope:
- 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')
+ # The release authority for an explicit release check: the active release
+ # marker, or the exact main pre-cut head, that the canonical checks bind to.
+ # Pull requests never run it: a release-branch pull request validates its
+ # own bump in release-bump, and every test job decides its own scope.
+ release-authority:
+ if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
runs-on: ubuntu-slim
permissions:
contents: read
outputs:
- docsite_only: ${{ steps.scope.outputs.docsite_only }}
- spec_only: ${{ steps.scope.outputs.spec_only }}
- tooling_only: ${{ steps.scope.outputs.tooling_only }}
- # 'false' only for a pull request whose changes the import graph can
- # scope (components, shared modules, docs, records). Anything else, an
- # empty value included, runs the full suite: main, release branches,
- # the merge queue, release-check dispatches, and shared infrastructure
- # (build and test config, the test harness, tokens, themes, root
- # dependencies, CI itself).
- full_suite: ${{ steps.scope.outputs.full_suite }}
- release_bump: ${{ steps.scope.outputs.release_bump }}
release_branch: ${{ steps.release-authority.outputs.branch || steps.main-authority.outputs.branch }}
release_head: ${{ steps.release-authority.outputs.head || steps.main-authority.outputs.head }}
release_plan_digest: ${{ steps.release-authority.outputs.planDigest }}
steps:
# Full history only where the release-branch validator reads it (tags,
- # the cut commit, release diffs). A PR's merge commit has the base tip
- # as a parent, and a main pre-cut check fetches current main on top, so
- # 50 commits are plenty there; the full clone took over a minute.
+ # the cut commit, release diffs). A main pre-cut check fetches current
+ # main on top, so 50 commits are plenty there; the full clone took over
+ # a minute.
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
- fetch-depth: ${{ ((github.event_name == 'workflow_dispatch' && inputs['release-branch'] != 'main') || (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v'))) && '0' || '50' }}
+ fetch-depth: ${{ inputs['release-branch'] != 'main' && '0' || '50' }}
- name: Fetch active release refs
- if: >-
- (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && inputs['release-branch'] != 'main') ||
- (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v'))
+ if: inputs['release-branch'] != 'main'
run: git fetch origin '+refs/heads/release/v*:refs/remotes/origin/release/v*'
- name: Validate active release authority
id: release-authority
- if: >-
- (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && inputs['release-branch'] != 'main') ||
- (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release/v'))
+ if: inputs['release-branch'] != 'main'
env:
RELEASE_BRANCH: ${{ github.event_name == 'workflow_dispatch' && inputs['release-branch'] || github.base_ref }}
RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs['release-version'] || '' }}
@@ -200,55 +192,10 @@ jobs:
fi
printf 'branch=main\nhead=%s\n' "$EXPECTED_HEAD" >> "$GITHUB_OUTPUT"
- - name: Fetch base branch
- if: github.event_name == 'pull_request'
- run: git fetch origin ${{ github.base_ref }} --depth=50
-
- - name: Determine change scope
- id: scope
- env:
- EVENT_NAME: ${{ github.event_name }}
- BASE_REF: ${{ github.base_ref }}
- run: |
- if [ "$EVENT_NAME" != pull_request ]; then
- printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\nrelease_bump=false\n' >> "$GITHUB_OUTPUT"
- exit 0
- fi
- if [[ "$BASE_REF" == release/v* ]]; then
- # Release bump PRs contain generated bookkeeping only. The final
- # branch head receives one full visual/a11y/RTL release-check.
- printf 'docsite_only=false\nspec_only=true\ntooling_only=true\nfull_suite=true\nrelease_bump=true\n' >> "$GITHUB_OUTPUT"
- exit 0
- fi
- MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null || echo "")
- if [ -z "$MERGE_BASE" ]; then
- printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\nrelease_bump=false\n' >> "$GITHUB_OUTPUT"
- exit 0
- fi
- echo 'release_bump=false' >> "$GITHUB_OUTPUT"
- CLASSIFIER_ROOT="$RUNNER_TEMP/change-scope"
- CLASSIFIER_DIR="$CLASSIFIER_ROOT/.github/scripts"
- REGISTRY_DIR="$CLASSIFIER_ROOT/scripts"
- mkdir -p "$CLASSIFIER_DIR" "$REGISTRY_DIR"
- CLASSIFIER="$CLASSIFIER_DIR/change-scope.cjs"
- MATCHER="$CLASSIFIER_DIR/knowledge-paths.cjs"
- REGISTRY="$REGISTRY_DIR/component-packages.cjs"
- if git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs" > "$CLASSIFIER" 2>/dev/null \
- && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$MATCHER" 2>/dev/null \
- && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then
- git diff --name-status "$MERGE_BASE"...HEAD \
- | node "$CLASSIFIER" --github-output
- else
- # Missing trusted policy or dependencies cannot grant a specialized
- # lane. Run broad CI until the base branch supplies the full classifier.
- printf 'docsite_only=false\nspec_only=false\ntooling_only=false\nfull_suite=true\n' \
- >> "$GITHUB_OUTPUT"
- fi
# Generated-only version PR lane. It validates release bookkeeping in a few
# minutes; the merged branch head receives one full visual/a11y/RTL projection.
release-bump:
- needs: [check-scope]
- if: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.release_bump == 'true' }}
+ 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 == 'pull_request' && startsWith(github.base_ref, 'release/v')) }}
runs-on: 2-core-ubuntu-arm
timeout-minutes: 15
permissions:
@@ -589,95 +536,6 @@ jobs:
if-no-files-found: error
retention-days: 7
- # Lightweight check — does the PR touch any published components?
- # Gates pr-a11y and pr-rtl to avoid unnecessary work.
- #
- # `scripts/component-packages.cjs` owns the component source roots used here
- # and by the RTL roster. `analyze-pr.js` still decides which changed components
- # each downstream audit receives. When those projections disagree the audits
- # silently no-op, so harness/registry changes also exercise the RTL smoke scope.
- # Spec-only changes keep only the trusted scope classifier and the
- # knowledge validator below. Unrelated component discovery must not take a
- # runner or fan out into visual, accessibility, or RTL work.
- check-components:
- needs: [check-scope]
- if: (github.event_name == 'pull_request' && needs.check-scope.outputs.spec_only != 'true') || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')
- runs-on: ubuntu-slim
- permissions:
- contents: read
- outputs:
- has_components: ${{ steps.check.outputs.has_components }}
- has_rtl_components: ${{ steps.check.outputs.has_rtl_components }}
- has_rtl_harness: ${{ steps.check.outputs.has_rtl_harness }}
- force_full_component_audits: ${{ steps.check.outputs.force_full_component_audits }}
- # Stable visual scope is separate from component scope: Core and the
- # non-private shipped themes participate; canaryOnly packages do not.
- has_stable_visual: ${{ steps.check.outputs.has_stable_visual }}
- broad_stable_visual: ${{ steps.check.outputs.broad_stable_visual }}
- steps:
- - name: Checkout
- uses: actions/checkout@v7
- with:
- # Depth 50 (same as check-scope) so the three-dot diff below can find
- # a merge base. With the default depth of 1 the diff fails with
- # "no merge base", the error is swallowed by the pipeline, and
- # has_components silently becomes false — skipping pr-a11y entirely.
- fetch-depth: 50
-
- - name: Fetch base branch
- if: github.event_name == 'pull_request'
- run: git fetch origin ${{ github.base_ref }} --depth=50
-
- - name: Check for component changes
- id: check
- env:
- SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }}
- run: |
- if [ "${{ github.event_name }}" = 'workflow_dispatch' ]; then
- printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\nhas_stable_visual=true\nbroad_stable_visual=true\n' >> "$GITHUB_OUTPUT"
- exit 0
- fi
- if [ "${{ needs.check-scope.outputs.docsite_only }}" = "true" ] \
- || [ "${{ needs.check-scope.outputs.spec_only }}" = "true" ] \
- || [ "${{ needs.check-scope.outputs.tooling_only }}" = "true" ]; then
- printf 'has_components=false\nhas_rtl_components=false\nhas_rtl_harness=false\nforce_full_component_audits=false\nhas_stable_visual=false\n' >> "$GITHUB_OUTPUT"
- echo "Trusted specialized lane — component audits explicitly not applicable."
- exit 0
- fi
- if ! MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null); then
- echo "::warning::No merge base between HEAD and origin/${{ github.base_ref }} — running full component audits"
- printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\n' >> "$GITHUB_OUTPUT"
- echo "has_stable_visual=true" >> "$GITHUB_OUTPUT"
- echo "broad_stable_visual=true" >> "$GITHUB_OUTPUT"
- exit 0
- fi
-
- POLICY_ROOT="$RUNNER_TEMP/component-audit-scope"
- mkdir -p "$POLICY_ROOT/.github/scripts" "$POLICY_ROOT/scripts"
- SCOPE="$POLICY_ROOT/.github/scripts/component-audit-scope.cjs"
- REGISTRY="$POLICY_ROOT/scripts/component-packages.cjs"
- if git show "origin/${{ github.base_ref }}:.github/scripts/component-audit-scope.cjs" > "$SCOPE" 2>/dev/null \
- && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$POLICY_ROOT/.github/scripts/knowledge-paths.cjs" 2>/dev/null \
- && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then
- git diff --name-status "$MERGE_BASE"...HEAD \
- | node "$SCOPE" --registry "$REGISTRY" --github-output
- else
- echo "::warning::Trusted component audit policy is unavailable — running full component audits"
- printf 'has_components=true\nhas_rtl_components=true\nhas_rtl_harness=true\nforce_full_component_audits=true\n' >> "$GITHUB_OUTPUT"
- fi
-
- FILES=$(git diff --name-only "$MERGE_BASE"...HEAD)
-
- # One classifier owns the release-channel rule. It reads each
- # package's `astryx.canaryOnly` metadata rather than hard-coding
- # today's Lab/charts/richtext/vega list.
- # A pull request that runs what it reaches audits a shared Core
- # module through its reverse dependents (spec:AST-030 FR13).
- VISUAL_ARGS=()
- if [ "$SCOPED" = true ]; then VISUAL_ARGS=(--scoped); fi
- printf '%s\n' "$FILES" \
- | node .github/scripts/visual-scope.mjs --github-output "$GITHUB_OUTPUT" "${VISUAL_ARGS[@]}"
-
# Tests run as two parallel lanes joined by `test` below.
#
# They used to be one `pnpm test` on a 2-core runner, which ran both Vitest
@@ -1044,7 +902,6 @@ jobs:
test:
needs:
[
- check-scope,
release-bump,
test-ui,
test-node,
@@ -1086,9 +943,6 @@ jobs:
- name: Require expected test-owner outcomes
if: steps.scope.outputs.spec_only != 'true' || steps.scope.outputs.release_bump == 'true'
env:
- # check-scope still gates the heavy lanes and release-check; the
- # join fails when it does not succeed.
- CHECK_SCOPE_RESULT: ${{ needs.check-scope.result }}
RELEASE_BUMP: ${{ steps.scope.outputs.release_bump }}
RELEASE_BUMP_RESULT: ${{ needs.release-bump.result }}
DOCSITE_ONLY: ${{ steps.scope.outputs.docsite_only }}
@@ -1472,8 +1326,8 @@ jobs:
# pr-a11y itself, so neither runs there.
pr-a11y-shard:
name: pr-a11y (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [build-storybook, check-components]
- if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true'
+ needs: [build-storybook]
+ if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
strategy:
fail-fast: false
matrix:
@@ -1521,8 +1375,8 @@ jobs:
pr-a11y-audit:
name: pr-a11y (full audit)
- needs: [build-storybook, check-components, pr-a11y-shard]
- if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' }}
+ needs: [build-storybook, pr-a11y-shard]
+ if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' }}
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' }}
permissions:
contents: read
@@ -1578,20 +1432,37 @@ jobs:
pr-a11y-guards:
name: pr-a11y (audit and guards)
- needs: [build-storybook, check-components]
- if: ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true'
+ needs: [build-storybook]
+ if: ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))
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:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Verify evidence checkout
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && steps.scope.outputs.has_components == 'true'
env:
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA"
@@ -1599,22 +1470,26 @@ jobs:
# Dependencies are installed later, together with the Playwright browser,
# because the analysis artifact has to be downloaded first.
- name: Setup Node and pnpm
+ if: steps.scope.outputs.has_components == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download analysis artifact
+ if: steps.scope.outputs.has_components == 'true'
uses: actions/download-artifact@v8
with:
name: pr-analysis
- name: Download Storybook artifact
+ if: steps.scope.outputs.has_components == 'true'
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
path: apps/storybook/dist
- name: Install Playwright
+ if: steps.scope.outputs.has_components == 'true'
run: pnpm install --frozen-lockfile && npx playwright install chromium
# Fails on axe violations not present in the checked-in baseline
@@ -1623,7 +1498,7 @@ jobs:
# Release checks scan the full roster in pr-a11y-shard and gate it in
# pr-a11y-audit; this job keeps the scoped PR audit and the guards.
- name: Run accessibility audit
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && steps.scope.outputs.has_components == 'true'
run: |
SCOPE_ARGS=()
if [ "${{ github.event_name }}" = 'pull_request' ]; then
@@ -1644,7 +1519,7 @@ jobs:
# if: always() so the report artifact (and the PR comment built from it)
# still exists when the gate above fails.
- name: Upload a11y artifact
- if: always() && github.event_name == 'pull_request'
+ if: (always() && github.event_name == 'pull_request') && steps.scope.outputs.has_components == 'true'
uses: actions/upload-artifact@v7
with:
name: a11y-report
@@ -1657,6 +1532,7 @@ jobs:
# and this Chromium probe is the guard. Runs after the upload above so an
# a11y failure still publishes its report.
- name: Run modal close visibility guard
+ if: steps.scope.outputs.has_components == 'true'
run: node .github/scripts/modal-close-visibility.js --storybook-dir apps/storybook/dist
# A public component var can be documented, read, and emitted into the
@@ -1667,6 +1543,7 @@ jobs:
# checkable. The source-side wiring half lives in
# packages/cli/foundation/discovery/theming-targets.test.mjs.
- name: Run theme var reachability guard
+ if: steps.scope.outputs.has_components == 'true'
run: node .github/scripts/theme-var-reachability.js --storybook-dir apps/storybook/dist
# A story play function is where geometry assertions live (they need
@@ -1677,6 +1554,7 @@ jobs:
# throw. Hosted here with the sibling Chromium guards because pr-a11y is
# the blocking job that runs whenever components change.
- name: Run story play guard
+ if: steps.scope.outputs.has_components == 'true'
run: node .github/scripts/story-play-guard.js --storybook-dir apps/storybook/dist
# Browser accessibility specs get their own budget. The scoped axe sweep and
@@ -1685,41 +1563,62 @@ jobs:
# inside the budget without weakening the stable pr-a11y join.
pr-a11y-specs:
name: pr-a11y (browser specs)
- needs: [build-storybook, check-components]
- if: ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true'
+ needs: [build-storybook]
+ if: ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))
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:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Verify evidence checkout
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && steps.scope.outputs.has_components == 'true'
env:
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA"
- name: Setup Node and pnpm
+ if: steps.scope.outputs.has_components == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download analysis artifact
+ if: steps.scope.outputs.has_components == 'true'
uses: actions/download-artifact@v8
with:
name: pr-analysis
- name: Download Storybook artifact
+ if: steps.scope.outputs.has_components == 'true'
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
path: apps/storybook/dist
- name: Install Playwright
+ if: steps.scope.outputs.has_components == 'true'
run: pnpm install --frozen-lockfile && npx playwright install chromium
# The runner runs every spec playwright.config.ts matches whose own
@@ -1727,7 +1626,7 @@ jobs:
# routing lines come from the merge commit these steps come from, so an
# older PR head is routed by current policy while specs run at that head.
- name: Run browser accessibility specs
- if: ${{ !cancelled() }}
+ if: (!cancelled()) && steps.scope.outputs.has_components == 'true'
env:
ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
@@ -1740,7 +1639,7 @@ jobs:
node "$runner"
- name: Upload browser accessibility evidence
- if: ${{ !cancelled() }}
+ if: (!cancelled()) && steps.scope.outputs.has_components == 'true'
uses: actions/upload-artifact@v7
with:
name: pr-a11y-evidence-${{ needs.build-storybook.outputs.short_hash }}
@@ -1754,8 +1653,8 @@ jobs:
# Stable required context joining the scoped audit/guards and browser specs.
pr-a11y:
- needs: [check-components, pr-a11y-guards, pr-a11y-specs]
- 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'))) && (always() && ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) && needs.check-components.outputs.has_components == 'true') }}
+ needs: [pr-a11y-guards, pr-a11y-specs]
+ 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'))) && (always() && ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))) }}
runs-on: ubuntu-slim
timeout-minutes: 5
permissions:
@@ -1777,8 +1676,8 @@ jobs:
# pr-a11y.
a11y-contracts-shard:
name: Accessibility spec-test contracts (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [build-storybook, check-components]
- if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true'
+ needs: [build-storybook]
+ if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
strategy:
fail-fast: false
matrix:
@@ -1856,8 +1755,8 @@ jobs:
# produced fails the merge, as the single job's upload used to fail.
a11y-contracts:
name: Accessibility spec-test contracts
- needs: [build-storybook, check-components, a11y-contracts-shard]
- if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' }}
+ needs: [build-storybook, a11y-contracts-shard]
+ if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' }}
runs-on: ubuntu-slim
permissions: {}
steps:
@@ -2066,14 +1965,11 @@ jobs:
# joins them only when every shard succeeded, and otherwise scouts inline.
visual-scout:
name: Stable visual scout (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [build-storybook, check-components]
+ needs: [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'))) && (!cancelled() &&
needs.build-storybook.result == 'success' &&
- needs.check-components.result == 'success' &&
- (((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) &&
- needs.check-components.outputs.has_stable_visual == 'true' &&
- needs.check-components.outputs.broad_stable_visual == 'true') ||
+ ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) ||
(github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')))
# Five legs: at three, each leg's scout took ~4.5 minutes and the visual
# regression waited for the slowest one.
@@ -2087,16 +1983,58 @@ jobs:
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }}
permissions:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
+ # Stable visual scope: Core and the non-private shipped themes take
+ # part; canaryOnly packages do not. A pull request the import graph can
+ # scope audits the changed components and their reverse dependents
+ # (spec:AST-030 FR13).
+ - name: Decide stable visual scope
+ id: visual-scope
+ env:
+ FILES_PATH: ${{ steps.scope.outputs.changed_files_path }}
+ SCOPED: ${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}
+ SPECIALIZED: ${{ steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.tooling_only == 'true' }}
+ run: |
+ if [ "$SPECIALIZED" = true ]; then
+ printf 'has_stable_visual=false\nbroad_stable_visual=false\n' >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ if [ "${{ github.event_name }}" != pull_request ] || [ ! -s "$FILES_PATH" ]; then
+ printf 'has_stable_visual=true\nbroad_stable_visual=true\n' >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ VISUAL_ARGS=()
+ if [ "$SCOPED" = true ]; then VISUAL_ARGS=(--scoped); fi
+ node .github/scripts/visual-scope.mjs --github-output "$GITHUB_OUTPUT" "${VISUAL_ARGS[@]}" < "$FILES_PATH"
+
- name: Setup Node and pnpm
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download Storybook artifact
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
@@ -2105,6 +2043,7 @@ jobs:
# The artifact carries the themes and the Core dist they import, built
# at this commit. If it is missing, the gate builds Core and the themes.
- name: Download built themes and core
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
continue-on-error: true
uses: actions/download-artifact@v8
with:
@@ -2112,9 +2051,11 @@ jobs:
path: packages
- name: Install Playwright
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
run: pnpm install --frozen-lockfile && npx playwright install chromium
- name: Scout this shard of the release plan
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
run: |
node .github/scripts/visual-gate/gate.mjs scout \
--storybook-dir apps/storybook/dist \
@@ -2124,6 +2065,7 @@ jobs:
--observations-out ".visual-scout/observations-${{ matrix.shard }}.json"
- name: Upload scout shard
+ if: steps.visual-scope.outputs.has_stable_visual == 'true' && steps.visual-scope.outputs.broad_stable_visual == 'true'
uses: actions/upload-artifact@v7
with:
name: visual-scout-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }}
@@ -2138,40 +2080,77 @@ jobs:
# Audit and interaction fixtures stay with their existing browser checks.
pr-visual:
name: Stable visual regression
- needs:
- [build-storybook, check-components, maintenance-request, visual-scout]
+ needs: [build-storybook, maintenance-request, visual-scout]
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'))) && (!cancelled() &&
(((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) &&
- needs.build-storybook.result == 'success' &&
- needs.check-components.result == 'success' &&
- needs.check-components.outputs.has_stable_visual == 'true') ||
+ needs.build-storybook.result == 'success') ||
(github.event_name == 'workflow_dispatch' &&
((inputs.operation == 'release-check' &&
- needs.build-storybook.result == 'success' &&
- needs.check-components.result == 'success') ||
+ needs.build-storybook.result == 'success') ||
(needs.maintenance-request.result == 'success' && inputs.operation == 'capture')))))
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:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
+ # Stable visual scope: Core and the non-private shipped themes take
+ # part; canaryOnly packages do not. A pull request the import graph can
+ # scope audits the changed components and their reverse dependents
+ # (spec:AST-030 FR13).
+ - name: Decide stable visual scope
+ id: visual-scope
+ env:
+ FILES_PATH: ${{ steps.scope.outputs.changed_files_path }}
+ SCOPED: ${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}
+ SPECIALIZED: ${{ steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.tooling_only == 'true' }}
+ run: |
+ if [ "$SPECIALIZED" = true ]; then
+ printf 'has_stable_visual=false\nbroad_stable_visual=false\n' >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ if [ "${{ github.event_name }}" != pull_request ] || [ ! -s "$FILES_PATH" ]; then
+ printf 'has_stable_visual=true\nbroad_stable_visual=true\n' >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ VISUAL_ARGS=()
+ if [ "$SCOPED" = true ]; then VISUAL_ARGS=(--scoped); fi
+ node .github/scripts/visual-scope.mjs --github-output "$GITHUB_OUTPUT" "${VISUAL_ARGS[@]}" < "$FILES_PATH"
+
- name: Setup Node and pnpm
+ if: github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download analysis artifact
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && (github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true')
uses: actions/download-artifact@v8
with:
name: pr-analysis
- name: Download Storybook artifact
- if: github.event_name == 'pull_request' || inputs.operation == 'release-check'
+ if: (github.event_name == 'pull_request' || inputs.operation == 'release-check') && (github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true')
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
@@ -2180,7 +2159,7 @@ jobs:
# The artifact carries the themes and the Core dist they import, built
# at this commit. If it is missing, the gate builds Core and the themes.
- name: Download built themes and core
- if: github.event_name == 'pull_request' || inputs.operation == 'release-check'
+ if: (github.event_name == 'pull_request' || inputs.operation == 'release-check') && (github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true')
continue-on-error: true
uses: actions/download-artifact@v8
with:
@@ -2190,7 +2169,7 @@ jobs:
# Only a complete set: the gate refuses a partial or mismatched one, and
# without any it scouts inline as before.
- name: Download scout shards
- if: (github.event_name == 'pull_request' || inputs.operation == 'release-check') && needs.visual-scout.result == 'success'
+ if: ((github.event_name == 'pull_request' || inputs.operation == 'release-check') && needs.visual-scout.result == 'success') && (github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true')
uses: actions/download-artifact@v8
with:
pattern: visual-scout-${{ needs.build-storybook.outputs.short_hash }}-*
@@ -2198,6 +2177,7 @@ jobs:
merge-multiple: true
- name: Install Playwright
+ if: github.event_name != 'pull_request' || steps.visual-scope.outputs.has_stable_visual == 'true'
run: pnpm install --frozen-lockfile && npx playwright install chromium
- name: Build canonical maintenance Storybook
@@ -2209,9 +2189,9 @@ jobs:
- name: Run the visual gate for the touched components
id: visual
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && steps.visual-scope.outputs.has_stable_visual == 'true'
env:
- BROAD_STABLE_VISUAL: ${{ needs.check-components.outputs.broad_stable_visual }}
+ BROAD_STABLE_VISUAL: ${{ steps.visual-scope.outputs.broad_stable_visual }}
ASTRYX_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
ASTRYX_PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
@@ -2298,7 +2278,7 @@ jobs:
esac
- name: Upload visual verdict and report
- if: always() && github.event_name == 'pull_request'
+ if: (always() && github.event_name == 'pull_request') && steps.visual-scope.outputs.has_stable_visual == 'true'
uses: actions/upload-artifact@v7
with:
name: visual-pr-report
@@ -2418,13 +2398,10 @@ jobs:
# To promote findings too, remove the audit step's continue-on-error.
pr-rtl-shard:
name: pr-rtl (${{ matrix.package }}${{ matrix.parts > 1 && format(' {0}/{1}', matrix.part, matrix.parts) || '' }})
- needs: [build-storybook, check-components]
+ needs: [build-storybook]
if: >-
((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) ||
- (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) &&
- (needs.check-components.outputs.has_rtl_components == 'true' ||
- needs.check-components.outputs.has_rtl_harness == 'true' ||
- needs.check-components.outputs.force_full_component_audits == 'true')
+ (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))
# Core is the largest package, so its audit is split three ways
# (`--shard`) and joined by pr-rtl-merge; every other package runs whole.
strategy:
@@ -2442,35 +2419,56 @@ jobs:
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 30 || 15 }}
permissions:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Verify RTL checkout
- if: github.event_name == 'pull_request'
+ if: (github.event_name == 'pull_request') && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
env:
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA"
- name: Setup Node and pnpm
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download analysis artifact
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/download-artifact@v8
with:
name: pr-analysis
- name: Download Storybook artifact
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
path: apps/storybook/dist
- name: Install Playwright
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
run: pnpm install --frozen-lockfile && npx playwright install chromium
# The D7 native-size regression test lives on the PR head. A head cut
@@ -2479,7 +2477,7 @@ jobs:
# so and passes; a head that has the file always runs it, and a failure
# fails. ci-rtl-d7.test.mjs keeps the path pointing at a real file.
- name: Verify D7 native target regression
- if: matrix.package == 'core' && matrix.part == 1
+ if: (matrix.package == 'core' && matrix.part == 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
env:
ASTRYX_RTL_BROWSER: '1'
run: |
@@ -2496,20 +2494,21 @@ jobs:
# step can run. An ordinary harness-only change uses the bounded routing
# smoke scope.
- name: Resolve RTL shard scope
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
id: rtl-scope
run: |
node .github/scripts/rtl-shard-scope.mjs \
--analysis analysis.json \
--package "${{ matrix.package }}" \
- --force-full "${{ needs.check-components.outputs.force_full_component_audits }}" \
- --has-components "${{ needs.check-components.outputs.has_rtl_components }}" \
- --has-harness "${{ needs.check-components.outputs.has_rtl_harness }}" \
+ --force-full "${{ steps.scope.outputs.force_full_component_audits }}" \
+ --has-components "${{ steps.scope.outputs.has_rtl_components }}" \
+ --has-harness "${{ steps.scope.outputs.has_rtl_harness }}" \
--manifest rtl-shard-scope.json \
--github-output "$GITHUB_OUTPUT"
- name: Run RTL audit
id: rtl
- if: steps.rtl-scope.outputs.should_run == 'true'
+ if: (steps.rtl-scope.outputs.should_run == 'true') && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
continue-on-error: true
run: |
PACKAGE=${{ matrix.package }}
@@ -2533,7 +2532,7 @@ jobs:
"${FILTER_ARGS[@]}"
- name: Require completed RTL shard report
- if: always()
+ if: always() && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
run: |
SCOPE_OUTCOME="${{ steps.rtl-scope.outcome }}"
SHOULD_RUN="${{ steps.rtl-scope.outputs.should_run }}"
@@ -2567,14 +2566,14 @@ jobs:
fi
- name: Write scorecard summary
- if: always() && steps.rtl-scope.outputs.should_run == 'true' && matrix.parts == 1
+ if: (always() && steps.rtl-scope.outputs.should_run == 'true' && matrix.parts == 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
run: |
node .github/scripts/rtl-scorecard-summary.mjs \
--report rtl-audit-report.json \
--scope "${{ steps.rtl-scope.outputs.components }}" >> "$GITHUB_STEP_SUMMARY"
- name: Upload RTL shard evidence
- if: always() && matrix.parts == 1
+ if: (always() && matrix.parts == 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/upload-artifact@v7
with:
name: rtl-audit-report-${{ matrix.package }}
@@ -2585,7 +2584,7 @@ jobs:
retention-days: 1
- name: Upload RTL part
- if: always() && matrix.parts > 1
+ if: (always() && matrix.parts > 1) && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/upload-artifact@v7
with:
name: rtl-audit-part-${{ matrix.package }}-${{ matrix.part }}
@@ -2601,40 +2600,58 @@ jobs:
# part fails here.
pr-rtl-merge:
name: pr-rtl (core)
- needs: [build-storybook, check-components, pr-rtl-shard]
+ needs: [build-storybook, pr-rtl-shard]
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'))) && (always() && !cancelled() &&
((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) ||
- (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')) &&
- (needs.check-components.outputs.has_rtl_components == 'true' ||
- needs.check-components.outputs.has_rtl_harness == 'true' ||
- needs.check-components.outputs.force_full_component_audits == 'true'))
+ (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check')))
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: 15
permissions:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup Node and pnpm
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: ./.github/actions/setup
- name: Download Storybook artifact
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
path: apps/storybook/dist
- name: Download Core RTL parts
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/download-artifact@v8
with:
pattern: rtl-audit-part-core-*
path: rtl-parts
- name: Join Core RTL parts
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
id: join
run: |
set -eu
@@ -2672,14 +2689,14 @@ jobs:
--filter "$FILTER"
- name: Write scorecard summary
- if: always() && hashFiles('rtl-audit-report.json') != ''
+ if: (always() && hashFiles('rtl-audit-report.json') != '') && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
run: |
node .github/scripts/rtl-scorecard-summary.mjs \
--report rtl-audit-report.json \
--scope "${{ steps.join.outputs.components }}" >> "$GITHUB_STEP_SUMMARY"
- name: Upload RTL shard evidence
- if: always()
+ if: always() && (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
uses: actions/upload-artifact@v7
with:
name: rtl-audit-report-core
@@ -2691,15 +2708,34 @@ jobs:
# Stable required context joining the five package shards above.
pr-rtl:
- needs: [check-scope, check-components, pr-rtl-shard, pr-rtl-merge]
- 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'))) && (always() && !cancelled() && (((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) && needs.check-scope.outputs.spec_only != 'true') || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))) }}
+ needs: [pr-rtl-shard, pr-rtl-merge]
+ 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'))) && (always() && !cancelled() && ((github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:heavy-lanes')) || (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'))) }}
runs-on: ubuntu-slim
timeout-minutes: 5
+ permissions:
+ contents: read
+ pull-requests: read
steps:
+ # This job decides its own component scope (no separate scope job):
+ # the step reads the PR's file list and the base's trusted classifiers.
+ # Outside a pull request every audit applies in full.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
+
+ - name: Decide this job's component scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ with:
+ component-audit: 'true'
+
- uses: actions/checkout@v7
- name: Download applicable RTL shard reports
- if: ${{ needs.check-components.result == 'success' && (needs.check-components.outputs.has_rtl_components == 'true' || needs.check-components.outputs.has_rtl_harness == 'true' || needs.check-components.outputs.force_full_component_audits == 'true') }}
+ if: (steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true')
continue-on-error: true
uses: actions/download-artifact@v8
with:
@@ -2710,10 +2746,10 @@ jobs:
if: always()
run: |
node .github/scripts/rtl-join.mjs \
- --check-components "${{ needs.check-components.result }}" \
+ --check-components "${{ steps.scope.outcome }}" \
--shards "${{ needs.pr-rtl-shard.result == needs.pr-rtl-merge.result && needs.pr-rtl-shard.result || format('{0}/{1}', needs.pr-rtl-shard.result, needs.pr-rtl-merge.result) }}" \
- --should-run "${{ needs.check-components.outputs.has_rtl_components == 'true' || needs.check-components.outputs.has_rtl_harness == 'true' || needs.check-components.outputs.force_full_component_audits == 'true' }}" \
- --force-full "${{ needs.check-components.outputs.force_full_component_audits }}" \
+ --should-run "${{ steps.scope.outputs.has_rtl_components == 'true' || steps.scope.outputs.has_rtl_harness == 'true' || steps.scope.outputs.force_full_component_audits == 'true' }}" \
+ --force-full "${{ steps.scope.outputs.force_full_component_audits }}" \
--reports-dir rtl-shard-reports
# Report-only: after every pull-request job finishes, each job's run time
@@ -2723,13 +2759,11 @@ jobs:
ci-duration:
needs:
[
- check-scope,
release-bump,
release-merge-back,
docsite-data,
docsite-browser,
docsite-test,
- check-components,
test-ui,
test-node,
native-swift-runner,
@@ -2791,8 +2825,7 @@ jobs:
release-check:
needs:
[
- check-scope,
- check-components,
+ release-authority,
build-storybook,
typecheck,
pr-visual,
@@ -2812,12 +2845,12 @@ jobs:
RELEASE_NEEDS: ${{ toJSON(needs) }}
RELEASE_BRANCH: ${{ inputs['release-branch'] }}
EXPECTED_HEAD: ${{ inputs['expected-head'] }}
- CHECKED_HEAD: ${{ needs.check-scope.outputs.release_head }}
- PLAN_DIGEST: ${{ needs.check-scope.outputs.release_plan_digest }}
+ CHECKED_HEAD: ${{ needs.release-authority.outputs.release_head }}
+ PLAN_DIGEST: ${{ needs.release-authority.outputs.release_plan_digest }}
with:
script: |
const needs = JSON.parse(process.env.RELEASE_NEEDS);
- for (const name of ['check-scope', 'check-components', 'build-storybook', 'typecheck', 'pr-visual', 'pr-a11y', 'a11y-contracts', 'pr-a11y-audit', 'pr-rtl']) {
+ for (const name of ['release-authority', 'build-storybook', 'typecheck', 'pr-visual', 'pr-a11y', 'a11y-contracts', 'pr-a11y-audit', 'pr-rtl']) {
if (needs[name]?.result !== 'success') {
throw new Error(`Required release job ${name} did not succeed: ${needs[name]?.result}`);
}
diff --git a/internal/lab-readiness/audit.test.mjs b/internal/lab-readiness/audit.test.mjs
index a0014b5e9a..19bf10c8b9 100644
--- a/internal/lab-readiness/audit.test.mjs
+++ b/internal/lab-readiness/audit.test.mjs
@@ -353,6 +353,22 @@ describe('CI wiring parsers', () => {
expect(roots).toContain('packages/vega/src/');
});
+ it('covers nothing when ci.yml has no recognizable component gate', () => {
+ const repoRoot = fs.mkdtempSync(
+ path.join(os.tmpdir(), 'lab-readiness-ci-'),
+ );
+ try {
+ fs.mkdirSync(path.join(repoRoot, '.github/workflows'), {recursive: true});
+ fs.writeFileSync(
+ path.join(repoRoot, '.github/workflows/ci.yml'),
+ 'jobs:\n build:\n runs-on: ubuntu-latest\n',
+ );
+ expect(_internal.ciComponentRoots(repoRoot)).toEqual([]);
+ } finally {
+ fs.rmSync(repoRoot, {recursive: true, force: true});
+ }
+ });
+
it('routes Charts, Rich Text, and Vega source-only changes into component audit scope', () => {
const repoRoot = path.resolve(import.meta.dirname, '..', '..');
const roots = _internal.ciComponentRoots(repoRoot);
diff --git a/internal/lab-readiness/automated.mjs b/internal/lab-readiness/automated.mjs
index 3247879aef..1a3e18b8f9 100644
--- a/internal/lab-readiness/automated.mjs
+++ b/internal/lab-readiness/automated.mjs
@@ -24,6 +24,7 @@ import path from 'node:path';
const LAB_SRC = 'packages/lab/src';
const STORIES_DIR = 'apps/storybook/stories';
const CI_WORKFLOW = '.github/workflows/ci.yml';
+const TEST_SCOPE_ACTION = '.github/actions/test-scope/action.yml';
const COMPONENT_REGISTRY = 'scripts/component-packages.cjs';
const RTL_AUDIT = 'apps/storybook/rtl-audit/rtl-audit.mjs';
@@ -95,25 +96,41 @@ function a11yComponentFromTitle(title) {
return componentPart.replace(/^XDS/i, '').toLowerCase();
}
-/** Roots the ci.yml `check-components` gate diffs against. */
+/**
+ * Roots the ci.yml component audits cover: every registered package root
+ * when the gate projects the registry (in ci.yml, or through the test-scope
+ * action its audit jobs run with `component-audit: 'true'`), else the roots a
+ * change-detection pathspec or package filter names, else none.
+ */
function ciComponentRoots(repoRoot) {
const ci = read(repoRoot, CI_WORKFLOW);
if (!ci) return [];
const registry = read(repoRoot, COMPONENT_REGISTRY);
+ const registryRoots = registry
+ ? [...registry.matchAll(/\bsrc:\s*['"]([^'"]+)['"]/g)].map(
+ match => `${match[1]}/`,
+ )
+ : [];
+ // The gate projects the registry when ci.yml, or the test-scope action its
+ // audit jobs run with `component-audit: 'true'`, runs the trusted
+ // component-audit-scope.cjs against scripts/component-packages.cjs.
+ const action = read(repoRoot, TEST_SCOPE_ACTION) ?? '';
const projectsRegistry =
/COMPONENT_PACKAGES/.test(ci) ||
(/component-audit-scope\.cjs/.test(ci) &&
- /scripts\/component-packages\.cjs/.test(ci));
- if (registry && projectsRegistry) {
- const roots = [...registry.matchAll(/\bsrc:\s*['"]([^'"]+)['"]/g)].map(
- match => `${match[1]}/`,
- );
- if (roots.length > 0) return roots;
- }
+ /scripts\/component-packages\.cjs/.test(ci)) ||
+ (/component-audit: 'true'/.test(ci) &&
+ /component-audit-scope\.cjs/.test(action) &&
+ /scripts\/component-packages\.cjs/.test(action));
+ if (projectsRegistry && registryRoots.length > 0) return registryRoots;
const pathspec = ci.match(/git diff --name-only [^\n]*?\.\.\.HEAD --([^|\n]+)/);
if (pathspec) return pathspec[1].trim().split(/\s+/).filter(Boolean);
const filtered = ci.match(/grep -E ['"]\^packages\/\(([^)]+)\)\/src\/['"]/);
- return filtered ? filtered[1].split('|').map(name => `packages/${name}/src/`) : [];
+ if (filtered) {
+ return filtered[1].split('|').map(name => `packages/${name}/src/`);
+ }
+ // No recognizable gate: nothing is covered, so the check fails.
+ return [];
}
/** Story-id prefixes the RTL auto-discovery sweep covers. */
@@ -413,7 +430,7 @@ export function deriveChecks(repoRoot, candidate) {
failures.push('ci.yml change detection excludes packages/lab/src');
evidence.push(
ev(
- `check-components diffs only ${roots.join(' ') || '(unparsed)'}, so a lab-only PR skips pr-a11y entirely.`,
+ `ci.yml component audits cover only ${roots.join(' ') || '(unparsed)'}, so a lab component skips pr-a11y entirely.`,
CI_WORKFLOW,
lineOf(read(repoRoot, CI_WORKFLOW), /git diff --name-only/),
),