Skip to content

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

TypeScript

ci: test-registry-e2e runs each registry's TypeScript and JavaScript consumers in their own legs (#9448)

Cindy Zhang0dbd1bdad006
diff --git a/.github/actions/ci-admission/action.yml b/.github/actions/ci-admission/action.yml
index 86e2a9b394..d9284997ae 100644
--- a/.github/actions/ci-admission/action.yml
+++ b/.github/actions/ci-admission/action.yml
@@ -161,7 +161,7 @@ runs:
// (ci-admission.test.mjs), a pull-request ci.yml run from its
// measured most, every other workflow's run one or two slim jobs.
const ESTIMATE = {
- '.github/workflows/ci.yml': run => (run.event === 'workflow_dispatch' ? 37 : 16),
+ '.github/workflows/ci.yml': run => (run.event === 'workflow_dispatch' ? 39 : 16),
'.github/workflows/deploy.yml': run => (run.event === 'push' ? 4 : 14),
'.github/workflows/review-signal.yml': () => 2,
};
diff --git a/.github/scripts/shadcn-registry-ci.test.mjs b/.github/scripts/shadcn-registry-ci.test.mjs
index 5ddc3f4cb9..0107dd284f 100644
--- a/.github/scripts/shadcn-registry-ci.test.mjs
+++ b/.github/scripts/shadcn-registry-ci.test.mjs
@@ -124,19 +124,38 @@ describe('ShadCN registry CI contract', () => {
);
});
- it('verifies the preview and hidden production registries in separate legs', () => {
- expect(job.strategy.matrix).toEqual({leg: ['preview', 'production']});
+ it('verifies each registry in a TypeScript and a JavaScript leg, all four required', () => {
+ // Both consumer modes of one registry in one job took 8-12 minutes and
+ // passed the 15-minute limit once, so each mode has its own leg.
+ expect(job.strategy.matrix).toEqual({
+ leg: ['preview', 'production'],
+ mode: ['typescript', 'javascript'],
+ });
expect(job.strategy['fail-fast']).toBe(false);
+ expect(job.strategy.matrix.include).toBeUndefined();
+ expect(job.strategy.matrix.exclude).toBeUndefined();
+ expect(job.name).toBe(
+ 'test-registry-e2e (${{ matrix.leg }}, ${{ matrix.mode }})',
+ );
+ // The matrix job's result, which release-check requires, is success only
+ // when every leg passed.
+ expect(ci.jobs['release-check'].needs).toContain('test-registry-e2e');
const legOf = {
- 'Verify hidden production registry contract': 'production',
- 'Generate and validate the complete preview registry': 'preview',
- 'Install and build every preview registry item': 'preview',
- 'Generate the hidden production registry': 'production',
- 'Verify hidden production discovery surfaces': 'production',
- 'Install and build every hidden production registry item': 'production',
+ 'Generate and validate the complete preview registry':
+ "matrix.leg == 'preview'",
+ 'Install and build every preview registry item':
+ "matrix.leg == 'preview'",
+ 'Generate the hidden production registry': "matrix.leg == 'production'",
+ 'Install and build every hidden production registry item':
+ "matrix.leg == 'production'",
+ // Registry-wide checks, once per registry.
+ 'Verify hidden production registry contract':
+ "matrix.leg == 'production' && matrix.mode == 'typescript'",
+ 'Verify hidden production discovery surfaces':
+ "matrix.leg == 'production' && matrix.mode == 'typescript'",
};
- for (const [name, leg] of Object.entries(legOf)) {
- expect(step(name).if, name).toBe(`matrix.leg == '${leg}'`);
+ for (const [name, condition] of Object.entries(legOf)) {
+ expect(step(name).if, name).toBe(condition);
}
// Every leg builds the packages it exercises.
expect(step('Build registry package exports').if).toBeUndefined();
@@ -147,14 +166,15 @@ describe('ShadCN registry CI contract', () => {
});
it('uses the complete clean-consumer verifier in preview and production', () => {
+ // Each leg installs and compiles every item in its own mode.
expect(step('Install and build every preview registry item').run).toBe(
- 'node internal/shadcn-registry/verify-full-catalog.mjs',
+ 'node internal/shadcn-registry/verify-full-catalog.mjs --mode ${{ matrix.mode }}',
);
const productionInstall = step(
'Install and build every hidden production registry item',
);
expect(productionInstall.run).toBe(
- 'node internal/shadcn-registry/verify-full-catalog.mjs',
+ 'node internal/shadcn-registry/verify-full-catalog.mjs --mode ${{ matrix.mode }}',
);
expect(productionInstall.env.ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES).toBe(
'1',
@@ -167,7 +187,8 @@ describe('ShadCN registry CI contract', () => {
"'add', ...itemPaths",
"'--silent'",
'expectedInstalledFile(file, tsx)',
- 'for (const tsx of [true, false])',
+ 'for (const tsx of modes)',
+ 'const MODES = {typescript: [true], javascript: [false], all: [true, false]};',
'did not install declared dependency',
'alias route',
'duplicate item name',
@@ -185,3 +206,28 @@ describe('ShadCN registry CI contract', () => {
expect(runLines()).toContain('verify-full-catalog.mjs');
});
});
+
+describe('verify-full-catalog --mode', () => {
+ it('verifies one mode per CI leg, and both by default', async () => {
+ const {selectedModes} =
+ await import('../../internal/shadcn-registry/verify-full-catalog.mjs');
+ expect(selectedModes(['--mode', 'typescript'])).toEqual([true]);
+ expect(selectedModes(['--mode', 'javascript'])).toEqual([false]);
+ expect(selectedModes(['--mode', 'all'])).toEqual([true, false]);
+ expect(selectedModes([])).toEqual([true, false]);
+ });
+
+ it('refuses a mode it does not know', async () => {
+ const {selectedModes} =
+ await import('../../internal/shadcn-registry/verify-full-catalog.mjs');
+ for (const argv of [
+ ['--mode', 'tsx'],
+ ['--mode'],
+ ['--mode', 'constructor'],
+ ]) {
+ expect(() => selectedModes(argv), argv.join(' ')).toThrow(
+ 'unknown --mode',
+ );
+ }
+ });
+});
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 941242d496..277db912e3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -138,7 +138,7 @@ jobs:
timeout-minutes: ${{ github.event_name == 'workflow_dispatch' && 16 || 13 }}
with:
phase: room
- peak: ${{ github.event_name == 'workflow_dispatch' && 37 || 16 }}
+ peak: ${{ github.event_name == 'workflow_dispatch' && 39 || 16 }}
main: ${{ github.event_name == 'workflow_dispatch' }}
max-wait-minutes: ${{ github.event_name == 'workflow_dispatch' && 15 || 12 }}
max-looks: ${{ github.event_name == 'workflow_dispatch' && 8 || 2 }}
@@ -176,7 +176,7 @@ jobs:
started: ${{ needs.room.outputs.started }}
looks: ${{ needs.room.outputs.looks }}
next: ${{ needs.room.outputs.next }}
- peak: ${{ github.event_name == 'workflow_dispatch' && 37 || 16 }}
+ peak: ${{ github.event_name == 'workflow_dispatch' && 39 || 16 }}
main: ${{ github.event_name == 'workflow_dispatch' }}
max-wait-minutes: ${{ github.event_name == 'workflow_dispatch' && 15 || 12 }}
max-looks: ${{ github.event_name == 'workflow_dispatch' && 8 || 2 }}
@@ -957,17 +957,20 @@ jobs:
# the registry: with the Node unit tests, and in docsite-test for a
# docsite-only change.
test-registry-e2e:
- name: test-registry-e2e (${{ matrix.leg }})
+ name: test-registry-e2e (${{ matrix.leg }}, ${{ matrix.mode }})
needs: [admission]
if: github.event_name == 'workflow_dispatch' && inputs.operation == 'release-check'
# The preview and hidden production registries are generated and verified
- # independently, so each gets its own leg (~9 minutes in one job).
- # release-check joins them: the job result is success only when both
- # passed.
+ # independently, and each installs and compiles every item twice, as a
+ # TypeScript and as a JavaScript consumer. One leg per registry and mode:
+ # the preview's two modes in one job took 8-12 minutes on the same 1,036
+ # items and passed the 15-minute limit once. release-check joins the legs:
+ # the job result is success only when all four passed.
strategy:
fail-fast: false
matrix:
leg: [preview, production]
+ mode: [typescript, javascript]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
@@ -980,8 +983,9 @@ jobs:
- name: Build registry package exports
run: pnpm build
+ # The registry-wide checks run once, in the TypeScript leg.
- name: Verify hidden production registry contract
- if: matrix.leg == 'production'
+ if: matrix.leg == 'production' && matrix.mode == 'typescript'
run: node internal/shadcn-registry/verify-production-gate.mjs
- name: Generate and validate the complete preview registry
@@ -992,7 +996,7 @@ jobs:
- name: Install and build every preview registry item
if: matrix.leg == 'preview'
- run: node internal/shadcn-registry/verify-full-catalog.mjs
+ run: node internal/shadcn-registry/verify-full-catalog.mjs --mode ${{ matrix.mode }}
- name: Generate the hidden production registry
if: matrix.leg == 'production'
@@ -1001,7 +1005,7 @@ jobs:
run: node apps/docsite/scripts/generate-data.mjs
- name: Verify hidden production discovery surfaces
- if: matrix.leg == 'production'
+ if: matrix.leg == 'production' && matrix.mode == 'typescript'
env:
ASTRYX_VERIFY_HIDDEN_PRODUCTION: '1'
NEXT_PUBLIC_DOCS_TARGET: latest
@@ -1011,7 +1015,7 @@ jobs:
if: matrix.leg == 'production'
env:
ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES: '1'
- run: node internal/shadcn-registry/verify-full-catalog.mjs
+ run: node internal/shadcn-registry/verify-full-catalog.mjs --mode ${{ matrix.mode }}
# Historical required check name. The Vitest lanes, the Build test owner,
# native Swift and the interaction proofs (Chromium and WebKit) always
diff --git a/internal/shadcn-registry/verify-full-catalog.mjs b/internal/shadcn-registry/verify-full-catalog.mjs
index 7f2060af4d..78f961930b 100644
--- a/internal/shadcn-registry/verify-full-catalog.mjs
+++ b/internal/shadcn-registry/verify-full-catalog.mjs
@@ -10,7 +10,8 @@
* ShadCN's own scratch directories stay inside each consumer, which is
* removed afterwards.
* @input A generated preview or hidden production registry under
- * apps/docsite/public/shadcn.
+ * apps/docsite/public/shadcn, and `--mode typescript|javascript` to verify
+ * one consumer mode (both by default; CI runs each in its own leg).
* @output A clean-consumer proof for every canonical item and alias route.
* @position Required CI contract for the public ShadCN compatibility surface.
*/
@@ -56,6 +57,17 @@ const USE_PUBLISHED_PACKAGES =
process.env.ASTRYX_SHADCN_USE_PUBLISHED_PACKAGES === '1';
const MAX_COMMAND_OUTPUT = 16 * 1024 * 1024;
const COPIED_KINDS = new Set(['showcase', 'example', 'block', 'page']);
+const MODES = {typescript: [true], javascript: [false], all: [true, false]};
+
+/** The consumer modes to verify, as `tsx` flags: `--mode <name>`, or both. */
+export function selectedModes(argv) {
+ const index = argv.indexOf('--mode');
+ const name = index === -1 ? 'all' : argv[index + 1];
+ if (!Object.hasOwn(MODES, name ?? '')) {
+ fail(`unknown --mode ${String(name)}; use typescript, javascript or all`);
+ }
+ return MODES[name];
+}
function fail(message) {
throw new Error(`ShadCN registry CI: ${message}`);
@@ -630,11 +642,12 @@ async function compileSources(project, sources) {
async function main() {
const startedAt = Date.now();
+ const modes = selectedModes(process.argv.slice(2));
const catalog = loadCatalog();
const packageDirs = USE_PUBLISHED_PACKAGES ? null : localPackageDirs();
const results = [];
- for (const tsx of [true, false]) {
+ for (const tsx of modes) {
const mode = tsx ? 'TypeScript' : 'JavaScript';
const project = fs.mkdtempSync(
path.join(os.tmpdir(), `astryx-shadcn-registry-${tsx ? 'tsx' : 'jsx'}-`),
@@ -672,7 +685,13 @@ async function main() {
);
}
-main().catch(error => {
- console.error(error);
- process.exitCode = 1;
-});
+// Run as a script; a test imports selectedModes without running it.
+if (
+ process.argv[1] &&
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
+) {
+ main().catch(error => {
+ console.error(error);
+ process.exitCode = 1;
+ });
+}