Skip to content

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

TypeScript

ci(a11y): the touched check audits every changed story no other audit covers (#10081)

Cindy Zhang9e559e928ff1
diff --git a/.github/scripts/accessibility-audit.js b/.github/scripts/accessibility-audit.js
index fc4be60918..a3ac849e7c 100644
--- a/.github/scripts/accessibility-audit.js
+++ b/.github/scripts/accessibility-audit.js
@@ -1,13 +1,14 @@
#!/usr/bin/env node
// Copyright (c) Meta Platforms, Inc. and affiliates.
-
/**
* @description Runs accessibility audits on component stories using axe-core
* @input --storybook-dir <path> --output <file> [--components <comma-separated>]
* [--stories <comma-separated-story-ids>] [--port <number, 0 = any free>]
* [--changed-story-files <file>] (the stories of these changed story files
- * that no component owns, instead of --components or --stories)
+ * that no other audit covers, instead of --components or --stories)
+ * [--covered-components <list>] (with --changed-story-files: the component
+ * filters the touched audit already runs, whose stories are left out)
* [--ready-selector <css-selector>] [--concurrency <pages, default 1>]
* [--shard <i>/<n> --shard-output <file>] (scan every n-th story, write it)
* [--merge-shards <dir>] (read a complete shard set instead of scanning)
@@ -24,8 +25,8 @@
* package-qualified ownership with the RTL audit.
*/
-const { chromium } = require('playwright');
-const { AxeBuilder } = require('@axe-core/playwright');
+const {chromium} = require('playwright');
+const {AxeBuilder} = require('@axe-core/playwright');
const fs = require('node:fs');
const path = require('node:path');
const http = require('node:http');
@@ -55,14 +56,14 @@ const {
legacyBaselineStoryKeys,
ownerForA11yStory,
} = require('./lib/a11y-story-identity');
-const {changedUnownedStoryIds} = require('./lib/a11y-changed-stories');
+const {changedUncoveredStoryIds} = require('./lib/a11y-changed-stories');
const args = process.argv.slice(2);
-const getArg = (name) => {
+const getArg = name => {
const idx = args.indexOf(`--${name}`);
return idx !== -1 ? args[idx + 1] : null;
};
-const hasFlag = (name) => args.includes(`--${name}`);
+const hasFlag = name => args.includes(`--${name}`);
const storybookDir = getArg('storybook-dir') || 'apps/storybook/dist';
const outputFile = getArg('output') || 'a11y-report.json';
@@ -75,8 +76,19 @@ const components = (componentsArg || '').split(',').filter(Boolean);
const storiesArg = getArg('stories');
const requestedStories = (storiesArg || '').split(',').filter(Boolean);
const changedStoryFilesArg = getArg('changed-story-files');
-if (changedStoryFilesArg !== null && (storiesArg !== null || componentsArg !== null)) {
- throw new Error('--changed-story-files selects its own stories; pass it without --stories or --components');
+if (
+ changedStoryFilesArg !== null &&
+ (storiesArg !== null || componentsArg !== null)
+) {
+ throw new Error(
+ '--changed-story-files selects its own stories; pass it without --stories or --components',
+ );
+}
+const coveredComponents = (getArg('covered-components') || '')
+ .split(',')
+ .filter(Boolean);
+if (coveredComponents.length > 0 && changedStoryFilesArg === null) {
+ throw new Error('--covered-components only narrows --changed-story-files');
}
// --components present but EMPTY means the caller derived an explicit empty
// audit set (pr-a11y on a PR whose core/src changes map to no component —
@@ -129,11 +141,11 @@ const FREEZE_CSS = `
// Rules to disable — these are Storybook-context false positives, not component issues
const DISABLED_RULES = [
- 'html-has-lang', // Storybook controls <html>, not the component
- 'document-title', // iframe has no <title>, irrelevant for components
- 'landmark-one-main', // component stories are fragments, not full pages
+ 'html-has-lang', // Storybook controls <html>, not the component
+ 'document-title', // iframe has no <title>, irrelevant for components
+ 'landmark-one-main', // component stories are fragments, not full pages
'page-has-heading-one', // same — not a full page
- 'region', // content doesn't need to be in landmarks in story isolation
+ 'region', // content doesn't need to be in landmarks in story isolation
];
// Wait until the story stops moving before scanning it. A story can paint
@@ -168,7 +180,7 @@ async function settleLayout(page) {
// Simple static file server
function createServer(dir, port) {
- return new Promise((resolve) => {
+ return new Promise(resolve => {
const server = http.createServer((req, res) => {
let filePath = path.join(dir, req.url === '/' ? 'index.html' : req.url);
filePath = filePath.split('?')[0];
@@ -197,7 +209,7 @@ function createServer(dir, port) {
res.end('Not found');
return;
}
- res.writeHead(200, { 'Content-Type': contentTypes[ext] || 'text/plain' });
+ res.writeHead(200, {'Content-Type': contentTypes[ext] || 'text/plain'});
res.end(data);
});
});
@@ -246,9 +258,7 @@ async function routedStoryIds(stories, componentFilters) {
componentRoutesForFilters,
storyIdsForComponentFilters,
unresolvedComponentFilters,
- } = await import(
- '../../apps/storybook/rtl-audit/rtl-audit-coverage.mjs'
- );
+ } = await import('../../apps/storybook/rtl-audit/rtl-audit-coverage.mjs');
const publicComponentsByPackage = Object.fromEntries(
COMPONENT_PACKAGES.map(pkg => [
pkg.name,
@@ -301,13 +311,15 @@ async function runAccessibilityAudit() {
console.log('No components to audit (--components is empty) — skipping.');
const report = {
components: {},
- summary: { componentsAudited: 0, totalViolations: 0 },
+ summary: {componentsAudited: 0, totalViolations: 0},
};
fs.writeFileSync(outputFile, JSON.stringify(report, null, 2));
return report;
}
- console.log(`Components to audit: ${components.length > 0 ? components.join(', ') : 'all affected'}`);
+ console.log(
+ `Components to audit: ${components.length > 0 ? components.join(', ') : 'all affected'}`,
+ );
const storybookPath = path.resolve(process.cwd(), storybookDir);
@@ -340,17 +352,28 @@ async function runAccessibilityAudit() {
const changedFiles = fs.existsSync(changedStoryFilesArg)
? fs.readFileSync(changedStoryFilesArg, 'utf8').split('\n')
: [];
- selectedStories = changedUnownedStoryIds(stories, routed.allRoutes, changedFiles);
+ // The touched components' audit already runs their stories.
+ const coveredIds =
+ coveredComponents.length > 0
+ ? (await routedStoryIds(stories, coveredComponents)).storyIds
+ : [];
+ selectedStories = changedUncoveredStoryIds(
+ stories,
+ changedFiles,
+ coveredIds,
+ );
if (selectedStories.length === 0) {
- console.log('No changed story without a component owner — skipping.');
+ console.log('No changed story outside the touched audit — skipping.');
const report = {
components: {},
- summary: { componentsAudited: 0, totalViolations: 0 },
+ summary: {componentsAudited: 0, totalViolations: 0},
};
fs.writeFileSync(outputFile, JSON.stringify(report, null, 2));
return report;
}
- console.log(`Changed stories no component owns: ${selectedStories.join(', ')}`);
+ console.log(
+ `Changed stories no other audit covers: ${selectedStories.join(', ')}`,
+ );
}
const routedIds = new Set(routed.storyIds);
const requestedStoryIds = new Set(selectedStories ?? []);
@@ -408,7 +431,7 @@ async function runAccessibilityAudit() {
try {
const context = scanning
? await browser.newContext({
- viewport: { width: 1280, height: 720 },
+ viewport: {width: 1280, height: 720},
reducedMotion: 'reduce',
})
: null;
@@ -484,11 +507,11 @@ async function runAccessibilityAudit() {
await settleLayout(page);
// Run axe-core accessibility analysis
- const results = await new AxeBuilder({ page })
+ const results = await new AxeBuilder({page})
.disableRules(DISABLED_RULES)
.analyze();
console.log(
- `✓ Audited: ${component} / ${story.name} - ${results.violations.length} issues`
+ `✓ Audited: ${component} / ${story.name} - ${results.violations.length} issues`,
);
return results.violations;
} catch (e) {
@@ -530,7 +553,10 @@ async function runAccessibilityAudit() {
while (!failed && next < items.length) {
const {component, story} = items[next++];
try {
- violationsByStory.set(story.id, await scanStory(component, story));
+ violationsByStory.set(
+ story.id,
+ await scanStory(component, story),
+ );
} catch (e) {
failed = true;
throw e;
@@ -597,10 +623,10 @@ async function runAccessibilityAudit() {
// Keep first 3 nodes for display (cap to avoid bloat)
if (agg.nodes.length < 3) {
agg.nodes.push(
- ...violation.nodes.slice(0, 3 - agg.nodes.length).map((n) => ({
+ ...violation.nodes.slice(0, 3 - agg.nodes.length).map(n => ({
html: n.html.substring(0, 200),
target: n.target,
- }))
+ })),
);
}
}
@@ -649,10 +675,7 @@ async function runAccessibilityAudit() {
for (const auditedStory of auditedStories) {
for (const legacyStory of legacyBaselineStoryKeys(auditedStory.storyId)) {
legacyBaselineAliases[legacyStory] ??= [];
- const canonicalStory = storyKey(
- auditedStory.owner,
- auditedStory.storyId,
- );
+ const canonicalStory = storyKey(auditedStory.owner, auditedStory.storyId);
if (!legacyBaselineAliases[legacyStory].includes(canonicalStory)) {
legacyBaselineAliases[legacyStory].push(canonicalStory);
}
@@ -688,7 +711,7 @@ async function runAccessibilityAudit() {
function loadBaselineFile(filePath) {
if (!fs.existsSync(filePath)) {
console.warn(`Baseline file not found at ${filePath} — treating as empty`);
- return { version: 1, entries: [] };
+ return {version: 1, entries: []};
}
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
@@ -706,7 +729,7 @@ function applyBaselineGate(report) {
: null;
fs.writeFileSync(
baselineFile,
- JSON.stringify(buildBaseline(report, { existing }), null, 2) + '\n'
+ JSON.stringify(buildBaseline(report, {existing}), null, 2) + '\n',
);
console.log(`Baseline written to ${baselineFile}`);
return 0;
@@ -714,15 +737,17 @@ function applyBaselineGate(report) {
const baseline = loadBaselineFile(baselineFile);
const diff = diffAgainstBaseline(report, baseline);
- console.log(formatDiffSummary(diff, { baselinePath: baselineFile }));
- const resolvedWarning = formatResolvedWarning(diff, { baselinePath: baselineFile });
+ console.log(formatDiffSummary(diff, {baselinePath: baselineFile}));
+ const resolvedWarning = formatResolvedWarning(diff, {
+ baselinePath: baselineFile,
+ });
if (resolvedWarning && process.env.GITHUB_ACTIONS === 'true') {
console.log(resolvedWarning);
}
if (diff.newViolations.length > 0 && failOnNew) {
console.error(
- `\nFailing: ${diff.newViolations.length} accessibility violation(s) not in baseline.`
+ `\nFailing: ${diff.newViolations.length} accessibility violation(s) not in baseline.`,
);
return 1;
}
@@ -730,13 +755,13 @@ function applyBaselineGate(report) {
}
runAccessibilityAudit()
- .then((report) => {
+ .then(report => {
// A shard writes per-story results only; the merge run gates.
if (report === null) return;
const code = applyBaselineGate(report);
if (code !== 0) process.exitCode = code;
})
- .catch((e) => {
+ .catch(e => {
console.error('Accessibility audit failed:', e);
process.exit(1);
});
diff --git a/.github/scripts/lib/a11y-changed-stories.js b/.github/scripts/lib/a11y-changed-stories.js
index 4b1a55098c..c88fac8fd6 100644
--- a/.github/scripts/lib/a11y-changed-stories.js
+++ b/.github/scripts/lib/a11y-changed-stories.js
@@ -2,12 +2,13 @@
/**
* @file a11y-changed-stories.js
- * @input The Storybook index's story entries, the story routes the audit
- * builds (story id and owner), and the pull request's changed file paths.
- * @output The ids of the changed story files' stories that no component owns.
+ * @input The Storybook index's story entries, the pull request's changed file
+ * paths, and the story ids the touched components' audit already runs.
+ * @output The ids of the changed story files' stories that no other audit in
+ * the pull request covers.
* @position Selects the stories the touched-components check audits on their
- * own (spec:AST-030 FR12): a touched component's audit never reaches a story
- * whose owner is no component.
+ * own (spec:AST-030 FR12): a changed story is audited whoever owns it, and a
+ * touched component's audit already runs its own stories.
*/
const path = require('node:path');
@@ -21,19 +22,19 @@ function storyFilePath(importPath) {
}
/**
- * The stories of the changed story files whose owner is no component. A story
- * with no route counts as unowned, so it is audited rather than dropped.
+ * The stories of the changed story files that the touched components' audit
+ * does not run: a story an untouched component owns, or one no component owns.
*
* @param {Record<string, {type?: string, importPath?: string}>} stories
- * @param {Array<{id: string, component: string}>} routes
* @param {string[]} changedFiles
+ * @param {Iterable<string>} coveredIds story ids another audit already runs
* @returns {string[]}
*/
-function changedUnownedStoryIds(stories, routes, changedFiles) {
+function changedUncoveredStoryIds(stories, changedFiles, coveredIds = []) {
const changed = new Set(
changedFiles.map(file => file.trim()).filter(Boolean),
);
- const owners = new Map(routes.map(route => [route.id, route.component]));
+ const covered = new Set(coveredIds);
return Object.entries(stories)
.filter(
([id, story]) =>
@@ -41,10 +42,10 @@ function changedUnownedStoryIds(stories, routes, changedFiles) {
!id.endsWith('--docs') &&
typeof story.importPath === 'string' &&
changed.has(storyFilePath(story.importPath)) &&
- String(owners.get(id) ?? 'unknown/').startsWith('unknown/'),
+ !covered.has(id),
)
.map(([id]) => id)
.sort();
}
-module.exports = {changedUnownedStoryIds, storyFilePath};
+module.exports = {changedUncoveredStoryIds, storyFilePath};
diff --git a/.github/scripts/lib/a11y-changed-stories.test.mjs b/.github/scripts/lib/a11y-changed-stories.test.mjs
index 309a166475..6dc7902fc9 100644
--- a/.github/scripts/lib/a11y-changed-stories.test.mjs
+++ b/.github/scripts/lib/a11y-changed-stories.test.mjs
@@ -2,21 +2,25 @@
/**
* @file a11y-changed-stories.test.mjs
- * Tests for the selection of changed stories no component owns, the ones the
- * touched-components check audits on their own (spec:AST-030 FR12).
+ * Tests for the selection of changed stories no other audit covers, the ones
+ * the touched-components check audits on their own (spec:AST-030 FR12).
*/
import fs from 'node:fs';
import path from 'node:path';
import {describe, expect, it} from 'vitest';
-import {changedUnownedStoryIds, storyFilePath} from './a11y-changed-stories.js';
+import {
+ changedUncoveredStoryIds,
+ storyFilePath,
+} from './a11y-changed-stories.js';
import {STORY_FILE} from '../touched-components.mjs';
const root = path.resolve(import.meta.dirname, '../../..');
const story = importPath => ({type: 'story', importPath});
-// #9985's shape: an `a11y/` story file whose stories route to an unknown
-// owner, beside a component's own story file.
+// #9985's shape: an `a11y/` story file no component owns. #9992's shape: a
+// story added to an untouched component's file (Resizable) while the change
+// touched another component (LayoutPanel).
const stories = {
'a11y-scroll-region-name--content-scrolls': story(
'./stories/ScrollRegionA11y.stories.tsx',
@@ -28,24 +32,15 @@ const stories = {
type: 'docs',
importPath: './stories/ScrollRegionA11y.stories.tsx',
},
- 'core-alertdialog--delete': story('./stories/AlertDialog.stories.tsx'),
+ 'core-resizable--collapsing-scroll-panel-fixture': story(
+ './stories/Resizable.stories.tsx',
+ ),
+ 'core-resizable--default': story('./stories/Resizable.stories.tsx'),
+ 'core-layoutpanel--default': story('./stories/LayoutPanel.stories.tsx'),
'core-chip--default': story('../../packages/core/src/Chip/Chip.stories.tsx'),
- 'pattern-x--unrouted': story('./stories/Unrouted.stories.tsx'),
};
-const routes = [
- {
- id: 'a11y-scroll-region-name--content-scrolls',
- component: 'unknown/a11y-scroll-region-name',
- },
- {
- id: 'a11y-scroll-region-name--panel-scrolls',
- component: 'unknown/a11y-scroll-region-name',
- },
- {id: 'core-alertdialog--delete', component: 'core/AlertDialog'},
- {id: 'core-chip--default', component: 'core/Chip'},
-];
-describe('changed stories no component owns', () => {
+describe('changed stories no other audit covers', () => {
it('reads an index import path as a repository path', () => {
expect(storyFilePath('./stories/X.stories.tsx')).toBe(
'apps/storybook/stories/X.stories.tsx',
@@ -57,7 +52,7 @@ describe('changed stories no component owns', () => {
it("selects a changed `a11y/` story file's stories, not its docs page", () => {
expect(
- changedUnownedStoryIds(stories, routes, [
+ changedUncoveredStoryIds(stories, [
'apps/storybook/stories/ScrollRegionA11y.stories.tsx',
]),
).toEqual([
@@ -66,47 +61,57 @@ describe('changed stories no component owns', () => {
]);
});
- it("leaves a component's own stories to its touched-component audit", () => {
+ it("selects a changed story an untouched component owns (#9992's fixture)", () => {
expect(
- changedUnownedStoryIds(stories, routes, [
- 'apps/storybook/stories/AlertDialog.stories.tsx',
- 'packages/core/src/Chip/Chip.stories.tsx',
- ]),
- ).toEqual([]);
+ changedUncoveredStoryIds(
+ stories,
+ [
+ 'apps/storybook/stories/Resizable.stories.tsx',
+ 'apps/storybook/stories/LayoutPanel.stories.tsx',
+ ],
+ ['core-layoutpanel--default'],
+ ),
+ ).toEqual([
+ 'core-resizable--collapsing-scroll-panel-fixture',
+ 'core-resizable--default',
+ ]);
});
- it('audits a story with no route rather than dropping it', () => {
+ it("leaves a touched component's stories to its own audit", () => {
expect(
- changedUnownedStoryIds(stories, routes, [
- 'apps/storybook/stories/Unrouted.stories.tsx',
- ]),
- ).toEqual(['pattern-x--unrouted']);
+ changedUncoveredStoryIds(
+ stories,
+ ['packages/core/src/Chip/Chip.stories.tsx'],
+ ['core-chip--default'],
+ ),
+ ).toEqual([]);
});
it('selects nothing for unchanged story files or an empty list', () => {
expect(
- changedUnownedStoryIds(stories, routes, [
+ changedUncoveredStoryIds(stories, [
'packages/core/src/Chip/Chip.tsx',
'',
]),
).toEqual([]);
- expect(changedUnownedStoryIds(stories, routes, [])).toEqual([]);
+ expect(changedUncoveredStoryIds(stories, [])).toEqual([]);
});
- it('selects the six #9985 stories from the real Storybook index, when one is built', () => {
+ it("selects #9992's fixture from the real Storybook index, when one is built", () => {
const index = path.join(root, 'apps/storybook/dist/index.json');
if (!fs.existsSync(index)) return;
const entries = JSON.parse(fs.readFileSync(index, 'utf8')).entries;
- const unknown = Object.keys(entries)
- .filter(id => id.startsWith('a11y-scroll-region-name--'))
- .map(id => ({id, component: 'unknown/a11y-scroll-region-name'}));
- const ids = changedUnownedStoryIds(entries, unknown, [
- 'apps/storybook/stories/ScrollRegionA11y.stories.tsx',
- ]);
- expect(ids.length).toBeGreaterThanOrEqual(6);
- expect(ids.every(id => id.startsWith('a11y-scroll-region-name--'))).toBe(
- true,
+ if (!entries['core-resizable--collapsing-scroll-panel-fixture']) return;
+ const layoutPanel = Object.keys(entries).filter(id =>
+ id.startsWith('core-layoutpanel--'),
+ );
+ const ids = changedUncoveredStoryIds(
+ entries,
+ ['apps/storybook/stories/Resizable.stories.tsx'],
+ layoutPanel,
);
+ expect(ids).toContain('core-resizable--collapsing-scroll-panel-fixture');
+ expect(ids.every(id => id.startsWith('core-resizable--'))).toBe(true);
});
it('knows a story file when it sees one', () => {
diff --git a/.github/scripts/touched-components.mjs b/.github/scripts/touched-components.mjs
index cfb2fa5d98..75094a4062 100644
--- a/.github/scripts/touched-components.mjs
+++ b/.github/scripts/touched-components.mjs
@@ -599,7 +599,7 @@ export function main(argv = process.argv.slice(2)) {
wide_change: String(decision.wideChange),
component_count: String(decision.componentCount),
has_components: String(scope.touched.length > 0 && !decision.wideChange),
- // A changed story no component owns is audited on its own (FR12),
+ // A changed story no other audit covers is audited on its own (FR12),
// wide change or not.
changed_stories: String(files.some(file => STORY_FILE.test(file))),
visual_components: scope.visualComponents.join(','),
diff --git a/.github/scripts/touched-components.test.mjs b/.github/scripts/touched-components.test.mjs
index e10d4d982e..a1bac5231c 100644
--- a/.github/scripts/touched-components.test.mjs
+++ b/.github/scripts/touched-components.test.mjs
@@ -590,7 +590,7 @@ describe('pr-touched-components routing', () => {
'Download Storybook artifact',
'Install Playwright',
]) {
- // A changed story no component owns needs the same setup (FR12).
+ // A changed story no other audit covers needs the same setup (FR12).
expect(step(name).if).toBe(
"(steps.touched.outputs.has_components == 'true' || steps.touched.outputs.changed_stories == 'true')",
);
@@ -645,7 +645,7 @@ describe('pr-touched-components routing', () => {
step('Skip when no component changed or the change is wide').if,
).toBe("steps.touched.outputs.has_components != 'true'");
// Every later step runs for touched components only, or for a changed
- // story no component owns (FR12).
+ // story no other audit covers (FR12).
const skipIndex = job.steps.findIndex(
candidate =>
candidate.name ===
@@ -838,11 +838,11 @@ describe('pr-component-a11y-contracts routing', () => {
});
});
-// A story the change adds or changes that no component owns is audited on
-// its own (spec:AST-030 FR12), new violations only.
-describe('the audit of changed stories no component owns', () => {
+// A story the change adds or changes that no other audit covers is audited
+// on its own (spec:AST-030 FR12), new violations only.
+describe('the audit of changed stories no other audit covers', () => {
const audit = step(
- 'Accessibility audit for changed stories no component owns',
+ 'Accessibility audit for changed stories no other audit covers',
);
const either =
"(steps.touched.outputs.has_components == 'true' || steps.touched.outputs.changed_stories == 'true')";
@@ -866,8 +866,21 @@ describe('the audit of changed stories no component owns', () => {
it("audits only those stories, against the head's baseline, failing on a new violation", () => {
expect(audit.env).toEqual({
FILES_PATH: '${{ steps.scope.outputs.changed_files_path }}',
+ TOUCHED_AUDIT:
+ "${{ steps.touched.outputs.has_components == 'true' && steps.touched.outputs.a11y_owners != '' }}",
});
expect(audit.run).toContain('--changed-story-files "$FILES_PATH"');
+ // The touched components' audit already runs their stories: the same
+ // filters it uses are left out here.
+ expect(audit.run).toContain(
+ 'COVERED=$(node .github/scripts/a11y-pr-scope.mjs analysis.json)',
+ );
+ expect(audit.run).toContain('--covered-components "$COVERED"');
+ expect(
+ step('Accessibility audit for the touched components').run,
+ ).toContain(
+ 'COMPONENTS=$(node .github/scripts/a11y-pr-scope.mjs analysis.json)',
+ );
expect(audit.run).toContain(
'--baseline .head-baseline/.github/a11y-baseline.json',
);
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5afe433f92..eb17e2aa10 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3882,7 +3882,7 @@ jobs:
echo "No component changed; no component audit."
fi
if [ "$STORIES" = true ]; then
- echo "Changed stories no component owns are audited below."
+ echo "Changed stories no other audit covers are audited below."
fi
- name: Setup Node and pnpm
@@ -3919,21 +3919,28 @@ jobs:
--concurrency 4 \
--components "$COMPONENTS"
- # A story the change adds or changes that no component owns (an `a11y/`
- # page, say) is in no touched component's audit, so it is audited on its
- # own: new violations against the head's baseline fail the job
- # (spec:AST-030 FR12).
- - name: Accessibility audit for changed stories no component owns
+ # A story the change adds or changes that no other audit covers (one an
+ # untouched component owns, or an `a11y/` page no component owns) is
+ # audited on its own: new violations against the head's baseline fail
+ # the job (spec:AST-030 FR12). The touched components' audit already
+ # runs their own stories, so those are left out.
+ - name: Accessibility audit for changed stories no other audit covers
id: story-a11y
if: always() && steps.playwright.outcome == 'success' && steps.touched.outputs.changed_stories == 'true'
env:
FILES_PATH: ${{ steps.scope.outputs.changed_files_path }}
+ TOUCHED_AUDIT: ${{ steps.touched.outputs.has_components == 'true' && steps.touched.outputs.a11y_owners != '' }}
run: |
+ COVERED=''
+ if [ "$TOUCHED_AUDIT" = true ]; then
+ COVERED=$(node .github/scripts/a11y-pr-scope.mjs analysis.json)
+ fi
node .github/scripts/accessibility-audit.js \
--storybook-dir apps/storybook/dist \
--output a11y-stories-report.json \
--concurrency 4 \
--changed-story-files "$FILES_PATH" \
+ --covered-components "$COVERED" \
--baseline .head-baseline/.github/a11y-baseline.json \
--fail-on-new
diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.md
index 6a3572e6e6..f9e176e434 100644
--- a/docs/specs/AST-030/spec.md
+++ b/docs/specs/AST-030/spec.md
@@ -234,7 +234,7 @@ they are separately named.
`hooks`, `internal` or `Layer` folder); behaviour-only shared code is not a
wide change. Every change, a wide one included, also gets an
accessibility audit, new violations only, of each story file it adds or
- changes whose owner is no component. Nothing starts a full suite on its own; a wide change's check
+ changes that no other audit in the pull request covers. Nothing starts a full suite on its own; a wide change's check
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
@@ -626,7 +626,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; `a11y-changed-stories.test.mjs` and the touched job's story-audit contract | 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 an `a11y/` story no component owns | a pull request that adds a browser accessibility spec that fails is not caught on that pull request, another component's spec or an unchanged `audit` spec runs in the contract job, a not-run file reads as passed or fails the join, a failing contract leaves the `test` join green, or a new violation in a changed story no component owns passes the touched check |
+| FR12 | `touched-components.test.mjs` changed-spec routing; `a11y-pr-contracts.test.mjs` `changedOnly` cases; `a11y-changed-stories.test.mjs` and the touched job's story-audit contract | 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 an `a11y/` story no component owns; one that adds a story to an untouched component's story file beside a touched component | a pull request that adds a browser accessibility spec that fails is not caught on that pull request, another component's spec or an unchanged `audit` spec runs in the contract job, a not-run file reads as passed or fails the join, a failing contract leaves the `test` join green, or a new violation in a changed story no component owns passes the touched check |
| FR12 | `a11y-pr-contracts.test.mjs` ownership cases; the CI workflow contract; contract-job and unit-test-job timings on 17 component pull requests | a pull request that touches one component with an owned `release-only` contract, passing and failing; a contract file that cannot finish within the budget; a wide change; a reverse dependent of the touched component; measured: setup up to about 1.5 minutes plus the 8-minute stop, against the slowest unit-test job finishing 9.9 to 25 minutes after the Storybook build | a touched component's owned `release-only` contract does not run on its pull request, a failing contract leaves the `test` join green, a skipped file is split, does not show as "not run" in the check's summary or fails the join, the contract job finishes after the slowest unit-test job, or a wide change or reverse dependent runs owned contracts |
| 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 |