Skip to content

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

TypeScript

ci: the docsite, test and build owners decide their own scope (#8918)

Cindy Zhanga23abec86b2f
diff --git a/.github/actions/test-scope/action.yml b/.github/actions/test-scope/action.yml
index 407f8dfc50..d2ad16af58 100644
--- a/.github/actions/test-scope/action.yml
+++ b/.github/actions/test-scope/action.yml
@@ -60,6 +60,12 @@ outputs:
release_bump:
description: The PR targets a release branch (the generated version bump).
value: ${{ steps.scope.outputs.release_bump }}
+ decided:
+ description: >-
+ `false` when the step fell back to everything in scope because it could
+ not decide; a job that must do work on a lane it cannot recognize (spec
+ validation) reads this.
+ value: ${{ steps.scope.outputs.decided }}
touches:
description: A changed path matches `paths` (true when `paths` is empty or undecidable).
value: ${{ steps.scope.outputs.touches }}
@@ -94,6 +100,7 @@ runs:
release_bump: 'false',
touches: 'true',
applies: 'true',
+ decided: 'true',
};
const report = values => {
for (const [key, value] of Object.entries(values)) core.setOutput(key, value);
@@ -142,7 +149,7 @@ runs:
}
} catch (error) {
core.warning(`Scope could not be decided (${error.message}); everything is in scope.`);
- report(everything);
+ report({...everything, decided: 'false'});
return;
}
diff --git a/.github/scripts/ci-docsite-browser.test.mjs b/.github/scripts/ci-docsite-browser.test.mjs
index 193b647535..eda887e356 100644
--- a/.github/scripts/ci-docsite-browser.test.mjs
+++ b/.github/scripts/ci-docsite-browser.test.mjs
@@ -11,7 +11,7 @@ import path from 'node:path';
import {spawnSync} from 'node:child_process';
import {describe, expect, it} from 'vitest';
import yaml from 'yaml';
-import {PR_REPORT_GATE, gated} from './ci-pr-gate.mjs';
+import {PR_REPORT_GATE, gated, ungated} from './ci-pr-gate.mjs';
const root = path.resolve(import.meta.dirname, '../..');
const {jobs} = yaml.parse(
@@ -27,29 +27,33 @@ const dataGuard = owner.steps.find(
step => step.name === 'Require successful docsite data generation and tests',
);
const ACTIVE =
- "needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'";
+ "steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'";
describe('docsite browser required-check projection', () => {
it('joins the existing required context and uses the same surface route', () => {
- expect(owner.needs).toEqual([
- 'check-scope',
- 'docsite-browser',
- 'docsite-data',
- ]);
+ expect(owner.needs).toEqual(['docsite-browser', 'docsite-data']);
expect(owner.if).toBe(
gated(
- "${{ github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.release_bump != 'true' && always() && !cancelled() }}",
+ "${{ github.event_name != 'workflow_dispatch' && !startsWith(github.base_ref, 'release/v') && always() && !cancelled() }}",
PR_REPORT_GATE,
),
);
- expect(browser.needs).toEqual(['check-scope']);
- expect(browser.if).toBe(
- `github.event_name != 'workflow_dispatch' && ${ACTIVE}`,
- );
- expect(data.needs).toEqual(['check-scope']);
- expect(data.if).toBe(
- `github.event_name != 'workflow_dispatch' && ${ACTIVE}`,
- );
+ // Each owner decides its own scope and gates every later step on it.
+ for (const job of [browser, data]) {
+ expect(job.needs).toBeUndefined();
+ expect(ungated(job.if)).toBe("github.event_name != 'workflow_dispatch'");
+ const scopeAt = job.steps.findIndex(step => step.id === 'scope');
+ expect(scopeAt).toBe(1);
+ // Exact conditions: an extra skip on any step (for example a
+ // docsite-only one) fails here. Only the evidence upload also runs
+ // after a failed step.
+ for (const step of job.steps.slice(scopeAt + 1)) {
+ const expected = step.name?.startsWith('Upload ')
+ ? `always() && ${ACTIVE}`
+ : ACTIVE;
+ expect(step.if, step.name ?? step.uses).toBe(expected);
+ }
+ }
expect(guard.if).toBe(ACTIVE);
expect(dataGuard.if).toBe(ACTIVE);
expect(
@@ -82,7 +86,7 @@ describe('docsite browser required-check projection', () => {
const upload = browser.steps.find(
step => step.name === 'Upload docsite browser evidence',
);
- expect(upload.if).toBe('always()');
+ expect(upload.if).toBe(`always() && ${ACTIVE}`);
expect(upload.with['if-no-files-found']).toBe('error');
expect(path.resolve(root, upload.with.path)).toBe(
path.resolve(path.dirname(configPath), outputDir),
diff --git a/.github/scripts/ci-test-join.mjs b/.github/scripts/ci-test-join.mjs
index 61e9701c16..5d6efa898d 100644
--- a/.github/scripts/ci-test-join.mjs
+++ b/.github/scripts/ci-test-join.mjs
@@ -4,15 +4,19 @@
/**
* @file Fail-closed contract for the pull-request `test` join.
*
- * The Build test owner is intentionally skipped for the admitted lightweight
- * scopes. Every other scope must execute it successfully. Keeping this decision
- * in an executable program lets tests prove every status/scope combination
- * instead of matching shell fragments in the workflow.
+ * Every test owner the join waits on decides its own scope and reports
+ * success whether it ran its work or skipped it, so each must have succeeded.
+ * The join's own scope outputs must be decided (true or false), never missing,
+ * and a release-branch pull request must pass its release-bump validation.
+ * Keeping this decision in an executable program lets tests prove every
+ * status/scope combination instead of matching shell fragments in the
+ * workflow.
*/
const requiredSuccess = [
['test-ui', process.env.TEST_UI_RESULT],
['test-node', process.env.TEST_NODE_RESULT],
+ ['test-build', process.env.TEST_BUILD_RESULT],
['registry-contract', process.env.REGISTRY_CONTRACT_RESULT],
['test-native-swift', process.env.TEST_NATIVE_SWIFT_RESULT],
['pr-interaction', process.env.PR_INTERACTION_RESULT],
@@ -23,6 +27,8 @@ 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'}`);
}
@@ -31,6 +37,17 @@ for (const [name, result] of requiredSuccess) {
if (result !== 'success') fail(`${name}: ${result ?? 'missing'}`);
}
+// A release-branch pull request must pass its bump validation; any other
+// pull request must not have run it.
+const expectedBump =
+ process.env.RELEASE_BUMP === 'true' ? 'success' : 'skipped';
+if (process.env.RELEASE_BUMP_RESULT !== expectedBump) {
+ fail(
+ `release-bump: ${process.env.RELEASE_BUMP_RESULT ?? 'missing'} ` +
+ `(expected ${expectedBump})`,
+ );
+}
+
const scopes = [
['docsite_only', process.env.DOCSITE_ONLY],
['spec_only', process.env.SPEC_ONLY],
@@ -42,15 +59,6 @@ for (const [name, value] of scopes) {
}
}
-const isSpecialized = scopes.some(([, value]) => value === 'true');
-const expectedBuild = isSpecialized ? 'skipped' : 'success';
-if (process.env.TEST_BUILD_RESULT !== expectedBuild) {
- fail(
- `test-build: ${process.env.TEST_BUILD_RESULT ?? 'missing'} ` +
- `(expected ${expectedBuild} for this scope)`,
- );
-}
-
if (process.exitCode !== 1) {
console.log(
'All required test owners reached their expected terminal state.',
diff --git a/.github/scripts/ci-test-join.test.mjs b/.github/scripts/ci-test-join.test.mjs
index 0786a00d86..83c7527bd2 100644
--- a/.github/scripts/ci-test-join.test.mjs
+++ b/.github/scripts/ci-test-join.test.mjs
@@ -13,6 +13,8 @@ const broad = {
DOCSITE_ONLY: 'false',
SPEC_ONLY: 'false',
TOOLING_ONLY: 'false',
+ RELEASE_BUMP: 'false',
+ RELEASE_BUMP_RESULT: 'skipped',
TEST_UI_RESULT: 'success',
TEST_NODE_RESULT: 'success',
TEST_BUILD_RESULT: 'success',
@@ -62,24 +64,36 @@ describe('pull-request test join', () => {
});
it.each(['DOCSITE_ONLY', 'SPEC_ONLY', 'TOOLING_ONLY'])(
- 'accepts a skipped Build owner only for %s',
+ 'still requires every owner to report success for %s, since each skips its own work',
scope => {
+ expect(run({[scope]: 'true'})).toMatchObject({status: 0});
expect(
run({[scope]: 'true', TEST_BUILD_RESULT: 'skipped'}),
- ).toMatchObject({status: 0});
- expect(
- run({[scope]: 'true', TEST_BUILD_RESULT: 'success'}),
).toMatchObject({status: 1});
},
);
it('fails closed when classification failed or omitted', () => {
- expect(
- run({CHECK_SCOPE_RESULT: 'failure', TEST_BUILD_RESULT: 'skipped'}),
- ).toMatchObject({status: 1});
- expect(
- run({CHECK_SCOPE_RESULT: '', TEST_BUILD_RESULT: 'skipped'}),
- ).toMatchObject({status: 1});
+ 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',
+ SPEC_ONLY: 'true',
+ TOOLING_ONLY: 'true',
+ };
+ expect(run({...release, RELEASE_BUMP_RESULT: 'success'})).toMatchObject({
+ status: 0,
+ });
+ for (const result of ['failure', 'skipped', 'cancelled', null]) {
+ expect(
+ run({...release, RELEASE_BUMP_RESULT: result}),
+ String(result),
+ ).toMatchObject({status: 1});
+ }
+ expect(run({RELEASE_BUMP_RESULT: 'success'})).toMatchObject({status: 1});
});
it('rejects missing or invalid scope decisions', () => {
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjs
index 8041c30f38..5aa416bca3 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -165,7 +165,7 @@ describe.each(Object.entries(WORKFLOWS))(
expect(suites).toHaveLength(2);
const [share, isolated] = suites;
// Its share is the full UI project, or for a scoped pull request the
- // tests related to its diff (check-scope's full_suite).
+ // tests related to its diff (the scope step's full_suite).
if (graphScoped) {
expect(share.run.trim()).toBe(
[
@@ -186,7 +186,7 @@ describe.each(Object.entries(WORKFLOWS))(
].join('\n'),
);
expect(share.env.SCOPED).toBe(
- "${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }}",
+ "${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}",
);
// The Node lane runs the same scoped share, guards included.
const node = workflow.jobs['test-node'].steps.find(
@@ -316,7 +316,11 @@ describe.each(Object.entries(WORKFLOWS))(
if (scopeConditional) {
it('keeps the lightweight-docs skip on every lane', () => {
for (const lane of lanes) {
- expect(workflow.jobs[lane].if).toContain('always()');
+ // Each lane decides its own scope; there is no scope job to wait on.
+ expect(
+ workflow.jobs[lane].steps.some(step => step.id === 'scope'),
+ `${lane} has no scope step`,
+ ).toBe(true);
const steps = workflow.jobs[lane].steps;
const suite = steps.find(step =>
expandScripts(step.run ?? '').includes('--project'),
@@ -327,9 +331,11 @@ describe.each(Object.entries(WORKFLOWS))(
expect(suite.if, `${lane} suite is unconditional`).toContain(
"spec_only != 'true'",
);
+ // A scope step that fails (a classifier rejecting the change)
+ // fails the lane; nothing lets the suite skip past it.
expect(
- steps.some(step =>
- step.run?.includes('refusing to skip required work'),
+ steps.some(
+ step => step.id === 'scope' && step['continue-on-error'] !== true,
),
`${lane} does not guard against an unclassified scope`,
).toBe(true);
@@ -423,8 +429,10 @@ describe('ci.yml RTL package sharding', () => {
'a11y-contracts-shard',
'pr-rtl-shard',
]) {
- const checkout = workflow.jobs[name].steps.find(candidate =>
- candidate.uses?.startsWith('actions/checkout@'),
+ const checkout = workflow.jobs[name].steps.find(
+ candidate =>
+ candidate.uses?.startsWith('actions/checkout@') &&
+ candidate.with?.path !== '.test-scope',
);
expect(checkout?.with?.ref, `${name} checkout is not exact-head`).toBe(
exactRef,
@@ -434,7 +442,7 @@ describe('ci.yml RTL package sharding', () => {
candidate => candidate.name === 'Verify Storybook source checkout',
);
expect(storybookVerify.if).toContain(
- "needs.check-scope.outputs.tooling_only != 'true'",
+ "steps.scope.outputs.tooling_only != 'true'",
);
expect(runLines(workflow.jobs['build-storybook'])).toContain(
'astryx-build-sha.txt',
@@ -779,10 +787,10 @@ describe('scoped browser audits (spec:AST-030 FR9, FR13)', () => {
throw new Error(`no step named ${name}`);
};
- it('asks component analysis for full audits unless check-scope reports a scoped suite', () => {
+ it('asks component analysis for full audits unless the scope step reports a scoped suite', () => {
const analyze = stepNamed('Analyze components');
expect(analyze.env.FULL_SUITE).toBe(
- '${{ needs.check-scope.outputs.full_suite }}',
+ '${{ steps.scope.outputs.full_suite }}',
);
expect(analyze.run).toContain(
'if [ "$FULL_SUITE" != false ]; then FORCE_FULL=(--force-full); fi',
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index 32de7d35be..c0a70ea2b4 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -16,16 +16,19 @@ import path from 'node:path';
import {describe, expect, it} from 'vitest';
import yaml from 'yaml';
+import {ungated} from './ci-pr-gate.mjs';
+
const root = path.resolve(import.meta.dirname, '../..');
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
const load = relative => yaml.parse(read(relative));
const ci = load('.github/workflows/ci.yml');
const lint = load('.github/workflows/lint.yml');
const prComment = load('.github/workflows/pr-comment.yml');
-const TOOLING_FALSE = "needs.check-scope.outputs.tooling_only != 'true'";
-const TOOLING_TRUE = "needs.check-scope.outputs.tooling_only == 'true'";
+const scopeAction = read('.github/actions/test-scope/action.yml');
+const TOOLING_FALSE = "steps.scope.outputs.tooling_only != 'true'";
+const TOOLING_TRUE = "steps.scope.outputs.tooling_only == 'true'";
const BROAD_ONLY =
- "needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'";
+ "steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'";
function step(job, name) {
return job.steps.find(candidate => candidate.name === name);
@@ -33,13 +36,20 @@ function step(job, name) {
describe('Node-tooling CI routing', () => {
it('publishes the tooling output from the trusted-base classifier', () => {
- expect(ci.jobs['check-scope'].outputs.tooling_only).toContain(
- 'steps.scope.outputs.tooling_only',
- );
- for (const workflow of [
- '.github/workflows/ci.yml',
- '.github/workflows/lint.yml',
+ // ci.yml jobs each run the scope action, which reads the classifier and
+ // both dependencies from the PR's base commit.
+ expect(scopeAction).toContain('ref: pr.base.sha');
+ for (const file of [
+ '.github/scripts/change-scope.cjs',
+ '.github/scripts/knowledge-paths.cjs',
+ 'scripts/component-packages.cjs',
]) {
+ expect(scopeAction).toContain(`'${file}'`);
+ }
+ expect(read('.github/workflows/ci.yml')).not.toContain(
+ 'node .github/scripts/change-scope.cjs',
+ );
+ for (const workflow of ['.github/workflows/lint.yml']) {
const source = read(workflow);
expect(source).toContain(
'git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs"',
@@ -58,10 +68,11 @@ describe('Node-tooling CI routing', () => {
});
it('grants no specialized lane without a merge base or trusted dependency', () => {
- for (const workflow of [
- '.github/workflows/ci.yml',
- '.github/workflows/lint.yml',
- ]) {
+ for (const key of ['spec_only', 'docsite_only', 'tooling_only']) {
+ expect(scopeAction).toContain(`${key}: 'false',`);
+ }
+ expect(scopeAction).toContain("full_suite: 'true',");
+ for (const workflow of ['.github/workflows/lint.yml']) {
const source = read(workflow);
expect(source).toContain(
'docsite_only=false\\nspec_only=false\\ntooling_only=false',
@@ -91,19 +102,15 @@ describe('Node-tooling CI routing', () => {
/^pnpm test:ui\b/.test(candidate.run ?? ''),
);
expect(uiSuite.if).toContain(TOOLING_FALSE);
- expect(ci.jobs['check-components'].if).not.toContain(TOOLING_FALSE);
- const componentCheck = step(
- ci.jobs['check-components'],
- 'Check for component changes',
- ).run;
- expect(componentCheck).toContain('needs.check-scope.outputs.tooling_only');
- expect(componentCheck).toContain('has_components=false');
- expect(ci.jobs['test-build'].if).toBe(
- `github.event_name != 'workflow_dispatch' && ${BROAD_ONLY}`,
- );
- expect(step(ci.jobs['test-build'], 'Run Build package contracts').run).toBe(
- 'pnpm test:build',
+ expect(ungated(ci.jobs['test-build'].if)).toBe(
+ "github.event_name != 'workflow_dispatch'",
);
+ expect(
+ step(ci.jobs['test-build'], 'Run Build package contracts'),
+ ).toMatchObject({
+ if: BROAD_ONLY,
+ run: 'pnpm test:build',
+ });
// The Build package's owner keeps its contracts, in order: the plugin is
// built before the cascade guard imports it.
const rootScripts = JSON.parse(
@@ -116,19 +123,18 @@ describe('Node-tooling CI routing', () => {
'node .github/scripts/theme-layer-cascade.js',
'ASTRYX_STYLEX_BROWSER=1 vitest run scripts/stylex-module-resolution.browser.test.mjs --project node --maxWorkers=1',
]);
- // The vibe-tests fixtures share test-build's Playwright runner, and its
- // Node-tooling skip.
- expect(ci.jobs['fixture-contrast']).toBeUndefined();
+ // The vibe-tests fixtures share test-build's Playwright runner.
for (const name of [
'Verify canonical setup compositions',
'Verify guest fixture contrast',
]) {
- expect(step(ci.jobs['test-build'], name)).toBeDefined();
+ expect(step(ci.jobs['test-build'], name).if).toBe(BROAD_ONLY);
}
- expect(ci.jobs['test-build'].if).toContain(TOOLING_FALSE);
// The merge-base size build is heavy build work and stays off the
// Node-tooling, docsite, and spec lanes.
- expect(ci.jobs['size-base'].if).toContain(BROAD_ONLY);
+ expect(step(ci.jobs['size-base'], 'Setup Node and pnpm').if).toContain(
+ BROAD_ONLY,
+ );
expect(rootScripts['test:theme-family'].split(' && ')).toEqual([
'pnpm -F @astryxdesign/core build',
'pnpm -F @astryxdesign/sandbox generate:theme-family',
@@ -154,7 +160,6 @@ describe('Node-tooling CI routing', () => {
expect(
step(ci.jobs['docsite-test'], 'Skip docsite work for Node tooling').if,
).toContain(TOOLING_TRUE);
- expect(ci.jobs['docsite-data'].if).toContain(TOOLING_FALSE);
for (const name of [
'Build core package',
'Build canary component packages',
@@ -168,7 +173,8 @@ describe('Node-tooling CI routing', () => {
...ci.jobs.typecheck.steps,
]) {
if (
- candidate.name === 'Require successful scope classification' ||
+ candidate.id === 'scope' ||
+ candidate.with?.path === '.test-scope' ||
candidate.name === 'Skip heavy work for a specialized lane' ||
candidate.name === 'Skip typechecks for a specialized lane'
) {
@@ -185,6 +191,7 @@ 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',
'test-build',
@@ -195,12 +202,22 @@ describe('Node-tooling CI routing', () => {
expect(ci.jobs.build.needs).toEqual(['build-storybook', 'typecheck']);
const testJoin = step(ci.jobs.test, 'Require expected test-owner outcomes');
expect(testJoin.run).toBe('node .github/scripts/ci-test-join.mjs');
- expect(ci.jobs.test.permissions).toEqual({contents: 'read'});
+ expect(ci.jobs.test.permissions).toEqual({
+ contents: 'read',
+ 'pull-requests': 'read',
+ });
+ // A release-branch pull request is spec-only, but its join still runs to
+ // require the release bump's own validation.
+ expect(testJoin.if).toBe(
+ "steps.scope.outputs.spec_only != 'true' || steps.scope.outputs.release_bump == 'true'",
+ );
expect(testJoin.env).toMatchObject({
CHECK_SCOPE_RESULT: '${{ needs.check-scope.result }}',
- DOCSITE_ONLY: '${{ needs.check-scope.outputs.docsite_only }}',
- SPEC_ONLY: '${{ needs.check-scope.outputs.spec_only }}',
- TOOLING_ONLY: '${{ needs.check-scope.outputs.tooling_only }}',
+ RELEASE_BUMP: '${{ steps.scope.outputs.release_bump }}',
+ RELEASE_BUMP_RESULT: '${{ needs.release-bump.result }}',
+ DOCSITE_ONLY: '${{ steps.scope.outputs.docsite_only }}',
+ SPEC_ONLY: '${{ steps.scope.outputs.spec_only }}',
+ TOOLING_ONLY: '${{ steps.scope.outputs.tooling_only }}',
TEST_UI_RESULT: '${{ needs.test-ui.result }}',
TEST_NODE_RESULT: '${{ needs.test-node.result }}',
TEST_BUILD_RESULT: '${{ needs.test-build.result }}',
diff --git a/.github/scripts/release-check-workflow.test.mjs b/.github/scripts/release-check-workflow.test.mjs
index 26fe4e00fd..7002d615aa 100644
--- a/.github/scripts/release-check-workflow.test.mjs
+++ b/.github/scripts/release-check-workflow.test.mjs
@@ -97,6 +97,7 @@ function runs(
'needs',
'always',
'cancelled',
+ 'steps',
`return Boolean(${expression});`,
)(
{
@@ -107,6 +108,21 @@ function runs(
needs,
() => true,
() => cancelled,
+ // The scope step puts everything in scope outside a pull request.
+ {
+ scope: {
+ outputs: {
+ spec_only: 'false',
+ docsite_only: 'false',
+ tooling_only: 'false',
+ full_suite: 'true',
+ release_bump: 'false',
+ touches: 'true',
+ applies: 'true',
+ decided: 'true',
+ },
+ },
+ },
);
}
diff --git a/.github/scripts/shadcn-registry-ci.test.mjs b/.github/scripts/shadcn-registry-ci.test.mjs
index 92fb15f90d..54f6aea04d 100644
--- a/.github/scripts/shadcn-registry-ci.test.mjs
+++ b/.github/scripts/shadcn-registry-ci.test.mjs
@@ -19,7 +19,7 @@ const root = path.resolve(import.meta.dirname, '../..');
const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
const ci = yaml.parse(read('.github/workflows/ci.yml'));
const job = ci.jobs['registry-contract'];
-const SPEC_FALSE = "needs.check-scope.outputs.spec_only != 'true'";
+const SPEC_FALSE = "steps.scope.outputs.spec_only != 'true'";
function step(name) {
return job.steps.find(candidate => candidate.name === name);
@@ -34,13 +34,13 @@ function runLines() {
describe('ShadCN registry CI contract', () => {
it('runs as a bounded fail-closed gate and feeds the required test context', () => {
- expect(job.needs).toEqual(['check-scope']);
- expect(job.if).toContain('always()');
+ // It decides its own scope; there is no scope job to wait on.
+ expect(job.needs).toBeUndefined();
+ expect(job.steps.find(candidate => candidate.id === 'scope').uses).toBe(
+ './.test-scope/.github/actions/test-scope',
+ );
expect(job['runs-on']).toBe('ubuntu-latest');
expect(job['timeout-minutes']).toBe(15);
- expect(step('Require successful scope classification').run).toContain(
- 'refusing to skip required work',
- );
expect(ci.jobs.test.needs).toContain('registry-contract');
const join = ci.jobs.test.steps.find(candidate =>
@@ -55,7 +55,8 @@ describe('ShadCN registry CI contract', () => {
it('runs every material step except on the trusted spec-only lane', () => {
for (const candidate of job.steps) {
if (
- candidate.name === 'Require successful scope classification' ||
+ candidate.id === 'scope' ||
+ candidate.with?.path === '.test-scope' ||
candidate.name === 'Skip registry work for spec-only changes'
) {
continue;
diff --git a/.github/scripts/spec-owner-workflow.test.mjs b/.github/scripts/spec-owner-workflow.test.mjs
index 2d61a39dd7..2c674c80b0 100644
--- a/.github/scripts/spec-owner-workflow.test.mjs
+++ b/.github/scripts/spec-owner-workflow.test.mjs
@@ -16,7 +16,7 @@ const read = relative => fs.readFileSync(path.join(root, relative), 'utf8');
describe('spec-only workflow contract', () => {
it('keeps classification in one tested helper', () => {
for (const workflow of [
- '.github/workflows/ci.yml',
+ '.github/actions/test-scope/action.yml',
'.github/workflows/lint.yml',
'.github/workflows/cli-smoke-test.yml',
'.github/workflows/internal-registry.yml',
@@ -32,8 +32,18 @@ describe('spec-only workflow contract', () => {
});
it('packages every dependency for trusted-base isolated classification', () => {
+ // ci.yml's jobs read the same three files from the base commit through
+ // the scope action (the GitHub API, no history needed).
+ const action = read('.github/actions/test-scope/action.yml');
+ for (const file of [
+ '.github/scripts/change-scope.cjs',
+ '.github/scripts/knowledge-paths.cjs',
+ 'scripts/component-packages.cjs',
+ ]) {
+ expect(action).toContain(`'${file}'`);
+ }
+ expect(action).toContain('ref: pr.base.sha');
for (const workflow of [
- '.github/workflows/ci.yml',
'.github/workflows/lint.yml',
'.github/workflows/cli-smoke-test.yml',
'.github/workflows/internal-registry.yml',
@@ -105,10 +115,7 @@ describe('spec-only workflow contract', () => {
it('routes spec-only changes without unrelated CI commands', () => {
const ci = read('.github/workflows/ci.yml');
- expect(ci).toContain(
- 'git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs"',
- );
- expect(ci).toContain('spec_only: ${{ steps.scope.outputs.spec_only }}');
+ expect(ci).toContain('uses: ./.test-scope/.github/actions/test-scope');
const jobBlock = name => {
const start = ci.indexOf(` ${name}:`);
@@ -117,15 +124,19 @@ describe('spec-only workflow contract', () => {
return next < 0 ? ci.slice(start) : ci.slice(start, start + 1 + next);
};
const unrelatedJobs = [
- 'check-components',
'test-ui',
'test-node',
'registry-contract',
'test',
'build-storybook',
- 'pr-rtl',
];
for (const job of unrelatedJobs) {
+ expect(jobBlock(job), job).toContain(
+ "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'",
);
@@ -135,7 +146,7 @@ describe('spec-only workflow contract', () => {
);
const docsite = jobBlock('docsite-test');
- expect(docsite).toContain("needs.check-scope.outputs.spec_only == 'true'");
+ expect(docsite).toContain("steps.scope.outputs.spec_only == 'true'");
expect(docsite).toContain('node scripts/check-knowledge.mjs');
const lint = read('.github/workflows/lint.yml');
@@ -189,23 +200,29 @@ describe('spec-only workflow contract', () => {
expect(checkout).toBeGreaterThanOrEqual(0);
expect(setup).toBeGreaterThan(checkout);
expect(validate).toBeGreaterThan(setup);
+ // It validates on the spec-only lane, and whenever its own scope step
+ // could not decide, so an undecided lane never skips validation.
expect(docsiteJob.slice(setup, validate)).toContain(
- "if: needs.check-scope.outputs.spec_only == 'true'",
+ "if: (steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')",
);
expect(docsiteJob).not.toContain('- name: Build core package');
expect(docsiteJob).not.toContain('- name: Generate and test docsite data');
- const header = dataJob.slice(0, dataJob.indexOf('steps:'));
- expect(header).toContain("needs.check-scope.outputs.spec_only != 'true'");
+ const setupStep = dataJob.slice(
+ dataJob.indexOf('- uses: ./.github/actions/setup'),
+ );
+ expect(setupStep.slice(0, 200)).toContain(
+ "steps.scope.outputs.spec_only != 'true'",
+ );
const build = dataJob.indexOf('- name: Build core package');
const generate = dataJob.indexOf('- name: Generate and test docsite data');
expect(build).toBeGreaterThanOrEqual(0);
expect(generate).toBeGreaterThan(build);
expect(dataJob.slice(build, generate)).toContain(
- "if: needs.check-scope.outputs.spec_only != 'true'",
+ "if: steps.scope.outputs.spec_only != 'true'",
);
expect(dataJob.slice(generate)).toContain(
- "if: needs.check-scope.outputs.spec_only != 'true'",
+ "if: steps.scope.outputs.spec_only != 'true'",
);
});
@@ -223,16 +240,20 @@ describe('spec-only workflow contract', () => {
expect(commandSteps.length).toBeGreaterThan(0);
for (const step of commandSteps) {
- expect(step).toContain("needs.check-scope.outputs.spec_only != 'true'");
+ expect(step).toContain("steps.scope.outputs.spec_only != 'true'");
}
});
it('fails closed when file APIs are truncated or scope classification fails', () => {
const ci = read('.github/workflows/ci.yml');
expect(ci).toContain(
- `if: ${gated("${{ github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.release_bump != 'true' && always() && !cancelled() }}", PR_REPORT_GATE)}`,
+ `if: ${gated("${{ github.event_name != 'workflow_dispatch' && !startsWith(github.base_ref, 'release/v') && always() && !cancelled() }}", PR_REPORT_GATE)}`,
+ );
+ const action = read('.github/actions/test-scope/action.yml');
+ expect(action).toContain(
+ "throw new Error('GitHub truncated the file list at 3000')",
);
- expect(ci).toContain("if: needs.check-scope.result != 'success'");
+ expect(action).toContain('core.setFailed(');
const reviewSignal = read('.github/workflows/review-signal.yml');
expect(reviewSignal).toContain('allFiles.length !== pr.changed_files');
@@ -391,3 +412,14 @@ describe('spec-only workflow contract', () => {
expect(writers.sort()).toEqual(['review-clear.yml', 'review-signal.yml']);
});
});
+
+describe('docsite-test spec validation', () => {
+ it('validates spec records whenever its own scope is spec-only or undecided', () => {
+ const ci = read('.github/workflows/ci.yml');
+ const job = ci.slice(ci.indexOf('\n docsite-test:\n'));
+ const validate = job.slice(job.indexOf('- name: Validate spec records'));
+ expect(validate.split('\n')[1].trim()).toBe(
+ "if: (steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')",
+ );
+ });
+});
diff --git a/.github/scripts/test-scope-action.test.mjs b/.github/scripts/test-scope-action.test.mjs
index 8e7caf4bd9..71c309026b 100644
--- a/.github/scripts/test-scope-action.test.mjs
+++ b/.github/scripts/test-scope-action.test.mjs
@@ -145,6 +145,7 @@ describe('per-job scope step', () => {
expect(Object.keys(action.outputs).sort()).toEqual(
[
'applies',
+ 'decided',
'docsite_only',
'full_suite',
'release_bump',
@@ -274,6 +275,14 @@ describe('per-job scope step', () => {
applies: 'true',
});
expect(messages.warning).toHaveLength(1);
+ expect(outputs.decided).toBe('false');
+ });
+
+ it('reports a decided scope when the classifier ran', async () => {
+ const {outputs} = await decide({
+ files: changed('docs/specs/AST-030/spec.md'),
+ });
+ expect(outputs.decided).toBe('true');
});
it('classifies a rename by both names, so a rename into specs is not spec-only', async () => {
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4e6982f4d8..fcfa022ba5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -404,77 +404,101 @@ jobs:
# be followed by this job's own generation and tests (~2.5 minutes). The
# spec-only lane validates spec records here, where it always has.
docsite-test:
- needs: [check-scope, docsite-browser, docsite-data]
- if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.release_bump != 'true' && always() && !cancelled()) }}
+ needs: [docsite-browser, docsite-data]
+ if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && !startsWith(github.base_ref, 'release/v') && always() && !cancelled()) }}
runs-on: ubuntu-24.04-arm
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- name: Require a branch in this repository or the ci:run label
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')) }}
run: |
echo "::error::Waiting for a maintainer's ci:run label: an outside contributor's pull request runs CI once a maintainer adds it (spec:AST-030 FR17)."
exit 1
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Require successful docsite browser contract
- if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
env:
DOCSITE_BROWSER_RESULT: ${{ needs.docsite-browser.result }}
run: test "$DOCSITE_BROWSER_RESULT" = 'success'
- name: Require successful docsite data generation and tests
- if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
env:
DOCSITE_DATA_RESULT: ${{ needs.docsite-data.result }}
run: test "$DOCSITE_DATA_RESULT" = 'success'
- name: Skip docsite work for Node tooling
- if: needs.check-scope.outputs.tooling_only == 'true'
+ if: steps.scope.outputs.tooling_only == 'true'
run: echo "Node-tooling PR — docsite generation is not an owned check"
- uses: actions/checkout@v7
- if: needs.check-scope.outputs.spec_only == 'true'
+ if: (steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')
# Spec validation imports the canonical CLI discovery path, so the
# lightweight docs path needs workspace dependencies too.
- uses: ./.github/actions/setup
- if: needs.check-scope.outputs.spec_only == 'true'
+ if: (steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')
- name: Validate spec records
- if: needs.check-scope.outputs.spec_only == 'true'
+ if: (steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.decided != 'true')
run: node scripts/check-knowledge.mjs
# Docsite data generation and tests. Its outcome feeds docsite-test.
docsite-data:
- needs: [check-scope]
- if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != '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 != 'workflow_dispatch')
runs-on: ubuntu-24.04-arm
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- - uses: actions/checkout@v7
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ - uses: actions/checkout@v7
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- uses: ./.github/actions/setup
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
# Docsite `generate` runs `astryx theme build`, which imports the compiled
# @astryxdesign/core/theme entry (dist/theme/index.js). Build core first so that
# entry exists — otherwise generate fails with "Cannot find module".
- name: Build core package
- if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm -F @astryxdesign/core build
# The generated preview registry imports every configured canary component
# package. Build those exports so Vitest exercises the same graph as the
# canary deployment.
- name: Build canary component packages
- if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: |
pnpm -F @astryxdesign/lab build
pnpm -F @astryxdesign/charts build
@@ -482,7 +506,7 @@ jobs:
pnpm -F @astryxdesign/vega build
- name: Generate and test docsite data
- if: needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm -F @astryxdesign/docsite generate && pnpm -F @astryxdesign/docsite test
# Docsite browser contracts. The playground preview runs user-authored code
@@ -496,26 +520,42 @@ jobs:
# the docsite and drives `next start` in Chromium. Its outcome feeds the
# existing required docsite-test context; it is not another required lane.
docsite-browser:
- needs: [check-scope]
- if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != '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 != 'workflow_dispatch')
# The longest docsite owner; the Next.js production build uses every core
# it gets.
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- - uses: actions/checkout@v7
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: Check out the scope action
+ uses: actions/checkout@v7
+ with:
+ sparse-checkout: .github/actions/test-scope
+ path: .test-scope
+ persist-credentials: false
- - uses: ./.github/actions/setup
+ - name: Decide this job's scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+ - uses: actions/checkout@v7
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
+ - uses: ./.github/actions/setup
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- name: Install Playwright
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: npx playwright install chromium
# The production build imports every theme package's built entry and the
# canary component packages, on top of core. Core builds first; the rest
# depend on it and not on each other, so they build side by side.
- name: Build docsite workspace dependencies
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: |
pnpm -F @astryxdesign/core build
pnpm --workspace-concurrency=4 \
@@ -533,13 +573,15 @@ jobs:
build
- name: Build the docsite
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm -F @astryxdesign/docsite build
- name: Run docsite browser contracts
+ if: steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm test:docsite-browser
- name: Upload docsite browser evidence
- if: always()
+ if: always() && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: actions/upload-artifact@v7
with:
name: docsite-browser-evidence
@@ -659,8 +701,7 @@ jobs:
# build-storybook + typecheck below.
test-ui:
name: test-ui (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [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' && always() && !cancelled() && needs.check-scope.outputs.spec_only != '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 != 'workflow_dispatch') }}
# One runner ran the whole UI project in ~16 minutes and set the PR's wall
# time. Vitest's --shard gives each leg an equal share of the files; the
# two slowest files (~3.5 minutes each) bound a leg, so more legs stop
@@ -678,58 +719,67 @@ jobs:
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Skip heavy work for a specialized lane
- if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true'
+ if: steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.tooling_only == 'true'
run: echo "Specialized PR lane — skipping unrelated test suite"
# Two commits: a pull request's merge commit and its base parent, the
# diff a scoped run follows.
- uses: actions/checkout@v7
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
with:
fetch-depth: 2
- uses: ./.github/actions/setup
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- name: Check knowledge schema history
if: >-
matrix.shard == 1 &&
github.event_name == 'pull_request' &&
- needs.check-scope.outputs.docsite_only != 'true' &&
- needs.check-scope.outputs.spec_only != 'true' &&
- needs.check-scope.outputs.tooling_only != 'true'
+ steps.scope.outputs.docsite_only != 'true' &&
+ steps.scope.outputs.spec_only != 'true' &&
+ steps.scope.outputs.tooling_only != 'true'
run: |
git fetch origin "${{ github.event.pull_request.base.sha }}" --depth=1
node scripts/check-knowledge.mjs --base "${{ github.event.pull_request.base.sha }}"
- name: Check copyright headers
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: ./scripts/add-copyright.sh --check
- name: Check package.json exports are in sync
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: node scripts/sync-exports.js --check
- name: Verify the published CLI ./api type surface
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: node .github/scripts/cli-api-types-verify.mjs
- name: Check token docs are in sync
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: node scripts/generate-token-docs.mjs --check
# Fails when the lab readiness manifest claims a check the source tree
# contradicts — the report is derived, never hand-maintained.
- name: Check lab readiness manifest is current
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm lab:readiness:check
# A scoped pull request runs the tests Vitest's module graph relates to
@@ -738,7 +788,7 @@ jobs:
# runs every test.
- name: Run this shard of the UI tests
env:
- SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }}
+ SCOPED: ${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}
run: |
if [ "$SCOPED" = true ]; then
pnpm test:ui --changed=HEAD^1 --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }}
@@ -754,19 +804,18 @@ jobs:
else
pnpm test:ui --shard=${{ matrix.shard }}/${{ strategy.job-total }}
fi
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
# A child process isolates engine state, not CPU or memory contention.
# FR23 must wait until this runner's other UI workers have exited
# (AST-036); the other shards run on other machines.
- name: Run the isolated Markdown benchmark
run: pnpm test:ui:isolated
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
test-node:
name: test-node (${{ matrix.shard }}/${{ strategy.job-total }})
- needs: [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' && always() && !cancelled() && needs.check-scope.outputs.spec_only != '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 != 'workflow_dispatch') }}
# One runner ran the Node project in ~12 minutes. Vitest's --shard splits
# the files across the legs; `test` joins them.
strategy:
@@ -783,24 +832,33 @@ jobs:
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Skip heavy work for a specialized lane
- if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true'
+ if: steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.spec_only == 'true'
run: echo "Specialized PR lane — skipping unrelated test suite"
- uses: actions/checkout@v7
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true'
with:
fetch-depth: 2
- uses: ./.github/actions/setup
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true'
# Before Vitest starts. A scoped run's `--changed` walks the tests'
# import graphs before the global setup builds Core, and Vite answers an
@@ -809,13 +867,13 @@ jobs:
# "@astryxdesign/core/theme" imported by "@astryxdesign/cli"". The global
# setup then finds Core built and skips its own build.
- name: Build core package
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true'
run: pnpm -F @astryxdesign/core build
# Scoped like test-ui's run.
- name: Run this shard of the Node tests
env:
- SCOPED: ${{ github.event_name == 'pull_request' && needs.check-scope.outputs.full_suite == 'false' }}
+ SCOPED: ${{ github.event_name == 'pull_request' && steps.scope.outputs.full_suite == 'false' }}
run: |
if [ "$SCOPED" = true ]; then
pnpm test:node --changed=HEAD^1 --passWithNoTests --shard=${{ matrix.shard }}/${{ strategy.job-total }}
@@ -831,18 +889,18 @@ jobs:
else
pnpm test:node --shard=${{ matrix.shard }}/${{ strategy.job-total }}
fi
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true'
# Theme-family compilation is owned by `theme-build`, not Build. Until
# that surface has an admitted dedicated lane, broad CI keeps its browser
# contract inside the existing Node test owner rather than `test-build`.
# One leg runs it.
- name: Install Playwright for theme-family contract
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: npx playwright install chromium
- name: Run the theme-family contract
- if: matrix.shard == 1 && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: matrix.shard == 1 && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm test:theme-family
# The one pre-job left: a runner must be picked before its job starts, so
@@ -904,8 +962,7 @@ jobs:
# item through the exact pinned ShadCN client and compiles every written source.
registry-contract:
name: registry-contract (${{ matrix.leg }})
- needs: [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' && always() && !cancelled() && needs.check-scope.outputs.spec_only != '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 != 'workflow_dispatch') }}
# The preview and hidden production registries are generated and verified
# independently, so each gets its own leg (~9 minutes in one job). `test`
# joins them: the job result is success only when both passed.
@@ -917,68 +974,78 @@ jobs:
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Skip registry work for spec-only changes
- if: needs.check-scope.outputs.spec_only == 'true'
+ if: steps.scope.outputs.spec_only == 'true'
run: echo "Spec-only PR — public registry output cannot change"
- uses: actions/checkout@v7
- if: needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true'
- uses: ./.github/actions/setup
- if: needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true'
- name: Build registry package exports
- if: needs.check-scope.outputs.spec_only != 'true'
+ if: steps.scope.outputs.spec_only != 'true'
run: pnpm build
- name: Verify hidden production registry contract
- if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'production' && steps.scope.outputs.spec_only != 'true'
run: node internal/shadcn-registry/verify-production-gate.mjs
- name: Generate and validate the complete preview registry
- if: matrix.leg == 'preview' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'preview' && steps.scope.outputs.spec_only != 'true'
env:
DOCSITE_TARGET: canary
run: node apps/docsite/scripts/generate-data.mjs
- name: Install and build every preview registry item
- if: matrix.leg == 'preview' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'preview' && steps.scope.outputs.spec_only != 'true'
run: node internal/shadcn-registry/verify-full-catalog.mjs
- name: Generate the hidden production registry
- if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'production' && steps.scope.outputs.spec_only != 'true'
env:
DOCSITE_TARGET: latest
run: node apps/docsite/scripts/generate-data.mjs
- name: Verify hidden production discovery surfaces
- if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'production' && steps.scope.outputs.spec_only != 'true'
env:
ASTRYX_VERIFY_HIDDEN_PRODUCTION: '1'
NEXT_PUBLIC_DOCS_TARGET: latest
run: pnpm -F @astryxdesign/docsite exec vitest run src/__tests__/hidden-shadcn-production.test.ts
- name: Install and build every hidden production registry item
- if: matrix.leg == 'production' && needs.check-scope.outputs.spec_only != 'true'
+ if: matrix.leg == 'production' && steps.scope.outputs.spec_only != 'true'
env:
ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES: '1'
run: node internal/shadcn-registry/verify-full-catalog.mjs
- # Historical required check name. The Vitest lanes, Build test owner,
- # public registry contract, native Swift and interaction proofs always report
- # or explicitly skip, so this join projects their combined result without
- # creating another surface lane.
+ # Historical required check name. The Vitest lanes, the Build test owner,
+ # native Swift and the interaction proofs always report (each skips its own
+ # work outside its scope), so this join projects their combined result
+ # without creating another surface lane.
test:
needs:
[
check-scope,
+ release-bump,
test-ui,
test-node,
test-build,
@@ -986,24 +1053,47 @@ jobs:
test-native-swift,
pr-interaction,
]
- if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true') }}
+ if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && always() && !cancelled()) }}
runs-on: ubuntu-slim
permissions:
contents: read
+ pull-requests: read
steps:
- name: Require a branch in this repository or the ci:run label
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')) }}
run: |
echo "::error::Waiting for a maintainer's ci:run label: an outside contributor's pull request runs CI once a maintainer adds it (spec:AST-030 FR17)."
exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+
+ # A release-branch pull request is spec-only by classification, but its
+ # join still runs: it requires the release bump's own validation.
- uses: actions/checkout@v7
+ if: steps.scope.outputs.spec_only != 'true' || steps.scope.outputs.release_bump == 'true'
- 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 }}
- DOCSITE_ONLY: ${{ needs.check-scope.outputs.docsite_only }}
- SPEC_ONLY: ${{ needs.check-scope.outputs.spec_only }}
- TOOLING_ONLY: ${{ needs.check-scope.outputs.tooling_only }}
+ RELEASE_BUMP: ${{ steps.scope.outputs.release_bump }}
+ RELEASE_BUMP_RESULT: ${{ needs.release-bump.result }}
+ DOCSITE_ONLY: ${{ steps.scope.outputs.docsite_only }}
+ SPEC_ONLY: ${{ steps.scope.outputs.spec_only }}
+ TOOLING_ONLY: ${{ steps.scope.outputs.tooling_only }}
TEST_UI_RESULT: ${{ needs.test-ui.result }}
TEST_NODE_RESULT: ${{ needs.test-node.result }}
TEST_BUILD_RESULT: ${{ needs.test-build.result }}
@@ -1017,72 +1107,80 @@ jobs:
# jobs. Sandbox previews come from the exact-head Vercel deployment, so CI
# builds no Sandbox of its own.
build-storybook:
- needs: [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') && always() && !cancelled() && needs.check-scope.outputs.spec_only != '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 != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled()) }}
# Every browser lane waits for this job, and the package builds and the
# Storybook build run side by side (build-packages-and-storybook.mjs).
runs-on: ${{ (github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && github.triggering_actor != 'github-actions[bot]') && '4-core-ubuntu' || 'ubuntu-latest' }}
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 360 || 15 }}
permissions:
contents: read
+ pull-requests: read
outputs:
short_hash: ${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }}
pr_number: ${{ steps.urls.outputs.pr_number }}
steps:
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Skip heavy work for a specialized lane
- if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true'
+ if: steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.tooling_only == 'true'
run: echo "Specialized PR lane — skipping unrelated build"
- name: Checkout
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: actions/checkout@v7
with:
# Component evidence artifacts are named for and reviewed at the PR
# head, so build their Storybook bytes from that exact tree rather
# than GitHub's synthetic merge checkout.
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- # Depth 50 (same as check-scope) so analyze-pr.js's three-dot diff
+ # Depth 50 so analyze-pr.js's three-dot diff
# can find a merge base — depth 1 breaks it ("no merge base") and
# the analysis silently reported zero changed components.
fetch-depth: 50
- name: Verify Storybook source checkout
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
env:
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: test "$(git rev-parse HEAD)" = "$EXPECTED_HEAD_SHA"
- name: Fetch base branch for PR analysis
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
run: git fetch origin ${{ github.base_ref }} --depth=50
- name: Setup Node and pnpm
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: ./.github/actions/setup
# The same steps as `pnpm build` and the Storybook build, overlapped: a
# package builds once its workspace dependencies have, and Storybook once
# the packages its story index records are built.
- name: Build packages and Storybook
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: node .github/scripts/build-packages-and-storybook.mjs
- name: Verify package exports
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: node scripts/verify-exports.mjs
- name: Stamp Storybook source revision
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: git rev-parse HEAD > apps/storybook/dist/astryx-build-sha.txt
- name: Compute PR preview path
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
id: urls
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
@@ -1093,7 +1191,7 @@ jobs:
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
- name: Identify full release audit scope
- if: github.event_name == 'workflow_dispatch' && needs.check-scope.outputs.tooling_only != 'true'
+ if: github.event_name == 'workflow_dispatch' && steps.scope.outputs.tooling_only != 'true'
id: release
run: |
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
@@ -1101,7 +1199,7 @@ jobs:
printf '{"forceFullComponentAudits":true}\n' > analysis.json
- name: Upload Storybook artifact
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
uses: actions/upload-artifact@v7
with:
name: storybook-${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }}
@@ -1120,7 +1218,7 @@ jobs:
# Two paths, so the artifact is rooted at their common ancestor
# (packages/) — the download below unpacks it there.
- name: Upload built themes and core
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
uses: actions/upload-artifact@v7
with:
name: dists-${{ steps.release.outputs.short_hash || steps.urls.outputs.short_hash }}
@@ -1130,9 +1228,9 @@ jobs:
retention-days: 1
- name: Analyze components
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
env:
- FULL_SUITE: ${{ needs.check-scope.outputs.full_suite }}
+ FULL_SUITE: ${{ steps.scope.outputs.full_suite }}
run: |
# Browser audits follow the changed components and their reverse
# dependents, unless the change touches shared infrastructure.
@@ -1145,7 +1243,7 @@ jobs:
"${FORCE_FULL[@]}"
- name: Write PR comment metadata
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && github.event_name == 'pull_request'
run: |
# PR Comment reads this exact-run analysis. Storybook and Sandbox
# preview links come from the exact-head Vercel deployment.
@@ -1163,7 +1261,7 @@ jobs:
EOF
- name: Upload analysis artifact
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true' && (github.event_name == 'pull_request' || inputs.operation == 'release-check')
uses: actions/upload-artifact@v7
with:
name: pr-analysis
@@ -1177,29 +1275,47 @@ jobs:
# inside it, so no browser lane waits for the second build; the head sizes
# still come from build-storybook's analysis.
size-base:
- needs: [check-scope]
- if: github.event_name == 'pull_request' && needs.check-scope.result == 'success' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != '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')
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
+ pull-requests: read
steps:
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+
- name: Checkout
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 50
- name: Fetch base branch
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: git fetch origin ${{ github.base_ref }} --depth=50
- name: Setup Node and pnpm
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: ./.github/actions/setup
# A branch far behind main may have no merge base within the fetched
# history even after deepening. The report then keeps Before and Delta
# as N/A rather than failing the run.
- name: Check out the merge base
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
id: merge-base
env:
BASE_REF: ${{ github.base_ref }}
@@ -1220,7 +1336,7 @@ jobs:
# packages depend on them; another package builds only when the PR
# changes its source.
- name: Build the merge base's component packages
- if: steps.merge-base.outputs.found == 'true'
+ if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
working-directory: .size-base
env:
BASE_SHA: ${{ steps.merge-base.outputs.sha }}
@@ -1237,7 +1353,7 @@ jobs:
done
- name: Measure the merge base
- if: steps.merge-base.outputs.found == 'true'
+ if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: |
node .github/scripts/analyze-pr.js \
--base origin/${{ github.base_ref }} \
@@ -1247,7 +1363,7 @@ jobs:
--output size-base.json
- name: Upload base size stats
- if: steps.merge-base.outputs.found == 'true'
+ if: (steps.merge-base.outputs.found == 'true') && steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: actions/upload-artifact@v7
with:
name: pr-size-base
@@ -1259,36 +1375,44 @@ jobs:
# ~1.5 minutes sooner. The build and release-check joins require this job,
# so a type error still fails both.
typecheck:
- needs: [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') && always() && !cancelled() && needs.check-scope.outputs.spec_only != '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 != 'workflow_dispatch' || inputs.operation == 'release-check') && always() && !cancelled()) }}
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:
- - name: Require successful scope classification
- if: needs.check-scope.result != 'success'
- run: |
- echo "Change scope could not be classified; refusing to skip required work."
- exit 1
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
- name: Skip typechecks for a specialized lane
- if: needs.check-scope.outputs.docsite_only == 'true' || needs.check-scope.outputs.spec_only == 'true' || needs.check-scope.outputs.tooling_only == 'true'
+ if: steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.spec_only == 'true' || steps.scope.outputs.tooling_only == 'true'
run: echo "Specialized PR lane — skipping typechecks"
- name: Checkout
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup Node and pnpm
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: ./.github/actions/setup
# The doc, template and CLI typechecks resolve the built package types.
- name: Build packages
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm build
# Every workspace package's own `typecheck` script: its sources and
@@ -1297,7 +1421,7 @@ jobs:
# A PR head cut before `pnpm typecheck` existed runs the previous list,
# loaded from the merge commit these steps come from.
- name: Typecheck every package
- if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
env:
WORKFLOW_SHA: ${{ github.sha }}
run: |
@@ -1313,9 +1437,10 @@ jobs:
# Join gate that keeps the historical `build` check name: anything keyed on
# "build" being green (branch protection, tooling, habit) keeps working, and
- # it fails when build-storybook or typecheck fails. A skipped
- # build-storybook (a spec-only or release-bump pull request) skips this
- # gate too.
+ # it fails when build-storybook or typecheck fails. On a pull request
+ # outside its scope, build-storybook skips its own work and passes, so this
+ # gate passes. A skipped build-storybook job (a draft) skips this gate too;
+ # a fork pull request without `ci:run` still reports here.
build:
needs: [build-storybook, typecheck]
if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.draft) && (github.event_name != 'workflow_dispatch' && !cancelled() && (needs.build-storybook.result != 'skipped' || github.event_name == 'pull_request' && !(github.event.pull_request.head.repo.full_name == github.repository || contains(github.event.pull_request.labels.*.name, 'ci:run')))) }}
@@ -1874,8 +1999,7 @@ jobs:
# package ownership explicit; the historical `test` join above projects its
# result. Until runtime:build has a specialized route, broad CI dispatches it.
test-build:
- needs: [check-scope]
- if: github.event_name != 'workflow_dispatch' && needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != '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 != 'workflow_dispatch')
runs-on: ubuntu-24.04-arm
timeout-minutes: 15
permissions:
@@ -1884,35 +2008,56 @@ jobs:
contents: read
pull-requests: read
steps:
+ # This job decides its own scope (no separate scope job): the step
+ # reads the PR's file list and the base's trusted classifier, and
+ # everything is in scope when it cannot decide.
+ - name: 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 scope
+ id: scope
+ uses: ./.test-scope/.github/actions/test-scope
+
- uses: actions/checkout@v7
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- name: Per-author heavy-suite caps
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
uses: ./.github/actions/heavy-caps
# The daily heavy-run cap counts this step (spec:AST-030 FR16).
- name: Heavy suite runs
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: 'true'
- uses: ./.github/actions/setup
-
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
- name: Install Playwright
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: npx playwright install chromium
# The Build package's contracts: the packed consumer's dependencies, the
# production CSS-layer cascade, and cross-package StyleX markers in a
# real browser. `pnpm test:build` owns the list.
- name: Run Build package contracts
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm test:build
# The vibe-tests fixtures share this Playwright-equipped runner: the
# canonical setup compositions and the guest fixture contrast need a
# production browser render.
- name: Verify canonical setup compositions
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
env:
ASTRYX_CANONICAL_SETUP_BROWSER: '1'
run: pnpm vitest run internal/vibe-tests/setup-test/setup-canonical.test.ts --project node --maxWorkers=1
- name: Verify guest fixture contrast
+ if: steps.scope.outputs.docsite_only != 'true' && steps.scope.outputs.spec_only != 'true' && steps.scope.outputs.tooling_only != 'true'
run: pnpm -F @astryxdesign/vibe-tests fixtures:contrast
# The full visual plan first loads every Core story to learn which theming