An open source design system that's fully customizable and agent ready
TypeScript
ci: a change to the visual gate's probe theme runs the whole visual plan (#10262)
Cindy Zhang195431c0a3fa
diff --git a/.github/scripts/visual-scope.mjs b/.github/scripts/visual-scope.mjsindex b06a9f02b7..b8ea3b8446 100644--- a/.github/scripts/visual-scope.mjs+++ b/.github/scripts/visual-scope.mjs@@ -23,6 +23,7 @@ import path from 'node:path';import {fileURLToPath} from 'node:url';import changeScope from './change-scope.cjs';+import {loadConfig} from './visual-gate/lib/sources.mjs';const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)),@@ -81,7 +82,14 @@ export function classifyVisualScope(),) ||paths.includes('packages/core/package.json');- let broadStableVisual = stableVisualInfrastructure;+ // The gate's probe theme: a private fixture that styles every theming+ // target. The release plan's probe tier shoots every story in it, so a+ // change to its source changes those shots and needs the whole plan.+ const probe = loadConfig(repoRoot).probeTheme;+ const probeChanged = paths.some(file =>+ file.startsWith(`packages/themes/${probe}/src/`),+ );+ let broadStableVisual = stableVisualInfrastructure || probeChanged;for (const file of stableCoreFiles) {const match = file.match(/^packages\/core\/src\/([^/]+)\//);@@ -145,6 +153,7 @@ export function classifyVisualScope(return {hasStableVisual:stableVisualInfrastructure ||+ probeChanged ||stableCoreFiles.length > 0 ||stableThemes.size > 0,broadStableVisual,diff --git a/.github/scripts/visual-scope.test.mjs b/.github/scripts/visual-scope.test.mjsindex b1529b458b..35f55596e6 100644--- a/.github/scripts/visual-scope.test.mjs+++ b/.github/scripts/visual-scope.test.mjs@@ -47,6 +47,15 @@ beforeEach(() => {});afterEach(() => fs.rmSync(root, {recursive: true, force: true}));+function writeGateConfig(config) {+ const dir = path.join(root, '.github/scripts/visual-gate');+ fs.mkdirSync(dir, {recursive: true});+ fs.writeFileSync(+ path.join(dir, 'visual-gate.config.json'),+ JSON.stringify(config),+ );+}+describe('classifyVisualScope', () => {it.each(['pnpm-lock.yaml',@@ -226,13 +235,57 @@ describe('classifyVisualScope', () => {});});- it('excludes the private probe fixture', () => {+ it('runs the whole plan for the probe fixture, whose shots the release plan takes', () => {+ writeGateConfig({probeTheme: 'probe'});+ for (const file of [+ 'packages/themes/probe/src/probeTheme.ts',+ 'packages/themes/probe/src/probeConfig.ts',+ ]) {+ const result = classifyVisualScope([file], root);+ expect(result, file).toMatchObject({+ hasStableVisual: true,+ broadStableVisual: true,+ // Still not a stable theme: its own theme-matrix shots stay out.+ stableThemes: [],+ });+ }+ // Its package metadata alone changes no pixels.+ expect(+ classifyVisualScope(['packages/themes/probe/package.json'], root)+ .hasStableVisual,+ ).toBe(false);+ });++ it("defaults the probe fixture as the gate does when the config doesn't name it", () => {+ writeGateConfig({});+ expect(+ classifyVisualScope(['packages/themes/probe/src/probeTheme.ts'], root),+ ).toMatchObject({hasStableVisual: true, broadStableVisual: true});+ });++ it('reads the probe fixture from the gate config, so a renamed fixture still counts', () => {+ writeGateConfig({probeTheme: 'preview'});+ expect(+ classifyVisualScope(+ ['packages/themes/preview/src/previewTheme.ts'],+ root,+ ),+ ).toMatchObject({hasStableVisual: true, broadStableVisual: true});+ expect(+ classifyVisualScope(['packages/themes/probe/src/probeTheme.ts'], root)+ .hasStableVisual,+ ).toBe(false);+ });++ it('uses the repository gate config for the probe fixture', () => {const result = classifyVisualScope(['packages/themes/probe/src/probeTheme.ts'],- root,+ path.resolve(import.meta.dirname, '../..'),);- expect(result.hasStableVisual).toBe(false);- expect(result.stableThemes).toEqual([]);+ expect(result).toMatchObject({+ hasStableVisual: true,+ broadStableVisual: true,+ });});it('excludes Lab and records its release channel from package metadata', () => {diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a9f010d8c3..d771ab55ce 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -3065,9 +3065,10 @@ jobs:uses: actions/checkout@v7# Stable visual scope: Core and the non-private shipped themes take- # part; canaryOnly packages do not. A pull request the import graph can- # scope audits the changed components and their reverse dependents- # (spec:AST-030 FR13).+ # part; canaryOnly packages do not. A change to the gate's probe fixture+ # runs the whole plan, whose probe tier shoots it. A pull request the+ # import graph can scope audits the changed components and their+ # reverse dependents (spec:AST-030 FR13).- name: Decide stable visual scopeid: visual-scopeenv:@@ -3183,9 +3184,10 @@ jobs:uses: actions/checkout@v7# Stable visual scope: Core and the non-private shipped themes take- # part; canaryOnly packages do not. A pull request the import graph can- # scope audits the changed components and their reverse dependents- # (spec:AST-030 FR13).+ # part; canaryOnly packages do not. A change to the gate's probe fixture+ # runs the whole plan, whose probe tier shoots it. A pull request the+ # import graph can scope audits the changed components and their+ # reverse dependents (spec:AST-030 FR13).- name: Decide stable visual scopeid: visual-scopeenv: