An open source design system that's fully customizable and agent ready
TypeScript
fix(ci): the touched-components job stops going red on a stale branch or a soft RTL finding (#9282)
Cindy Zhang653e5e1f615d
diff --git a/.github/scripts/touched-components.mjs b/.github/scripts/touched-components.mjsindex 982c277327..8b738af156 100644--- a/.github/scripts/touched-components.mjs+++ b/.github/scripts/touched-components.mjs@@ -7,7 +7,8 @@* @output `scope`: GitHub step outputs naming what each suite audits.* `report`: touched-components.json, one row per touched component with a* pass/fail/changed/not-run result for each suite, for the pull-request- * comment; a step summary; exit 1 when a suite failed.+ * comment; a step summary; exit 1 when visual or accessibility failed+ * (RTL findings are soft, as in pr-rtl).* @position Default pull-request check (spec:AST-030 FR12). It audits only the* components a change touches and never widens to a full suite; full suites* run behind their `ci:run-<suite>` labels and in the release check.@@ -434,9 +435,16 @@ export function buildTouchedReport({};}+/**+ * The suites whose failure fails the job. RTL findings are soft, as in+ * pr-rtl (a failed check or a coverage gap reports, never blocks), so an RTL+ * `fail` is recorded and shown but does not turn the job red.+ */+const BLOCKING_SUITES = ['visual', 'a11y'];+export function hasFailure(report) {return report.components.some(component =>- SUITES.some(suite => component.results[suite] === 'fail'),+ BLOCKING_SUITES.some(suite => component.results[suite] === 'fail'),);}diff --git a/.github/scripts/touched-components.test.mjs b/.github/scripts/touched-components.test.mjsindex 5288a75a69..a4fd32668e 100644--- a/.github/scripts/touched-components.test.mjs+++ b/.github/scripts/touched-components.test.mjs@@ -547,6 +547,38 @@ describe('pr-touched-components routing', () => {);});+ it('reads the accessibility baseline from the head that built the audited Storybook', () => {+ const baseline = step("Check out the head's accessibility baseline");+ expect(baseline.with).toMatchObject({+ ref: '${{ github.event.pull_request.head.sha }}',+ path: '.head-baseline',+ 'sparse-checkout': '.github/a11y-baseline.json',+ });+ expect(step('Report per-component results').run).toContain(+ '--a11y-baseline .head-baseline/.github/a11y-baseline.json',+ );+ });++ it('records an RTL failure without failing the job, as pr-rtl keeps RTL findings soft', () => {+ const report = {+ components: [+ {+ key: 'core/ContextMenu',+ results: {visual: 'pass', a11y: 'pass', rtl: 'fail'},+ },+ ],+ };+ expect(hasFailure(report)).toBe(false);+ report.components[0].results.a11y = 'fail';+ expect(hasFailure(report)).toBe(true);+ });++ it('checks out the tested merge commit, so a branch that predates the check still runs it', () => {+ const checkout = job.steps.find(step => step.name === 'Checkout');+ expect(checkout.uses).toMatch(/^actions\/checkout@/);+ expect(checkout.with?.ref).toBeUndefined();+ });+it('exposes the wide-change flag and count', () => {expect(job.outputs).toEqual({wide_change: '${{ steps.touched.outputs.wide_change }}',diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 20cf315c2d..82896ac690 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -3036,10 +3036,23 @@ jobs:with:component-audit: 'true'+ # The tested merge commit, as pr-visual checks out: a branch that+ # predates this check has none of its scripts at its own head.- name: Checkout+ uses: actions/checkout@v7+ with:+ persist-credentials: false++ # The accessibility baseline is read from the head, which built the+ # Storybook this job audits: a branch behind a main fix that dropped a+ # baseline entry would otherwise report that entry as new.+ - name: Check out the head's accessibility baselineuses: actions/checkout@v7with:ref: ${{ github.event.pull_request.head.sha }}+ path: .head-baseline+ sparse-checkout: .github/a11y-baseline.json+ sparse-checkout-cone-mode: falsepersist-credentials: false# A spec-only, docsite-only or tooling-only change has no analysis; it@@ -3164,7 +3177,7 @@ jobs:--visual-job "$VISUAL_JOB" \--baseline-manifest .github/visual-baseline/manifest.json \--a11y a11y-report.json \- --a11y-baseline .github/a11y-baseline.json \+ --a11y-baseline .head-baseline/.github/a11y-baseline.json \--a11y-step "$A11Y_STEP" \--rtl-dir rtl-reports \--rtl-step "$RTL_STEP" \