Skip to content

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

TypeScript

ci: the default touched check runs the browser accessibility specs a pull request changes (#9316)

Cindy Zhangf78b2050a833
diff --git a/.github/scripts/a11y-pr-contracts.mjs b/.github/scripts/a11y-pr-contracts.mjs
index abbb22332d..7f240d8748 100644
--- a/.github/scripts/a11y-pr-contracts.mjs
+++ b/.github/scripts/a11y-pr-contracts.mjs
@@ -34,7 +34,16 @@
* the PR's component scope.
*
* Unknown scope (no merge base, no changed-file list) runs every scoped spec,
- * never fewer. Locally, `pnpm test:a11y-contract:pr origin/main --dry-run`
+ * never fewer.
+ *
+ * `--changed-only <file>` (the default touched-components check, spec:AST-030
+ * FR12): run only the browser specs the pull request adds or modifies, listed
+ * one per line in <file>. It reads no component scope or title, runs no
+ * component audit, and widens to nothing else; a changed `release-only` or
+ * `audit` spec still waits for the release check or its audit pull request.
+ * To stay inside the job's 15-minute budget it runs at most
+ * CHANGED_SPEC_LIMIT files, in path order, and stops after
+ * CHANGED_SPEC_BUDGET_MS; the rest are reported as not run, never as passed. Locally, `pnpm test:a11y-contract:pr origin/main --dry-run`
* prints what a PR from this branch would run.
*
* The CI step loads this file from the merge commit its steps come from
@@ -286,6 +295,42 @@ export function selectSpecs({
return selected;
}
+/** The most changed spec files the default check runs (spec:AST-030 FR12). */
+export const CHANGED_SPEC_LIMIT = 4;
+
+/** The changed-spec run's wall-clock bound, inside the job's 15 minutes. */
+export const CHANGED_SPEC_BUDGET_MS = 8 * 60 * 1000;
+
+/**
+ * Split a changed-only selection at the limit: the first files, in path order,
+ * run; the rest are not run, with the label that runs them.
+ * @param {{file: string, reason: string}[]} selected
+ * @param {number} [limit]
+ */
+export function withinBudget(selected, limit = CHANGED_SPEC_LIMIT) {
+ const ordered = [...selected].sort((a, b) => a.file.localeCompare(b.file));
+ return {
+ run: ordered.slice(0, limit),
+ notRun: ordered.slice(limit).map(({file}) => ({
+ file,
+ reason: `over the default check's ${limit}-file budget; add ci:run-a11y to run it`,
+ })),
+ };
+}
+
+/**
+ * The changed-only selection: of the specs the routing selects, only those the
+ * pull request itself adds or modifies, each because it changed.
+ * @param {{file: string, reason: string}[]} selected
+ * @param {string[]} changedPaths
+ */
+export function changedOnly(selected, changedPaths) {
+ const changed = new Set(changedPaths);
+ return selected
+ .filter(({file}) => changed.has(file))
+ .map(({file}) => ({file, reason: 'spec changed'}));
+}
+
/**
* Path segments that never hold knowledge records. Mirrors
* `IGNORED_COMPONENT_KNOWLEDGE_SEGMENTS` in `knowledge-paths.cjs` (a test
@@ -468,20 +513,39 @@ function main() {
process.argv.slice(2).find(arg => !arg.startsWith('-')) ||
(process.env.GITHUB_ACTIONS ? undefined : 'origin/main');
const policySha = process.env.WORKFLOW_SHA;
+ const changedOnlyIndex = process.argv.indexOf('--changed-only');
+ const changedOnlyFile =
+ changedOnlyIndex === -1 ? null : process.argv[changedOnlyIndex + 1];
const specs = listSpecs(root).map(file => ({
file,
routing: parseRouting(readPolicySource(root, file, policySha)),
}));
- const changedPaths = isPullRequest ? changedSinceMergeBase(base) : [];
- const components = isPullRequest ? readComponents(root) : [];
- const title = isPullRequest ? (process.env.PR_TITLE ?? '') : '';
- const selected = selectSpecs({
+ const changedPaths =
+ changedOnlyFile != null
+ ? fs.readFileSync(changedOnlyFile, 'utf8').split('\n').filter(Boolean)
+ : isPullRequest
+ ? changedSinceMergeBase(base)
+ : [];
+ const components =
+ isPullRequest && changedOnlyFile == null ? readComponents(root) : [];
+ const title =
+ isPullRequest && changedOnlyFile == null
+ ? (process.env.PR_TITLE ?? '')
+ : '';
+ const routed = selectSpecs({
specs,
- isPullRequest,
+ // The changed-only run is always a pull request's.
+ isPullRequest: isPullRequest || changedOnlyFile != null,
changedPaths,
components,
title,
});
+ const budgeted =
+ changedOnlyFile != null
+ ? withinBudget(changedOnly(routed, changedPaths))
+ : {run: routed, notRun: []};
+ const selected = budgeted.run;
+ const notRun = budgeted.notRun;
const [audited] = auditedComponents(title);
const auditConfigFile = '.github/a11y-audit-axe.json';
const plan = planFor(
@@ -506,6 +570,7 @@ function main() {
components,
audit: plan && {component: audited, ...plan},
selected,
+ notRun,
},
null,
2,
@@ -515,6 +580,9 @@ function main() {
`PR accessibility specs: ${selected.length} of ${specs.length} discovered.`,
);
for (const {file, reason} of selected) console.log(` ${file} (${reason})`);
+ for (const {file, reason} of notRun) {
+ console.log(`::notice title=Not run::${file}: ${reason}`);
+ }
if (process.argv.includes('--dry-run')) return 0;
let status = 0;
@@ -546,6 +614,11 @@ function main() {
process.env.GITHUB_ACTIONS ? 'list,json,github' : 'list,json',
'--output',
'pr-a11y-output',
+ // The changed-only run stops at its budget: an interrupted spec fails
+ // the run, so a spec that did not finish is never read as passed.
+ ...(changedOnlyFile != null
+ ? ['--global-timeout', String(CHANGED_SPEC_BUDGET_MS)]
+ : []),
'--project',
'chromium',
],
diff --git a/.github/scripts/a11y-pr-contracts.test.mjs b/.github/scripts/a11y-pr-contracts.test.mjs
index 20a8256148..6aab4af072 100644
--- a/.github/scripts/a11y-pr-contracts.test.mjs
+++ b/.github/scripts/a11y-pr-contracts.test.mjs
@@ -23,6 +23,9 @@ import {
auditArgs,
auditedComponents,
auditPlan,
+ CHANGED_SPEC_BUDGET_MS,
+ CHANGED_SPEC_LIMIT,
+ changedOnly,
changedSinceMergeBase,
kebab,
planFor,
@@ -31,7 +34,13 @@ import {
isKnowledgeRecord,
selectSpecs,
specOwners,
+ withinBudget,
} from './a11y-pr-contracts.mjs';
+import {
+ A11Y_SPEC_GLOBS,
+ WEBKIT_A11Y_SPEC_GLOBS,
+ isA11ySpecFile,
+} from './lib/a11y-spec-files.mjs';
const root = path.resolve(import.meta.dirname, '../..');
@@ -53,6 +62,125 @@ const pr = (specs, overrides = {}) =>
const BINDING =
'packages/core/src/Chat/__tests__/ChatSendButton.a11y.chromium.spec.ts';
+// spec:AST-030 FR12: the default touched-components check runs the browser
+// specs a pull request adds or modifies, and only those.
+describe('changedOnly (the default check runs changed specs)', () => {
+ const NEW_SPEC =
+ 'packages/core/src/Radio/__tests__/RadioKeyboard.a11y.chromium.spec.ts';
+ const ALWAYS =
+ 'packages/core/src/__tests__/DisabledFocus.a11y.chromium.spec.ts';
+ const RELEASE =
+ 'packages/core/src/Table/__tests__/TableFull.a11y.chromium.spec.ts';
+ const AUDIT =
+ 'packages/core/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts';
+ const specs = [
+ spec(NEW_SPEC),
+ spec(ALWAYS, ['// @pr-a11y always']),
+ spec(RELEASE, ['// @pr-a11y release-only']),
+ spec(AUDIT, ['// @pr-a11y audit Drawer']),
+ spec(BINDING),
+ ];
+ const run = changed =>
+ changedOnly(
+ selectSpecs({
+ specs,
+ isPullRequest: true,
+ changedPaths: changed,
+ components: [],
+ title: '',
+ }),
+ changed,
+ );
+
+ it('selects a spec the pull request adds, which no label-free run reached before', () => {
+ expect(run([NEW_SPEC])).toEqual([{file: NEW_SPEC, reason: 'spec changed'}]);
+ });
+
+ it('runs a changed always-spec too, but never an unchanged one', () => {
+ expect(run([NEW_SPEC]).map(({file}) => file)).not.toContain(ALWAYS);
+ expect(run([ALWAYS])).toEqual([{file: ALWAYS, reason: 'spec changed'}]);
+ });
+
+ it('leaves a changed release-only spec to the release check', () => {
+ expect(run([RELEASE])).toEqual([]);
+ });
+
+ it('stops the changed-only run at eight minutes, inside the job budget', () => {
+ expect(CHANGED_SPEC_LIMIT).toBe(4);
+ expect(CHANGED_SPEC_BUDGET_MS).toBe(8 * 60 * 1000);
+ const runner = fs.readFileSync(
+ path.join(root, '.github/scripts/a11y-pr-contracts.mjs'),
+ 'utf8',
+ );
+ // Only the changed-only run carries the global timeout.
+ expect(runner).toMatch(
+ /changedOnlyFile != null\s*\?\s*\['--global-timeout', String\(CHANGED_SPEC_BUDGET_MS\)\]\s*:\s*\[\]/,
+ );
+ });
+
+ it('leaves a changed audit spec to its own component-audit pull request', () => {
+ expect(run([AUDIT])).toEqual([]);
+ });
+
+ it('runs at most the budget of files, in path order, and reports the rest as not run', () => {
+ const files = Array.from(
+ {length: CHANGED_SPEC_LIMIT + 2},
+ (_, i) => `packages/core/src/C${i}/__tests__/C${i}.a11y.chromium.spec.ts`,
+ );
+ const {run: ran, notRun} = withinBudget(
+ [...files].reverse().map(file => ({file, reason: 'spec changed'})),
+ );
+ expect(ran.map(({file}) => file)).toEqual(
+ [...files].sort().slice(0, CHANGED_SPEC_LIMIT),
+ );
+ expect(notRun).toHaveLength(2);
+ expect(notRun[0].reason).toContain('ci:run-a11y');
+ });
+
+ it('widens to nothing else: a changed component folder selects no spec', () => {
+ expect(run(['packages/core/src/Chat/ChatSendButton.tsx'])).toEqual([]);
+ });
+});
+
+describe('a11y-spec-files (one spec list for Playwright and the touched check)', () => {
+ it('is the list playwright.config.ts runs', () => {
+ const config = fs.readFileSync(
+ path.join(root, 'playwright.config.ts'),
+ 'utf8',
+ );
+ expect(config).toContain('testMatch: [...A11Y_SPEC_GLOBS]');
+ expect(config).toContain('testMatch: [...WEBKIT_A11Y_SPEC_GLOBS]');
+ expect(A11Y_SPEC_GLOBS).toEqual(
+ expect.arrayContaining([...WEBKIT_A11Y_SPEC_GLOBS]),
+ );
+ });
+
+ it('matches each kind of browser accessibility spec and nothing else', () => {
+ expect(isA11ySpecFile(BINDING)).toBe(true);
+ expect(
+ isA11ySpecFile(
+ 'packages/core/src/Dialog/DialogSecondDocument.a11y.browser.spec.ts',
+ ),
+ ).toBe(true);
+ expect(
+ isA11ySpecFile('internal/a11y-spec/src/patterns/menu.chromium.spec.ts'),
+ ).toBe(true);
+ expect(isA11ySpecFile('packages/core/src/Chat/ChatSendButton.tsx')).toBe(
+ false,
+ );
+ expect(
+ isA11ySpecFile(
+ 'packages/core/src/Chat/__tests__/ChatSendButton.a11y.test.tsx',
+ ),
+ ).toBe(false);
+ expect(
+ isA11ySpecFile(
+ 'internal/interaction-harness/src/harness.interaction.browser.spec.ts',
+ ),
+ ).toBe(false);
+ });
+});
+
describe('parseRouting', () => {
it('defaults to scoped with no tokens', () => {
expect(parseRouting('// Copyright\nimport x;\n')).toEqual({
@@ -501,12 +629,13 @@ describe('repository specs', () => {
path.join(root, 'playwright.config.ts'),
'utf8',
);
+ expect(config).toContain('testMatch: [...A11Y_SPEC_GLOBS]');
for (const glob of [
'internal/a11y-spec/src/**/*.chromium.spec.ts',
'packages/*/src/**/*.a11y.chromium.spec.ts',
'packages/*/src/**/*.a11y.browser.spec.ts',
]) {
- expect(config).toContain(`'${glob}'`);
+ expect(A11Y_SPEC_GLOBS).toContain(glob);
}
expect(files.length).toBeGreaterThan(100);
});
@@ -531,9 +660,9 @@ describe('isKnowledgeRecord', () => {
});
it('treats a component record as a record and its fixtures as not', () => {
- expect(isKnowledgeRecord('docs/specs/components/Chat/ChatLayout.spec.md')).toBe(
- true,
- );
+ expect(
+ isKnowledgeRecord('docs/specs/components/Chat/ChatLayout.spec.md'),
+ ).toBe(true);
expect(
isKnowledgeRecord('packages/core/src/Chat/.hidden/ChatLayout.spec.md'),
).toBe(false);
diff --git a/.github/scripts/lib/a11y-spec-files.mjs b/.github/scripts/lib/a11y-spec-files.mjs
new file mode 100644
index 0000000000..37152191b8
--- /dev/null
+++ b/.github/scripts/lib/a11y-spec-files.mjs
@@ -0,0 +1,56 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file a11y-spec-files.mjs
+ * @input Repository-relative paths
+ * @output The browser accessibility spec globs `playwright.config.ts` runs,
+ * and `isA11ySpecFile`
+ * @position The one list of browser accessibility spec files. The Playwright
+ * config matches them, and the default touched-components check (spec:AST-030
+ * FR12) uses the same list to find the specs a pull request changes. No
+ * imports and no `import.meta`, so Playwright's config loader and plain Node
+ * both load it before dependencies are installed.
+ */
+
+/** Every browser accessibility spec, run in Chromium. */
+export const A11Y_SPEC_GLOBS = Object.freeze([
+ // The contract's own conforming/violating fixture proof.
+ 'internal/a11y-spec/src/**/*.chromium.spec.ts',
+ // Component bindings.
+ 'packages/*/src/**/*.a11y.chromium.spec.ts',
+ 'packages/*/src/**/*.a11y.browser.spec.ts',
+]);
+
+/** The specs that also run in WebKit. */
+export const WEBKIT_A11Y_SPEC_GLOBS = Object.freeze([
+ 'packages/*/src/**/*.a11y.browser.spec.ts',
+]);
+
+/**
+ * A glob in Playwright's subset (`**` any depth, `*` within one segment) as a
+ * regular expression over a repository-relative path.
+ * @param {string} glob
+ */
+export function globToRegExp(glob) {
+ let source = '';
+ for (let i = 0; i < glob.length; i += 1) {
+ const char = glob[i];
+ if (char === '*' && glob[i + 1] === '*') {
+ // `**/` matches zero or more whole segments.
+ source += glob[i + 2] === '/' ? '(?:.*/)?' : '.*';
+ i += glob[i + 2] === '/' ? 2 : 1;
+ } else if (char === '*') {
+ source += '[^/]*';
+ } else {
+ source += char.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
+ }
+ }
+ return new RegExp(`^${source}$`);
+}
+
+const PATTERNS = A11Y_SPEC_GLOBS.map(globToRegExp);
+
+/** Whether a repository-relative path is a browser accessibility spec. */
+export function isA11ySpecFile(file) {
+ return PATTERNS.some(pattern => pattern.test(file));
+}
diff --git a/.github/scripts/touched-components.test.mjs b/.github/scripts/touched-components.test.mjs
index a4fd32668e..b67649c4f5 100644
--- a/.github/scripts/touched-components.test.mjs
+++ b/.github/scripts/touched-components.test.mjs
@@ -579,6 +579,46 @@ describe('pr-touched-components routing', () => {
expect(checkout.with?.ref).toBeUndefined();
});
+ // spec:AST-030 FR12: a browser accessibility spec the change adds or
+ // modifies is caught on its own pull request, not first on main.
+ it('runs the changed browser accessibility specs, and only on a pull request that changes one', () => {
+ const find = step('Find the changed browser accessibility specs');
+ expect(find.env.FILES_PATH).toBe(
+ '${{ steps.scope.outputs.changed_files_path }}',
+ );
+ // The same spec list playwright.config.ts runs, not a copy of its globs.
+ expect(find.run).toContain(
+ 'import {isA11ySpecFile} from "./.github/scripts/lib/a11y-spec-files.mjs";',
+ );
+ expect(find.run).not.toContain('spec\\.ts');
+ const runSpecs = step('Run the changed browser accessibility specs');
+ expect(runSpecs.if).toBe(
+ "always() && steps.playwright.outcome == 'success' && steps.specs.outputs.has_specs == 'true'",
+ );
+ expect(runSpecs.run).toBe(
+ 'node .github/scripts/a11y-pr-contracts.mjs --changed-only "$SPECS_PATH"',
+ );
+ // A failing spec turns the job red: no continue-on-error.
+ expect(runSpecs['continue-on-error']).toBeUndefined();
+ // Bounded inside the job's 15 minutes, past the runner's own 8-minute stop.
+ expect(runSpecs['timeout-minutes']).toBe(9);
+ // Setup, Storybook and Playwright run for a spec-only change too.
+ for (const name of [
+ 'Setup Node and pnpm',
+ 'Download Storybook artifact',
+ 'Install Playwright',
+ ]) {
+ expect(step(name).if).toBe(
+ "steps.touched.outputs.has_components == 'true' || steps.specs.outputs.has_specs == 'true'",
+ );
+ }
+ expect(step('Upload touched-components results').with.path).toContain(
+ 'pr-a11y-evidence/',
+ );
+ // Still advisory: no required context depends on this job.
+ expect(job.name).toBe('Touched components (visual, accessibility, RTL)');
+ });
+
it('exposes the wide-change flag and count', () => {
expect(job.outputs).toEqual({
wide_change: '${{ steps.touched.outputs.wide_change }}',
@@ -621,12 +661,16 @@ describe('pr-touched-components routing', () => {
expect(
step('Skip when no component changed or the change is wide').if,
).toBe("steps.touched.outputs.has_components != 'true'");
- const scopeIndex = job.steps.findIndex(
- candidate => candidate.id === 'touched',
+ // Every later step runs for touched components, or (setup, Storybook,
+ // Playwright, the spec run and the upload) for a changed browser spec.
+ const skipIndex = job.steps.findIndex(
+ candidate =>
+ candidate.name ===
+ 'Skip when no component changed or the change is wide',
);
- for (const candidate of job.steps.slice(scopeIndex + 2)) {
- expect(candidate.if, candidate.name).toContain(
- "steps.touched.outputs.has_components == 'true'",
+ for (const candidate of job.steps.slice(skipIndex + 1)) {
+ expect(candidate.if, candidate.name).toMatch(
+ /steps\.touched\.outputs\.has_components == 'true'|steps\.specs\.outputs\.has_specs == 'true'/,
);
}
});
diff --git a/.github/scripts/visual-gate/README.md b/.github/scripts/visual-gate/README.md
index acec25158d..cee1744d3d 100644
--- a/.github/scripts/visual-gate/README.md
+++ b/.github/scripts/visual-gate/README.md
@@ -36,7 +36,9 @@ PR accessibility is intentionally smaller. With `ci:run-a11y` it runs an
explicit changed-component axe scope (including grouped-folder owners), plus
the fast modal-close, theme-var, and story-play guards. Without the label, the
default touched-components check audits only the touched components' stories,
-without the guards. Empty/shared scope never falls back to all stories, and
+without the guards, and runs up to four browser accessibility spec files the
+pull request adds or modifies (scoped and `always` specs; `audit` and
+`release-only` specs wait). Empty/shared scope never falls back to all stories, and
missing or approximate analysis fails rather than granting an empty scope.
The full axe roster, whole-repository accessibility spec-test contracts and their
pixel/evidence uploads run only during `release-check`.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b528095560..f0ae0c27ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3162,6 +3162,34 @@ jobs:
--head-sha "$HEAD_SHA" \
--out touched-components.json
+ # A scoped or always browser accessibility spec the change adds or
+ # modifies runs here by itself (spec:AST-030 FR12), so it is checked on
+ # its own pull request; audit and release-only specs still wait. No such
+ # file, no work.
+ - name: Find the changed browser accessibility specs
+ id: specs
+ env:
+ FILES_PATH: ${{ steps.scope.outputs.changed_files_path }}
+ run: |
+ list="$RUNNER_TEMP/changed-a11y-specs.txt"
+ : > "$list"
+ if [ -n "$FILES_PATH" ] && [ -f "$FILES_PATH" ]; then
+ # The same spec globs playwright.config.ts runs.
+ node --input-type=module -e '
+ import fs from "node:fs";
+ import {isA11ySpecFile} from "./.github/scripts/lib/a11y-spec-files.mjs";
+ const paths = fs.readFileSync(process.argv[1], "utf8").split("\n");
+ for (const file of paths.filter(isA11ySpecFile)) console.log(file);
+ ' "$FILES_PATH" > "$list"
+ fi
+ echo "path=$list" >> "$GITHUB_OUTPUT"
+ if [ -s "$list" ]; then
+ echo "has_specs=true" >> "$GITHUB_OUTPUT"
+ echo "Changed browser accessibility specs:"; cat "$list"
+ else
+ echo "has_specs=false" >> "$GITHUB_OUTPUT"
+ fi
+
- name: Skip when no component changed or the change is wide
if: steps.touched.outputs.has_components != 'true'
env:
@@ -3175,13 +3203,13 @@ jobs:
fi
- name: Setup Node and pnpm
- if: steps.touched.outputs.has_components == 'true'
+ if: steps.touched.outputs.has_components == 'true' || steps.specs.outputs.has_specs == 'true'
uses: ./.github/actions/setup
with:
install: 'false'
- name: Download Storybook artifact
- if: steps.touched.outputs.has_components == 'true'
+ if: steps.touched.outputs.has_components == 'true' || steps.specs.outputs.has_specs == 'true'
uses: actions/download-artifact@v8
with:
name: storybook-${{ needs.build-storybook.outputs.short_hash }}
@@ -3189,7 +3217,7 @@ jobs:
- name: Install Playwright
id: playwright
- if: steps.touched.outputs.has_components == 'true'
+ if: steps.touched.outputs.has_components == 'true' || steps.specs.outputs.has_specs == 'true'
run: pnpm install --frozen-lockfile && npx playwright install chromium
# The same changed-component filters an opted-in pull request uses.
@@ -3235,6 +3263,22 @@ jobs:
test -s "rtl-reports/$PACKAGE.json"
done
+ # Only the changed spec files, in Chromium, with their routing lines read
+ # from this merge commit; a changed release-only or audit spec still
+ # waits. A failing or unfinished spec turns this advisory job red, and a
+ # file over the budget is reported as not run.
+ - name: Run the changed browser accessibility specs
+ id: changed-specs
+ if: always() && steps.playwright.outcome == 'success' && steps.specs.outputs.has_specs == 'true'
+ # The runner runs at most four changed files and stops at eight
+ # minutes; this bounds a hung browser inside the job's 15 minutes.
+ timeout-minutes: 9
+ env:
+ ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ WORKFLOW_SHA: ${{ github.sha }}
+ SPECS_PATH: ${{ steps.specs.outputs.path }}
+ run: node .github/scripts/a11y-pr-contracts.mjs --changed-only "$SPECS_PATH"
+
# The visual result comes from pr-visual, the one visual owner: its
# default touched check, or its full check under ci:run-visual.
- name: Download pr-visual's verdict
@@ -3268,7 +3312,7 @@ jobs:
--out touched-components.json
- name: Upload touched-components results
- if: always() && (steps.touched.outputs.has_components == 'true' || steps.touched.outputs.wide_change == 'true')
+ if: always() && (steps.touched.outputs.has_components == 'true' || steps.touched.outputs.wide_change == 'true' || steps.specs.outputs.has_specs == 'true')
uses: actions/upload-artifact@v7
with:
name: touched-components
@@ -3276,6 +3320,7 @@ jobs:
touched-components.json
a11y-report.json
rtl-reports/
+ pr-a11y-evidence/
if-no-files-found: ignore
retention-days: 7
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5cdea3cb1a..0949a4c2d8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -510,11 +510,11 @@ CI collects tests by file name, never from a list of test files, so a new test
needs no edit to `.github/workflows/`. Put the test where its kind is collected
and CI picks it up:
-| Kind | Put it | Collected by | CI job |
-| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------- |
-| Unit and integration (jsdom or Node) | `*.test.ts(x)` / `*.test.mjs` beside the code, in a path the `ui` or `node` project of `vitest.config.ts` includes | the `ui` and `node` Vitest projects | `test-ui`, `test-node` (sharded) |
-| Browser accessibility or engine behavior | `*.a11y.chromium.spec.ts` (Chromium) or `*.a11y.browser.spec.ts` (Chromium and WebKit) under `packages/*/src/` | `pnpm test:a11y-contract`; pull requests run `pnpm test:a11y-contract:pr` | `pr-a11y`; every spec in the release check's `a11y-contracts` |
-| Visual regression | a Storybook story | the visual plan | `pr-visual` |
+| Kind | Put it | Collected by | CI job |
+| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Unit and integration (jsdom or Node) | `*.test.ts(x)` / `*.test.mjs` beside the code, in a path the `ui` or `node` project of `vitest.config.ts` includes | the `ui` and `node` Vitest projects | `test-ui`, `test-node` (sharded) |
+| Browser accessibility or engine behavior | `*.a11y.chromium.spec.ts` (Chromium) or `*.a11y.browser.spec.ts` (Chromium and WebKit) under `packages/*/src/` | `pnpm test:a11y-contract`; pull requests run `pnpm test:a11y-contract:pr` | `pr-a11y` (with `ci:run-a11y`); up to four changed spec files in the touched-components check; every spec in the release check's `a11y-contracts` |
+| Visual regression | a Storybook story | the visual plan | `pr-visual` |
A browser spec runs on a pull request when the PR changes the spec, its
component folder, or the component it is named after (`ChatSendButton.a11y.chromium.spec.ts`
@@ -534,7 +534,9 @@ any other value:
These routes apply when a pull request runs the accessibility owner, which it
does only with the `ci:run-a11y` label; `main` and release checks run every
-spec. `pnpm test:a11y-contract:pr origin/main --dry-run` prints what a pull request
+spec. Without the label, the touched-components check still runs up to four
+spec files the pull request adds or modifies, by these same routes, so a
+changed `audit` or `release-only` spec waits. `pnpm test:a11y-contract:pr origin/main --dry-run` prints what a pull request
from your branch would run (component tokens need CI's `analysis.json`; without
it the runner says so and leaves those specs out). A spec writes its receipts under
`test-results/<name>/` or, for a component audit, a top-level
@@ -935,10 +937,13 @@ Storybook story for anything you added or altered.
- **Every pull request runs a touched-components check** (visual,
accessibility and RTL for only the components it changes): its visual part
runs in the visual job, and accessibility and RTL in one job on a standard
- runner. It skips a wide change, one that touches more than five components
- or changes shared styles (themes, tokens, shared `.stylex.ts` files); add
- the `ci:run-*` labels for those. It is advisory: no required check waits for
- it.
+ runner. It also runs up to four browser accessibility spec files the change
+ adds or modifies, by themselves, so a new spec is checked on its own pull
+ request (an `audit` or `release-only` spec still waits for its audit pull
+ request or the release check), wide changes included. Its component audits
+ skip a wide change, one that touches more than five components or changes
+ shared styles (themes, tokens, shared `.stylex.ts` files); add the
+ `ci:run-*` labels for those. It is advisory: no required check waits for it.
- **A pull request that changes CI states its CI impact.** When it changes a
workflow, a composite action or a CI script, its description carries a
`CI impact:` line: each changed job's runner class (standard or
diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.md
index 3d72b37bf2..dc614e8785 100644
--- a/docs/specs/AST-030/spec.md
+++ b/docs/specs/AST-030/spec.md
@@ -221,7 +221,7 @@ they are separately named.
is the full suites behind the labels. No required context depends on the
touched check, and it records each touched component's pass, fail, changed
or not-run result per suite, or that the change was wide and how many
- components it touched, for the pull-request comment. An opted-in PR's a11y MUST remain scoped to changed components
+ components it touched, for the pull-request comment. The default check also runs, in Chromium, the browser accessibility spec files the change adds or modifies, and only those files, routed by their own `@pr-a11y` lines read from the merge commit: a changed `release-only` spec waits for the release check, a changed `audit` spec for its component-audit pull request, and the run widens to no other spec. It stays inside the check's 15-minute budget by running at most four changed spec files, in path order, and stopping after eight minutes; a file over the limit is recorded as not run, with the label that runs it, and a spec that does not finish fails the run, so neither reads as passed. A pull request that changes no such file runs none, and a failing one turns the advisory check red on that pull request, wide changes included. An opted-in PR's a11y MUST remain scoped to changed components
plus fast interaction guards; full a11y
sweeps, whole-repository spec-test contracts, and their evidence uploads MUST
run only for `release-check` in this workflow. Missing,
@@ -272,7 +272,8 @@ they are separately named.
audits every component each of those folders implements. A Changeset renders nothing and widens no audit. A changed module that no component bundle holds adds none, and without
a readable build the audits run in full. PR accessibility, when it runs, stays
scoped to changed components (FR12). Without a label, the default
- touched-components check audits only the touched components and never
+ touched-components check audits only the touched components, and runs only
+ the browser accessibility spec files the change adds or modifies; it never
widens (FR12). Shared infrastructure runs the full suite of the owners the
pull request runs (visual, accessibility and RTL only with their `ci:run-*`
labels, FR12): root
@@ -470,6 +471,7 @@ The nightly perf lane is the one scheduled measurement outside them (FR18).
| FR10 | surface-admission and routing contract tests | existing surface; proposed surface with and without the full admission contract | a new surface adds lanes without its approved paths, commands, ownership, projections, and routing tests |
| FR11 | surface owner, internal-job, and required-join contract tests | Build package browser behavior; CLI; theme-family broad fallback; mixed Core+CLI | a second owner is routed for one surface, an internal job masquerades as a lane, an owned failure misses its join, or an unrelated owner runs |
| FR12 | Storybook visual-plan, canonical workflow, and repository-owner guard tests | PR scope; full-plan maintenance; report-only publication; deployment/a11y/RTL/vibe artifacts | another workflow captures or compares pixels, a renamed or aliased owner escapes the guard, or legitimate non-visual artifacts are rejected |
+| FR12 | `touched-components.test.mjs` changed-spec routing; `a11y-pr-contracts.test.mjs` `changedOnly` cases | a pull request that adds a browser accessibility spec; one that changes an `always` spec; one that changes a `release-only` or an `audit` spec; one that changes more spec files than the limit; a component change with no spec change | a pull request that adds a browser accessibility spec that fails is not caught on that pull request, an unchanged, `release-only` or `audit` spec runs in the default check, a file over the limit is reported as passed, or the default check widens past the changed spec files |
| FR13 | classifier, workflow contract, component-analysis and RTL-scope tests | component change; shared module; Changeset beside code; infrastructure path; incomplete list; no build | an infrastructure path is scoped, a file-system guard test is skipped, a reverse dependent leaves visual/RTL or enters PR accessibility, or a full-suite event is narrowed |
| FR14 | `workflow-paths.test.mjs` over every workflow | path allowlist; required-context workflow | a `paths-ignore`, a match-all or exclusion glob, or a path filter on a workflow that reports a required context fails |
| FR15 | workflow contract and reconciler tests | ENGOWNER spec PR; owner command; other comment; fork review; non-spec PR; run over the request budget; maintainer dispatch | `review-required` succeeds while spec approval is missing, another workflow publishes a review context, a fork review starts the spec checks, a non-command comment starts a runner, or an over-budget run decides |
@@ -608,6 +610,7 @@ while the full
suites stay behind their labels; the
modal-close, theme-var and story-play guards are steps of the accessibility
owner, so they run with it, after merge or on a labelled pull request. A
+browser accessibility spec file a pull request adds or modifies runs in that same job, by itself, so a new scoped or `always` spec is checked on its own pull request rather than first on `main`'s release check; an `audit` or `release-only` spec still first runs on its audit pull request or the release check. It costs nothing on a pull request that changes no spec. A
failure on `main` is repaired forward with an atomic pull request, not reverted
first. This supersedes DEC-5's choice to keep these checks off main pushes:
running the browser suites on every update of every open pull request costs
diff --git a/playwright.config.ts b/playwright.config.ts
index 01bf7cb32e..ed73cbf3bd 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -29,11 +29,16 @@
* `pnpm test:a11y-contract:pr`; each spec's `@pr-a11y` header lines decide when
* (`.github/scripts/a11y-pr-contracts.mjs`). A new spec needs no workflow edit.
*
- * SYNC: When a package gains an accessibility binding outside these globs, add
- * its glob here and in `.github/scripts/a11y-pr-contracts.test.mjs`.
+ * SYNC: The spec globs live in `.github/scripts/lib/a11y-spec-files.mjs`, which
+ * the default touched-components check also reads to find changed specs. A
+ * package with an accessibility binding outside them adds its glob there.
*/
import {defineConfig, devices} from '@playwright/test';
+import {
+ A11Y_SPEC_GLOBS,
+ WEBKIT_A11Y_SPEC_GLOBS,
+} from './.github/scripts/lib/a11y-spec-files.mjs';
// GitHub Actions sets CI=true; some runners set it to an empty string. One
// definition, so `forbidOnly` and the reporter choice cannot disagree.
@@ -57,13 +62,7 @@ function contractWorkers(): number {
export default defineConfig({
testDir: '.',
- testMatch: [
- // The contract's own conforming/violating fixture proof.
- 'internal/a11y-spec/src/**/*.chromium.spec.ts',
- // Component bindings.
- 'packages/*/src/**/*.a11y.chromium.spec.ts',
- 'packages/*/src/**/*.a11y.browser.spec.ts',
- ],
+ testMatch: [...A11Y_SPEC_GLOBS],
// The contract mounts, focuses, and types into one page at a time, so a spec
// file's tests run in order on one worker (`fullyParallel: false`). Workers
// are separate processes, each with its own browser, so they share no
@@ -85,7 +84,7 @@ export default defineConfig({
{name: 'chromium', use: {...devices['Desktop Chrome']}},
{
name: 'webkit',
- testMatch: ['packages/*/src/**/*.a11y.browser.spec.ts'],
+ testMatch: [...WEBKIT_A11Y_SPEC_GLOBS],
use: {...devices['Desktop Safari']},
},
],