An open source design system that's fully customizable and agent ready
TypeScript
fix(ci): scope component browser audits (#6316)
Cindy Zhangbdea6e22c0e7
diff --git a/.github/scripts/component-audit-scope.cjs b/.github/scripts/component-audit-scope.cjsindex 6175d9e472..1a5a381d0d 100644--- a/.github/scripts/component-audit-scope.cjs+++ b/.github/scripts/component-audit-scope.cjs@@ -37,6 +37,12 @@ function classifyComponentAuditScope(paths, componentPackages) {file === '.github/scripts/rtl-audit-coverage.test.mjs' ||file === '.github/scripts/weekly-rtl-summary.test.mjs' ||file === '.github/workflows/rtl-weekly.yml';+ // These are positively owned surfaces that neither component browser audit+ // can observe. Keep this list narrow: unmatched paths still fail closed.+ const isKnownNonComponentSurface = file =>+ file.startsWith('.changeset/') ||+ file.startsWith('apps/sandbox/') ||+ file.startsWith('packages/cli/');const isSharedRoutingPolicy = file =>file === 'apps/storybook/rtl-audit/rtl-audit-coverage.mjs' ||file === 'apps/storybook/rtl-audit/targets.json' ||@@ -56,7 +62,8 @@ function classifyComponentAuditScope(paths, componentPackages) {(!isComponentSource(file) &&!isStory(file) &&!isAccessibilitySurface(file) &&- !isRtlHarness(file)),+ !isRtlHarness(file) &&+ !isKnownNonComponentSurface(file)),);return {diff --git a/.github/scripts/component-audit-scope.test.mjs b/.github/scripts/component-audit-scope.test.mjsindex 67f933dc78..1216ed9f33 100644--- a/.github/scripts/component-audit-scope.test.mjs+++ b/.github/scripts/component-audit-scope.test.mjs@@ -22,6 +22,13 @@ const FULL_AUDIT_SCOPE = {force_full_component_audits: true,};+const NO_COMPONENT_AUDIT_SCOPE = {+ has_components: false,+ has_rtl_components: false,+ has_rtl_harness: false,+ force_full_component_audits: false,+};+describe('component audit scope', () => {it('loads the classifier and registry from the trusted base ref', () => {const workflow = fs.readFileSync(@@ -71,6 +78,42 @@ describe('component audit scope', () => {).toMatchObject(FULL_AUDIT_SCOPE);});+ it('does not expose unrelated contributors to inherited component-audit failures', () => {+ const paths = [+ '.changeset/theme-family-artifacts.md',+ 'apps/sandbox/src/app/(sandbox)/pages/theme-family/page.tsx',+ 'packages/cli/api/theme/build/build.mjs',+ ];+ expect(classifyComponentAuditScope(paths, COMPONENT_PACKAGES)).toEqual(+ NO_COMPONENT_AUDIT_SCOPE,+ );+ });++ it('still audits a component changed beside a known non-component surface', () => {+ expect(+ classifyComponentAuditScope(+ [+ 'packages/cli/api/theme/build/build.mjs',+ 'packages/core/src/Button/Button.tsx',+ ],+ COMPONENT_PACKAGES,+ ),+ ).toMatchObject({+ has_components: true,+ has_rtl_components: true,+ force_full_component_audits: false,+ });+ });++ it('fails closed when a known non-component path is renamed from an unknown surface', () => {+ expect(+ classifyComponentAuditScope(+ ['new/unclassified/path.xyz', 'packages/cli/api/theme/build/build.mjs'],+ COMPONENT_PACKAGES,+ ),+ ).toMatchObject(FULL_AUDIT_SCOPE);+ });+it.each([['routing-test-only',