Skip to content

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

TypeScript

ci(a11y): split the release spec-test contracts into three shards (#7432)

Cindy Zhang88f3aa57089d
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjs
index f264ea30f9..6d7bc05af1 100644
--- a/.github/scripts/ci-test-routing.test.mjs
+++ b/.github/scripts/ci-test-routing.test.mjs
@@ -241,7 +241,7 @@ describe('ci.yml RTL package sharding', () => {
'build-storybook',
'pr-a11y-shard',
'pr-a11y',
- 'a11y-contracts',
+ 'a11y-contracts-shard',
'pr-rtl-shard',
]) {
const checkout = workflow.jobs[name].steps.find(candidate =>
diff --git a/.github/scripts/release-check-workflow.test.mjs b/.github/scripts/release-check-workflow.test.mjs
index c4e7b83df3..fb3502a886 100644
--- a/.github/scripts/release-check-workflow.test.mjs
+++ b/.github/scripts/release-check-workflow.test.mjs
@@ -29,6 +29,7 @@ const releaseJobs = [
'pr-a11y-shard',
'pr-a11y-audit',
'pr-a11y',
+ 'a11y-contracts-shard',
'a11y-contracts',
'pr-rtl-shard',
'pr-rtl-merge',
@@ -227,7 +228,7 @@ describe('explicit release routing', () => {
it.each([
'pr-a11y-shard',
'pr-a11y',
- 'a11y-contracts',
+ 'a11y-contracts-shard',
'visual-scout',
'pr-visual',
'pr-rtl-shard',
@@ -598,7 +599,7 @@ describe('full release scope without PR metadata or maintenance writes', () => {
expect(result.stdout).not.toContain('--components');
expect(audit['continue-on-error']).toBeUndefined();
expect(
- step('a11y-contracts', 'Run accessibility spec-test contracts').env
+ step('a11y-contracts-shard', 'Run accessibility spec-test contracts').env
.ASTRYX_HEAD_SHA,
).toBe('${{ github.event.pull_request.head.sha || github.sha }}');
});
@@ -665,9 +666,9 @@ describe('full release scope without PR metadata or maintenance writes', () => {
it('keeps exhaustive a11y contracts and their artifacts release-only', () => {
for (const [job, name] of [
- ['a11y-contracts', 'Run accessibility spec-test contracts'],
- ['a11y-contracts', 'Upload pressed-state pixel evidence'],
- ['a11y-contracts', 'Upload component-audit browser evidence'],
+ ['a11y-contracts-shard', 'Run accessibility spec-test contracts'],
+ ['a11y-contracts-shard', 'Upload pressed-state pixel evidence'],
+ ['a11y-contracts-shard', 'Upload component-audit browser evidence'],
]) {
expect(runs(step(job, name)), name).toBe(true);
expect(
@@ -680,18 +681,31 @@ describe('full release scope without PR metadata or maintenance writes', () => {
expect(
runs(jobs['a11y-contracts'], {event: 'pull_request', operation: ''}),
).toBe(false);
+ const contracts = step(
+ 'a11y-contracts-shard',
+ 'Run accessibility spec-test contracts',
+ );
+ expect(contracts.run).toBe(
+ 'pnpm test:a11y-contract --shard=${{ matrix.shard }}/${{ strategy.job-total }}',
+ );
+ expect(contracts.env.A11Y_CONTRACT_WORKERS).toBe(4);
+ expect(contracts['continue-on-error']).toBeUndefined();
+ // The join fails closed: a failed shard, or an evidence set no shard
+ // produced, blocks release-check through a11y-contracts.
+ const join = jobs['a11y-contracts'];
+ expect(join.needs).toContain('a11y-contracts-shard');
expect(
- step('a11y-contracts', 'Run accessibility spec-test contracts').run,
- ).toBe('pnpm test:a11y-contract');
- expect(
- step('a11y-contracts', 'Run accessibility spec-test contracts').env
- .A11Y_CONTRACT_WORKERS,
- ).toBe(4);
- expect(
- step('a11y-contracts', 'Run accessibility spec-test contracts')[
- 'continue-on-error'
- ],
- ).toBeUndefined();
+ step('a11y-contracts', 'Require every contract shard').run,
+ ).toContain('"$SHARD_RESULT" != success');
+ for (const name of [
+ 'Join pressed-state pixel evidence',
+ 'Join component-audit browser evidence',
+ ]) {
+ expect(step('a11y-contracts', name).uses).toBe(
+ 'actions/upload-artifact/merge@v7',
+ );
+ expect(step('a11y-contracts', name).with['delete-merged']).toBe(true);
+ }
for (const name of [
'Run modal close visibility guard',
'Run theme var reachability guard',
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 90e91efe1b..38e8921d07 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1934,10 +1934,14 @@ jobs:
# its full axe sweep, so the release check waits for the longer of the two
# rather than their sum. release-check requires this job as it requires
# pr-a11y.
- a11y-contracts:
- name: Accessibility spec-test contracts
+ a11y-contracts-shard:
+ name: Accessibility spec-test contracts (${{ matrix.shard }}/${{ strategy.job-total }})
needs: [build-storybook, check-components]
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true'
+ strategy:
+ fail-fast: false
+ matrix:
+ shard: [1, 2, 3]
runs-on: 2-core-ubuntu-arm
permissions:
contents: read
@@ -1969,16 +1973,19 @@ jobs:
env:
ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
A11Y_CONTRACT_WORKERS: 4
- run: pnpm test:a11y-contract
+ run: pnpm test:a11y-contract --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Upload pressed-state pixel evidence
if: always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
uses: actions/upload-artifact@v7
with:
- name: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}
+ name: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }}
path: test-results/pressed-state-evidence/
+ # A failing run keeps its evidence here (the join merges only after
+ # every leg passed, then deletes these copies).
retention-days: 30
- if-no-files-found: error
+ # Only the shard that ran the spec has frames; the join requires them.
+ if-no-files-found: ignore
# Component-audit browser evidence. A whole-component audit has to show
# the states it graded, and the audit node cannot always run a browser —
@@ -1988,10 +1995,45 @@ jobs:
if: always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
uses: actions/upload-artifact@v7
with:
- name: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}
+ name: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}-${{ matrix.shard }}
path: test-results/chat-layout-audit-evidence/
retention-days: 30
- if-no-files-found: error
+ if-no-files-found: ignore
+
+ # Joins the contract shards for release-check: every shard must pass, and
+ # each evidence set is rebuilt under its usual artifact name. A set no shard
+ # produced fails the merge, as the single job's upload used to fail.
+ a11y-contracts:
+ name: Accessibility spec-test contracts
+ needs: [build-storybook, check-components, a11y-contracts-shard]
+ if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check' && needs.check-components.outputs.has_components == 'true' }}
+ runs-on: ubuntu-slim
+ permissions: {}
+ steps:
+ - name: Require every contract shard
+ env:
+ SHARD_RESULT: ${{ needs.a11y-contracts-shard.result }}
+ run: |
+ if [ "$SHARD_RESULT" != success ]; then
+ echo "Accessibility contract shards did not all succeed: $SHARD_RESULT"
+ exit 1
+ fi
+
+ - name: Join pressed-state pixel evidence
+ uses: actions/upload-artifact/merge@v7
+ with:
+ name: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}
+ pattern: pressed-state-evidence-${{ needs.build-storybook.outputs.short_hash }}-*
+ retention-days: 30
+ delete-merged: true
+
+ - name: Join component-audit browser evidence
+ uses: actions/upload-artifact/merge@v7
+ with:
+ name: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}
+ pattern: component-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}-*
+ retention-days: 30
+ delete-merged: true
# Build package test owner. The plugin's production CSS partition is a Build
# integration contract: source inspection cannot prove which declaration