An open source design system that's fully customizable and agent ready
TypeScript
ci: skip unrelated checks for spec-only PRs (#6405)
Cindy Zhang62ef02c57a54
diff --git a/.github/scripts/ci-test-routing.test.mjs b/.github/scripts/ci-test-routing.test.mjsindex 9c32a9d9a0..edcf10e8f5 100644--- a/.github/scripts/ci-test-routing.test.mjs+++ b/.github/scripts/ci-test-routing.test.mjs@@ -212,11 +212,14 @@ describe('ci.yml RTL package sharding', () => {const shard = workflow.jobs['pr-rtl-shard'];const join = workflow.jobs['pr-rtl'];- it('keeps specialized lanes as explicit successful no-audit classifications', () => {+ it('skips component discovery for spec-only changes and classifies other lightweight lanes', () => {const classification = workflow.jobs['check-components'];- expect(classification.if).toBe("github.event_name == 'pull_request'");+ expect(classification.if).toContain("github.event_name == 'pull_request'");+ expect(classification.if).toContain(+ "needs.check-scope.outputs.spec_only != 'true'",+ );const commands = runLines(classification);- for (const lane of ['docsite_only', 'spec_only', 'tooling_only']) {+ for (const lane of ['docsite_only', 'tooling_only']) {expect(commands).toContain(`needs.check-scope.outputs.${lane}`);}expect(commands).toContain('has_components=false');diff --git a/.github/scripts/spec-owner-workflow.test.mjs b/.github/scripts/spec-owner-workflow.test.mjsindex f419b51378..eb75337379 100644--- a/.github/scripts/spec-owner-workflow.test.mjs+++ b/.github/scripts/spec-owner-workflow.test.mjs@@ -17,6 +17,8 @@ describe('spec-only workflow contract', () => {for (const workflow of ['.github/workflows/ci.yml','.github/workflows/lint.yml',+ '.github/workflows/cli-smoke-test.yml',+ '.github/workflows/internal-registry.yml','.github/workflows/pr-comment.yml',]) {expect(read(workflow), workflow).toContain(@@ -32,6 +34,8 @@ describe('spec-only workflow contract', () => {for (const workflow of ['.github/workflows/ci.yml','.github/workflows/lint.yml',+ '.github/workflows/cli-smoke-test.yml',+ '.github/workflows/internal-registry.yml',]) {const source = read(workflow);expect(source, workflow).toContain(@@ -98,21 +102,68 @@ describe('spec-only workflow contract', () => {}});- it('keeps required CI names green while skipping heavy work', () => {+ it('routes spec-only changes without unrelated CI commands', () => {const ci = read('.github/workflows/ci.yml');expect(ci).toContain('git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs"',);expect(ci).toContain('spec_only: ${{ steps.scope.outputs.spec_only }}');- expect(ci).toContain('node scripts/check-knowledge.mjs');- expect(ci).toContain("needs.check-scope.outputs.spec_only != 'true'");- expect(ci).toContain('build:');- expect(ci).toContain('docsite-test:');- expect(ci).toContain('test:');++ const jobBlock = name => {+ const start = ci.indexOf(` ${name}:`);+ expect(start, name).toBeGreaterThanOrEqual(0);+ const next = ci.slice(start + 1).search(/^ [a-zA-Z0-9_-]+:\s*$/m);+ return next < 0 ? ci.slice(start) : ci.slice(start, start + 1 + next);+ };+ const unrelatedJobs = [+ 'check-components',+ 'test-ui',+ 'test-node',+ 'registry-contract',+ 'test',+ 'build-storybook',+ 'pr-rtl',+ ];+ for (const job of unrelatedJobs) {+ expect(jobBlock(job), job).toContain(+ "needs.check-scope.outputs.spec_only != 'true'",+ );+ }+ expect(jobBlock('build')).toContain(+ "needs.build-storybook.result != 'skipped'",+ );++ const docsite = jobBlock('docsite-test');+ expect(docsite).toContain("needs.check-scope.outputs.spec_only == 'true'");+ expect(docsite).toContain('node scripts/check-knowledge.mjs');const lint = read('.github/workflows/lint.yml');- expect(lint).toContain("steps.scope.outputs.spec_only == 'true'");- expect(lint).toContain('node scripts/check-knowledge.mjs');+ expect(lint).toContain('.github/scripts/change-scope.cjs');+ expect(lint).not.toContain('node scripts/check-knowledge.mjs');++ for (const workflow of [+ '.github/workflows/cli-smoke-test.yml',+ '.github/workflows/internal-registry.yml',+ ]) {+ const source = read(workflow);+ expect(source, workflow).toContain(+ "if: steps.scope.outputs.spec_only == 'true'",+ );+ const expensiveSteps = source+ .split(/\n - /)+ .slice(1)+ .filter(step =>+ /(?:github\/actions\/setup|pnpm|playwright|cli-smoke-test|dependency-check)/.test(+ step,+ ),+ );+ expect(expensiveSteps.length, workflow).toBeGreaterThan(0);+ for (const step of expensiveSteps) {+ expect(step, `${workflow}: ${step.slice(0, 60)}`).toContain(+ "steps.scope.outputs.spec_only != 'true'",+ );+ }+ }});it('sets up dependencies before spec validation and skips heavy spec-only work', () => {diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 22c8e12b0e..80ee4bce5c 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -125,9 +125,12 @@ jobs:# and by the RTL roster. `analyze-pr.js` still decides which changed components# each downstream audit receives. When those projections disagree the audits# silently no-op, so harness/registry changes also exercise the RTL smoke scope.+ # Spec-only changes keep only the trusted scope classifier and the+ # knowledge validator below. Unrelated component discovery must not take a+ # runner or fan out into visual, accessibility, or RTL work.check-components:needs: [check-scope]- if: github.event_name == 'pull_request'+ if: github.event_name == 'pull_request' && needs.check-scope.outputs.spec_only != 'true'runs-on: ubuntu-slimpermissions:contents: read@@ -213,7 +216,7 @@ jobs:# build-storybook + build-sandbox below.test-ui:needs: [check-scope]- if: ${{ always() && !cancelled() }}+ if: ${{ always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}runs-on: 4-core-ubuntupermissions:contents: read@@ -276,7 +279,7 @@ jobs:test-node:needs: [check-scope]- if: ${{ always() && !cancelled() }}+ if: ${{ always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}runs-on: 2-core-ubuntu-armpermissions:contents: read@@ -324,7 +327,7 @@ jobs:# item through the exact pinned ShadCN client and compiles every written source.registry-contract:needs: [check-scope]- if: ${{ always() && !cancelled() }}+ if: ${{ always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}runs-on: 4-core-ubuntutimeout-minutes: 30permissions:@@ -388,7 +391,7 @@ jobs:# projects their combined result without creating another surface lane.test:needs: [check-scope, test-ui, test-node, test-build, registry-contract]- if: ${{ always() && !cancelled() }}+ if: ${{ always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}runs-on: ubuntu-slimpermissions:contents: read@@ -415,7 +418,7 @@ jobs:# `build` join below folds their results into the historical check name.build-storybook:needs: [check-scope]- if: ${{ always() && !cancelled() }}+ if: ${{ always() && !cancelled() && needs.check-scope.outputs.spec_only != 'true' }}runs-on: 2-core-ubuntu-armpermissions:contents: read@@ -1253,8 +1256,8 @@ jobs:# Stable required context joining the five package shards above.pr-rtl:- needs: [check-components, pr-rtl-shard]- if: ${{ always() && !cancelled() && github.event_name == 'pull_request' }}+ needs: [check-scope, check-components, pr-rtl-shard]+ if: ${{ always() && !cancelled() && github.event_name == 'pull_request' && needs.check-scope.outputs.spec_only != 'true' }}runs-on: ubuntu-slimtimeout-minutes: 5steps:diff --git a/.github/workflows/cli-smoke-test.yml b/.github/workflows/cli-smoke-test.ymlindex 7936e36362..43267664e9 100644--- a/.github/workflows/cli-smoke-test.yml+++ b/.github/workflows/cli-smoke-test.yml@@ -6,15 +6,15 @@ name: CLI Smoke Teston:pull_request:- branches: ["main"]+ branches: ['main']paths-ignore:- - "apps/docsite/**"+ - 'apps/docsite/**'merge_group:permissions: {}concurrency:- group: "cli-smoke-${{ github.event.merge_group.head_sha || github.head_ref }}"+ group: 'cli-smoke-${{ github.event.merge_group.head_sha || github.head_ref }}'cancel-in-progress: truejobs:@@ -24,26 +24,67 @@ jobs:contents: readsteps:- uses: actions/checkout@v7+ with:+ fetch-depth: 50++ - name: Classify changed files+ if: github.event_name == 'pull_request'+ id: scope+ run: |+ git fetch origin ${{ github.base_ref }} --depth=50+ MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null || echo "")+ if [ -z "$MERGE_BASE" ]; then+ printf 'docsite_only=false\nspec_only=false\ntooling_only=false\n' >> "$GITHUB_OUTPUT"+ exit 0+ fi+ CLASSIFIER_ROOT="$RUNNER_TEMP/change-scope"+ CLASSIFIER_DIR="$CLASSIFIER_ROOT/.github/scripts"+ REGISTRY_DIR="$CLASSIFIER_ROOT/scripts"+ mkdir -p "$CLASSIFIER_DIR" "$REGISTRY_DIR"+ CLASSIFIER="$CLASSIFIER_DIR/change-scope.cjs"+ MATCHER="$CLASSIFIER_DIR/knowledge-paths.cjs"+ REGISTRY="$REGISTRY_DIR/component-packages.cjs"+ if git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs" > "$CLASSIFIER" 2>/dev/null \+ && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$MATCHER" 2>/dev/null \+ && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then+ git diff --name-status "$MERGE_BASE"...HEAD \+ | node "$CLASSIFIER" --github-output+ else+ # Missing trusted policy cannot grant a specialized lane.+ printf 'docsite_only=false\nspec_only=false\ntooling_only=false\n' \+ >> "$GITHUB_OUTPUT"+ fi++ - name: Skip CLI checks for spec-only changes+ if: steps.scope.outputs.spec_only == 'true'+ run: echo "Spec-only PR — CLI behavior cannot change"- uses: ./.github/actions/setup+ if: steps.scope.outputs.spec_only != 'true'- name: CLI smoke test+ if: steps.scope.outputs.spec_only != 'true'run: node .github/scripts/cli-smoke-test.mjs- name: Typecheck JSON API types+ if: steps.scope.outputs.spec_only != 'true'run: cd packages/cli && pnpm typecheck:json-api- name: CLI --json smoke test+ if: steps.scope.outputs.spec_only != 'true'run: node .github/scripts/cli-json-smoke-test.mjs- name: API ↔ CLI parity test+ if: steps.scope.outputs.spec_only != 'true'run: node .github/scripts/api-cli-parity-test.mjs --no-baseline# The CDN starter page is the only thing we ship that runs with no# bundler and no test double for the CDNs, so it is verified by rendering# it. Needs network access to jsDelivr, esm.sh and the npm registry.- name: Install Playwright+ if: steps.scope.outputs.spec_only != 'true'run: npx playwright install chromium- name: CDN starter page smoke test+ if: steps.scope.outputs.spec_only != 'true'run: node .github/scripts/cdn-template-smoke-test.mjsdiff --git a/.github/workflows/internal-registry.yml b/.github/workflows/internal-registry.ymlindex 21a2a7aff6..b248a1c511 100644--- a/.github/workflows/internal-registry.yml+++ b/.github/workflows/internal-registry.yml@@ -11,7 +11,7 @@ name: Internal Registryon:pull_request:- branches: ["main"]+ branches: ['main']merge_group:permissions: {}@@ -24,5 +24,41 @@ jobs:id-token: writesteps:- uses: actions/checkout@v7+ with:+ fetch-depth: 50++ - name: Classify changed files+ if: github.event_name == 'pull_request'+ id: scope+ run: |+ git fetch origin ${{ github.base_ref }} --depth=50+ MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }} 2>/dev/null || echo "")+ if [ -z "$MERGE_BASE" ]; then+ printf 'docsite_only=false\nspec_only=false\ntooling_only=false\n' >> "$GITHUB_OUTPUT"+ exit 0+ fi+ CLASSIFIER_ROOT="$RUNNER_TEMP/change-scope"+ CLASSIFIER_DIR="$CLASSIFIER_ROOT/.github/scripts"+ REGISTRY_DIR="$CLASSIFIER_ROOT/scripts"+ mkdir -p "$CLASSIFIER_DIR" "$REGISTRY_DIR"+ CLASSIFIER="$CLASSIFIER_DIR/change-scope.cjs"+ MATCHER="$CLASSIFIER_DIR/knowledge-paths.cjs"+ REGISTRY="$REGISTRY_DIR/component-packages.cjs"+ if git show "origin/${{ github.base_ref }}:.github/scripts/change-scope.cjs" > "$CLASSIFIER" 2>/dev/null \+ && git show "origin/${{ github.base_ref }}:.github/scripts/knowledge-paths.cjs" > "$MATCHER" 2>/dev/null \+ && git show "origin/${{ github.base_ref }}:scripts/component-packages.cjs" > "$REGISTRY" 2>/dev/null; then+ git diff --name-status "$MERGE_BASE"...HEAD \+ | node "$CLASSIFIER" --github-output+ else+ # Missing trusted policy cannot grant a specialized lane.+ printf 'docsite_only=false\nspec_only=false\ntooling_only=false\n' \+ >> "$GITHUB_OUTPUT"+ fi++ - name: Skip dependency checks for spec-only changes+ if: steps.scope.outputs.spec_only == 'true'+ run: echo "Spec-only PR — package dependencies cannot change"+- uses: facebook/lexical/.github/actions/internal-registry/dependency-check@internal-registry-dependency-check-v1+ if: steps.scope.outputs.spec_only != 'true'continue-on-error: truediff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 7dafdbb442..7b335440a3 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -48,10 +48,6 @@ jobs:>> "$GITHUB_OUTPUT"fi- - name: Validate spec records- if: steps.scope.outputs.spec_only == 'true'- run: node scripts/check-knowledge.mjs-- name: Skip full lint for lightweight docsif: steps.scope.outputs.docsite_only == 'true' || steps.scope.outputs.spec_only == 'true'run: echo "Lightweight documentation PR — skipping full lint"