Skip to content

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

TypeScript

ci: name the Build test owner explicitly (#6327)

Cindy Zhangc87f73fb0ced
diff --git a/.github/scripts/ci-test-join.mjs b/.github/scripts/ci-test-join.mjs
new file mode 100644
index 0000000000..ca2357716e
--- /dev/null
+++ b/.github/scripts/ci-test-join.mjs
@@ -0,0 +1,56 @@
+#!/usr/bin/env node
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @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.
+ */
+
+const requiredSuccess = [
+ ['test-ui', process.env.TEST_UI_RESULT],
+ ['test-node', process.env.TEST_NODE_RESULT],
+ ['registry-contract', process.env.REGISTRY_CONTRACT_RESULT],
+];
+
+function fail(message) {
+ console.error(message);
+ process.exitCode = 1;
+}
+
+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'}`);
+}
+
+const scopes = [
+ ['docsite_only', process.env.DOCSITE_ONLY],
+ ['spec_only', process.env.SPEC_ONLY],
+ ['tooling_only', process.env.TOOLING_ONLY],
+];
+for (const [name, value] of scopes) {
+ if (value !== 'true' && value !== 'false') {
+ fail(`${name}: ${value ?? 'missing'}`);
+ }
+}
+
+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
new file mode 100644
index 0000000000..f06eb2693d
--- /dev/null
+++ b/.github/scripts/ci-test-join.test.mjs
@@ -0,0 +1,76 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @file Mutation-sensitive scope/status matrix for the pull-request test join. */
+
+import {execFileSync} from 'node:child_process';
+import path from 'node:path';
+
+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',
+ TEST_UI_RESULT: 'success',
+ TEST_NODE_RESULT: 'success',
+ TEST_BUILD_RESULT: 'success',
+ REGISTRY_CONTRACT_RESULT: 'success',
+};
+
+function run(overrides = {}) {
+ try {
+ const stdout = execFileSync(process.execPath, [script], {
+ encoding: 'utf8',
+ env: {...process.env, ...broad, ...overrides},
+ stdio: ['ignore', 'pipe', 'pipe'],
+ });
+ return {status: 0, output: stdout};
+ } catch (error) {
+ return {
+ status: error.status ?? 1,
+ output: `${error.stdout ?? ''}${error.stderr ?? ''}`,
+ };
+ }
+}
+
+describe('pull-request test join', () => {
+ it('requires every owner on broad scope', () => {
+ expect(run()).toMatchObject({status: 0});
+ for (const [name, value] of [
+ ['TEST_UI_RESULT', 'failure'],
+ ['TEST_NODE_RESULT', 'cancelled'],
+ ['TEST_BUILD_RESULT', 'skipped'],
+ ['REGISTRY_CONTRACT_RESULT', 'failure'],
+ ]) {
+ expect(run({[name]: value}), name).toMatchObject({status: 1});
+ }
+ });
+
+ it.each(['DOCSITE_ONLY', 'SPEC_ONLY', 'TOOLING_ONLY'])(
+ 'accepts a skipped Build owner only for %s',
+ scope => {
+ 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});
+ });
+
+ it('rejects missing or invalid scope decisions', () => {
+ expect(run({SPEC_ONLY: ''})).toMatchObject({status: 1});
+ expect(run({TOOLING_ONLY: 'unknown'})).toMatchObject({status: 1});
+ });
+});
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjs
index 27fa232910..85883ae00a 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -131,12 +131,26 @@ describe.each(Object.entries(WORKFLOWS))(
it('fails the join when any lane fails', () => {
// `needs` alone does not fail a job whose `if` is `always()`; the join
- // has to assert the results it waited for.
- const join = runLines(workflow.jobs.test);
- for (const lane of lanes) {
- expect(join, `join does not assert ${lane}`).toContain(
- `needs.${lane}.result }}" = "success"`,
+ // has to pass every result to its fail-closed contract.
+ const join = workflow.jobs.test;
+ if (file === 'ci.yml') {
+ const contract = join.steps.find(step =>
+ step.run?.includes('.github/scripts/ci-test-join.mjs'),
);
+ expect(contract).toBeDefined();
+ for (const lane of lanes) {
+ const key = `${lane.replaceAll('-', '_').toUpperCase()}_RESULT`;
+ expect(contract.env[key], `join does not pass ${lane}`).toContain(
+ `needs.${lane}.result`,
+ );
+ }
+ } else {
+ const commands = runLines(join);
+ for (const lane of lanes) {
+ expect(commands, `join does not assert ${lane}`).toContain(
+ `needs.${lane}.result }}" = "success"`,
+ );
+ }
}
});
diff --git a/.github/scripts/ci-tooling-routing.test.mjs b/.github/scripts/ci-tooling-routing.test.mjs
index bb35fbf7cf..715a530380 100644
--- a/.github/scripts/ci-tooling-routing.test.mjs
+++ b/.github/scripts/ci-tooling-routing.test.mjs
@@ -24,6 +24,8 @@ 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 BROAD_ONLY =
+ "needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'";
function step(job, name) {
return job.steps.find(candidate => candidate.name === name);
@@ -96,8 +98,38 @@ describe('Node-tooling CI routing', () => {
).run;
expect(componentCheck).toContain('needs.check-scope.outputs.tooling_only');
expect(componentCheck).toContain('has_components=false');
- expect(ci.jobs['theme-layers'].if).toContain(TOOLING_FALSE);
+ expect(ci.jobs['test-build'].if).toBe(BROAD_ONLY);
+ expect(step(ci.jobs['test-build'], 'Build the Vite plugin').run).toBe(
+ 'pnpm -F @astryxdesign/build build',
+ );
+ expect(
+ step(ci.jobs['test-build'], 'Run Build CSS-layer cascade guard').run,
+ ).toBe('node .github/scripts/theme-layer-cascade.js');
expect(ci.jobs['fixture-contrast'].if).toContain(TOOLING_FALSE);
+ const familyCommands = new Map([
+ [
+ 'Install Playwright for theme-family contract',
+ 'npx playwright install chromium',
+ ],
+ [
+ 'Build theme-family compiler dependencies',
+ 'pnpm -F @astryxdesign/core build',
+ ],
+ [
+ 'Generate the maintained theme-family fixture',
+ 'pnpm -F @astryxdesign/sandbox generate:theme-family',
+ ],
+ [
+ 'Run theme family cascade guard',
+ 'node .github/scripts/theme-family-cascade.js',
+ ],
+ ]);
+ for (const [name, command] of familyCommands) {
+ const ownerStep = step(ci.jobs['test-node'], name);
+ expect(ownerStep.if).toBe(BROAD_ONLY);
+ expect(ownerStep.run).toBe(command);
+ expect(step(ci.jobs['test-build'], name)).toBeUndefined();
+ }
});
it('keeps required build and docsite contexts green without their heavy work', () => {
@@ -130,15 +162,26 @@ 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',
'test-ui',
'test-node',
+ 'test-build',
'registry-contract',
]);
expect(ci.jobs.build.needs).toEqual(['build-storybook', 'build-sandbox']);
- const testJoin = step(ci.jobs.test, 'Assert every test gate succeeded').run;
- expect(testJoin).toContain('needs.test-node.result');
- expect(testJoin).toContain('needs.test-ui.result');
- expect(testJoin).toContain('needs.registry-contract.result');
+ 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(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 }}',
+ TEST_UI_RESULT: '${{ needs.test-ui.result }}',
+ TEST_NODE_RESULT: '${{ needs.test-node.result }}',
+ TEST_BUILD_RESULT: '${{ needs.test-build.result }}',
+ REGISTRY_CONTRACT_RESULT: '${{ needs.registry-contract.result }}',
+ });
const buildJoin = step(
ci.jobs.build,
'Assert parallel builds succeeded',
diff --git a/.github/scripts/shadcn-registry-ci.test.mjs b/.github/scripts/shadcn-registry-ci.test.mjs
index aa28e3d3ab..56cbda8a8b 100644
--- a/.github/scripts/shadcn-registry-ci.test.mjs
+++ b/.github/scripts/shadcn-registry-ci.test.mjs
@@ -43,11 +43,13 @@ describe('ShadCN registry CI contract', () => {
);
expect(ci.jobs.test.needs).toContain('registry-contract');
- const join = ci.jobs.test.steps
- .map(candidate => candidate.run ?? '')
- .join('\n');
- expect(join).toContain('needs.registry-contract.result');
- expect(join).toContain('needs.registry-contract.result }}" = "success"');
+ const join = ci.jobs.test.steps.find(candidate =>
+ candidate.run?.includes('.github/scripts/ci-test-join.mjs'),
+ );
+ expect(join).toBeDefined();
+ expect(join.env.REGISTRY_CONTRACT_RESULT).toBe(
+ '${{ needs.registry-contract.result }}',
+ );
});
it('runs every material step except on the trusted spec-only lane', () => {
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a143410642..21b8c490bd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -295,6 +295,25 @@ jobs:
- run: pnpm vitest run --project node
if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-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`.
+ - name: Install Playwright for theme-family contract
+ if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ run: npx playwright install chromium
+
+ - name: Build theme-family compiler dependencies
+ if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ run: pnpm -F @astryxdesign/core build
+
+ - name: Generate the maintained theme-family fixture
+ if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ run: pnpm -F @astryxdesign/sandbox generate:theme-family
+
+ - name: Run theme family cascade guard
+ if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
+ run: node .github/scripts/theme-family-cascade.js
+
# Public registry contract. Generation proves schema, dependency, route-lock,
# alias, and release-gating invariants; the final step drives every canonical
# item through the exact pinned ShadCN client and compiles every written source.
@@ -359,23 +378,29 @@ jobs:
ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES: '1'
run: node internal/shadcn-registry/verify-full-catalog.mjs
- # Historical required check name. The two Vitest lanes and the public
- # registry contract always report, so this asserts success rather than
- # tolerating a skip.
+ # Historical required check name. The Vitest lanes, Build test owner, and
+ # public registry contract always report or explicitly skip, so this join
+ # projects their combined result without creating another surface lane.
test:
- needs: [test-ui, test-node, registry-contract]
+ needs: [check-scope, test-ui, test-node, test-build, registry-contract]
if: ${{ always() && !cancelled() }}
runs-on: ubuntu-slim
- permissions: {}
+ permissions:
+ contents: read
steps:
- - name: Assert every test gate succeeded
- run: |
- echo "test-ui: ${{ needs.test-ui.result }}"
- echo "test-node: ${{ needs.test-node.result }}"
- echo "registry-contract: ${{ needs.registry-contract.result }}"
- [ "${{ needs.test-ui.result }}" = "success" ] || exit 1
- [ "${{ needs.test-node.result }}" = "success" ] || exit 1
- [ "${{ needs.registry-contract.result }}" = "success" ] || exit 1
+ - uses: actions/checkout@v7
+
+ - name: Require expected test-owner outcomes
+ env:
+ 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 }}
+ TEST_UI_RESULT: ${{ needs.test-ui.result }}
+ TEST_NODE_RESULT: ${{ needs.test-node.result }}
+ TEST_BUILD_RESULT: ${{ needs.test-build.result }}
+ REGISTRY_CONTRACT_RESULT: ${{ needs.registry-contract.result }}
+ run: node .github/scripts/ci-test-join.mjs
# Build storybook + typecheck + analyze components (parallel with test and
# build-sandbox). Uploads the storybook preview and analysis artifacts for
@@ -777,17 +802,12 @@ jobs:
- name: Run accessibility spec-test contracts
run: pnpm test:a11y-contract
- # The layer order Astryx promises is Astryx < theme < product, and which
- # declaration paints is a cascade fact no jsdom test can settle: the build has
- # been wrong in both directions inside one week — unsplit, so StyleX outranked
- # every theme, then wrapped instead of split, so an app's own styles lost to
- # one. vite.build.test.ts reads the built stylesheet; this renders it.
- #
- # Its own job on purpose. pr-a11y, where the sibling Chromium guards live,
- # runs only when packages/core or packages/lab changed, and what this guards
- # is packages/build — so hosting it there would skip it on exactly the PRs
- # that can break it. Gated like `test` instead: everything but docsite-only.
- theme-layers:
+ # Build package test owner. The plugin's production CSS partition is a Build
+ # integration contract: source inspection cannot prove which declaration
+ # paints after Vite emits the final bundle. The `test-build` name makes that
+ # 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: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true' && needs.check-scope.outputs.tooling_only != 'true'
runs-on: 2-core-ubuntu-arm
@@ -806,21 +826,9 @@ jobs:
- name: Build the Vite plugin
run: pnpm -F @astryxdesign/build build
- - name: Run theme layer cascade guard
+ - name: Run Build CSS-layer cascade guard
run: node .github/scripts/theme-layer-cascade.js
- # AST-034's family contract is also a cascade contract: structural tests
- # cannot prove identity switching, nested boundaries, media surfaces, or
- # equal-specificity unrelated stylesheets in either physical order.
- - name: Build theme-family compiler dependencies
- run: pnpm -F @astryxdesign/core build
-
- - name: Generate the maintained theme-family fixture
- run: pnpm -F @astryxdesign/sandbox generate:theme-family
-
- - name: Run theme family cascade guard
- run: node .github/scripts/theme-family-cascade.js
-
# Guest token boundaries cross portals and the host light/dark cascade. This
# requires a production browser render; source and jsdom checks cannot prove
# which custom properties paint the portaled surfaces.