An open source design system that's fully customizable and agent ready
TypeScript
ci: shard main's post-merge Vitest lanes like the PR gate (#8426)
Cindy Zhang85e48a0e5d96
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjsindex 434d406ea8..a8ef2fde70 100644--- a/.github/scripts/ci-test-routing.test.mjs+++ b/.github/scripts/ci-test-routing.test.mjs@@ -71,7 +71,7 @@ const WORKFLOWS = {// other and so ride one lane of their own.lanes: ['test-ui', 'test-node', 'typecheck'],scopeConditional: false,- sharded: false,+ sharded: true,},};@@ -157,18 +157,6 @@ describe.each(Object.entries(WORKFLOWS))(expect(suite['continue-on-error']).not.toBe(true);}- if (!sharded) {- // One conditional step preserves the existing scope gate for both- // runs. Exact foreground commands also reject backgrounding or- // ignored exits.- expect(suites).toHaveLength(1);- expect(suites[0].run.trim().split('\n')).toEqual([- 'pnpm test:ui',- 'pnpm test:ui:isolated',- ]);- return;- }-// Sharded: every leg runs its share without FR23, and exactly one leg// runs FR23 in a later step on the same runner, after its share exited.expect(suites).toHaveLength(2);@@ -178,12 +166,18 @@ describe.each(Object.entries(WORKFLOWS))(expect(job.steps.indexOf(isolated)).toBeGreaterThan(job.steps.indexOf(share),);- expect(isolated.if).toBe(`matrix.shard == 1 && ${share.if}`);+ expect(isolated.if).toBe(+ share.if ? `matrix.shard == 1 && ${share.if}` : 'matrix.shard == 1',+ );});if (sharded) {it('splits each Vitest lane across legs that together run every file', () => {- for (const lane of lanes) {+ const vitestLanes = lanes.filter(lane =>+ /--project \w+/.test(runLines(workflow.jobs[lane])),+ );+ expect(vitestLanes).toEqual(['test-ui', 'test-node']);+ for (const lane of vitestLanes) {const job = workflow.jobs[lane];const legs = job.strategy?.matrix?.shard;expect(Array.isArray(legs), `${lane} has no shard matrix`).toBe(true);@@ -647,13 +641,23 @@ describe('deploy.yml push gating', () => {}});- it('checks out main on every push-gate lane', () => {- // A lane that checks out the default ref would gate the wrong commit.+ it('checks out one run-wide main commit on every push-gate lane and leg', () => {+ // A lane that checks out the default ref would gate the wrong commit, and+ // legs that each resolve `main` can straddle a merge and shard different+ // file lists, so one job resolves the commit and every leg checks it out.+ const resolve = workflow.jobs['main-commit'];+ expect(resolve.outputs.sha).toBe('${{ steps.resolve.outputs.sha }}');+ const script = resolve.steps[0].with.script;+ expect(script).toContain('context.sha');+ expect(script).toContain("branch: 'main'");for (const lane of ['test-ui', 'test-node', 'typecheck']) {+ expect(workflow.jobs[lane].needs).toEqual(['main-commit']);const checkout = workflow.jobs[lane].steps.find(step =>step.uses?.startsWith('actions/checkout'),);- expect(checkout?.with?.ref, `${lane} does not pin main`).toBe('main');+ expect(checkout?.with?.ref, `${lane} does not pin the run's commit`).toBe(+ '${{ needs.main-commit.outputs.sha }}',+ );}});});diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.ymlindex 130d6be5f9..25d604fb50 100644--- a/.github/workflows/deploy.yml+++ b/.github/workflows/deploy.yml@@ -16,6 +16,29 @@ concurrency:cancel-in-progress: falsejobs:+ # The one commit every lane and leg of this run tests. A push validates the+ # pushed commit; a dispatch, main's tip when it starts. Each leg resolving+ # `main` itself could straddle a merge, shard different file lists, and skip+ # a file in every leg.+ main-commit:+ runs-on: ubuntu-slim+ permissions:+ contents: read+ outputs:+ sha: ${{ steps.resolve.outputs.sha }}+ steps:+ - name: Resolve the commit under test+ id: resolve+ uses: actions/github-script@v9+ with:+ script: |+ let sha = context.sha;+ if (context.eventName !== 'push') {+ const {data} = await github.rest.repos.getBranch({...context.repo, branch: 'main'});+ sha = data.commit.sha;+ }+ core.setOutput('sha', sha);+# Verify package.json exports match the source tree.# Fails if exports are stale — run `node scripts/sync-exports.js` locally to fix.sync-exports:@@ -41,26 +64,40 @@ jobs:# typecheck needs the `pnpm build` it follows, so they stay together in# their own lane and take the build with them.#- # `ui` is the heavier project by ~4x here, so it takes the larger runner (see- # ci.yml's lane comment).+ # Both Vitest lanes split into four legs, as in ci.yml: one job each ran+ # test-ui in ~18 minutes and test-node in ~28, so main's gate took about half+ # an hour while the PR gate took under fifteen. `test` joins the legs.test-ui:+ needs: [main-commit]+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]runs-on: 4-core-ubuntupermissions:contents: readsteps:- uses: actions/checkout@v7with:- ref: main+ ref: ${{ needs.main-commit.outputs.sha }}- uses: ./.github/actions/setup- # Match the PR gate: FR23 needs an idle test runner, not just a new process.- - name: Run UI tests and isolated Markdown benchmark- run: |- pnpm test:ui- pnpm test:ui:isolated+ - name: Run this shard of the UI tests+ run: pnpm test:ui --shard=${{ matrix.shard }}/${{ strategy.job-total }}++ # Match the PR gate: FR23 needs an idle test runner, not just a new+ # process, so one leg runs it after its own share has exited.+ - name: Run the isolated Markdown benchmark+ if: matrix.shard == 1+ run: pnpm test:ui:isolatedtest-node:+ needs: [main-commit]+ strategy:+ fail-fast: false+ matrix:+ shard: [1, 2, 3, 4]# Vitest runs one test file per CPU beyond the first, so the 2-core runner# ran this suite one file at a time (~23 min). Four cores give it three.runs-on: 4-core-ubuntu@@ -69,11 +106,11 @@ jobs:steps:- uses: actions/checkout@v7with:- ref: main+ ref: ${{ needs.main-commit.outputs.sha }}- uses: ./.github/actions/setup- - run: pnpm test:node+ - run: pnpm test:node --shard=${{ matrix.shard }}/${{ strategy.job-total }}# The typecheck mirroring the PR `build` job in ci.yml. ci.yml only runs# on pull_request/merge_group, so a typecheck error can land on main (its@@ -81,13 +118,14 @@ jobs:# every open PR, which typechecks the PR merged with main (see #3197).# Running them here closes that gap and blocks a broken deploy.typecheck:+ needs: [main-commit]runs-on: 2-core-ubuntu-armpermissions:contents: readsteps:- uses: actions/checkout@v7with:- ref: main+ ref: ${{ needs.main-commit.outputs.sha }}- uses: ./.github/actions/setup