Skip to content

Commit 3ca4781

Browse files
ci(repo): scope the machine and custom integration suites to the packages they load
These suites build their apps inside their tests instead of selecting long-running apps by id. The dependency check now accepts that as long as the tagged tests reference at least one app config, so suites whose apps can't be found still can't be narrowed.
1 parent 2ab2bfe commit 3ca4781

2 files changed

Lines changed: 45 additions & 40 deletions

File tree

‎integration/presets/__tests__/suiteBuildDependencies.test.ts‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ beforeAll(async () => {
6060
({ appConfigs } = await import('..'));
6161
});
6262

63-
const packagesLoadedBy = (suite: string) => {
63+
const appsLoadedBy = (suite: string) => {
6464
const { appIds, tag } = parseScript(suite);
65-
const longRunning = (
66-
appConfigs.longRunningApps.getByPattern(appIds!) as unknown as { config: ApplicationConfig }[]
67-
).map(app => app.config);
65+
const longRunning = appIds
66+
? (appConfigs.longRunningApps.getByPattern(appIds) as unknown as { config: ApplicationConfig }[]).map(
67+
app => app.config,
68+
)
69+
: [];
6870

6971
const tagPattern = new RegExp(`${tag}(?![\\w-])`);
7072
const taggedSources = listTestFiles(testsDir)
@@ -80,7 +82,12 @@ const packagesLoadedBy = (suite: string) => {
8082
[...source.matchAll(/addDependency\(\s*'(@clerk\/[\w-]+)',\s*PKGLAB\s*\)/g)].map(([, name]) => name),
8183
);
8284

83-
return [...[...longRunning, ...referenced].flatMap(config => config.pkglabDependencies), ...addedInTests];
85+
return { configs: [...longRunning, ...referenced], addedInTests };
86+
};
87+
88+
const packagesLoadedBy = (suite: string) => {
89+
const { configs, addedInTests } = appsLoadedBy(suite);
90+
return [...configs.flatMap(config => config.pkglabDependencies), ...addedInTests];
8491
};
8592

8693
describe('scoped integration suites declare the builds they load', () => {
@@ -93,11 +100,14 @@ describe('scoped integration suites declare the builds they load', () => {
93100
});
94101

95102
describe.each(scopedSuites)('$suite', ({ suite, dependsOn }) => {
96-
it('selects its apps with E2E_APP_ID and a --grep tag', () => {
97-
const { script, appIds, tag } = parseScript(suite);
103+
it('selects its tests with a --grep tag and its apps by id or from its tagged tests', () => {
104+
const { script, tag } = parseScript(suite);
98105
expect(script, `package.json has no test:integration:${suite} script`).toBeDefined();
99-
expect(appIds, `test:integration:${suite} must set E2E_APP_ID to be scoped`).toBeDefined();
100106
expect(tag, `test:integration:${suite} must pass --grep @tag to be scoped`).toBeDefined();
107+
expect(
108+
appsLoadedBy(suite).configs.length,
109+
`test:integration:${suite} must set E2E_APP_ID or its tagged tests must use appConfigs apps to be scoped`,
110+
).toBeGreaterThan(0);
101111
});
102112

103113
it('depends on exactly the builds of the packages its fixtures and harness load', () => {

‎turbo.json‎

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,23 @@
763763
"outputLogs": "new-only"
764764
},
765765
"//#test:integration:machine": {
766+
"dependsOn": [
767+
"@clerk/astro#build",
768+
"@clerk/backend#build",
769+
"@clerk/clerk-js#build",
770+
"@clerk/express#build",
771+
"@clerk/fastify#build",
772+
"@clerk/hono#build",
773+
"@clerk/localizations#build",
774+
"@clerk/nextjs#build",
775+
"@clerk/nuxt#build",
776+
"@clerk/react-router#build",
777+
"@clerk/shared#build",
778+
"@clerk/tanstack-react-start#build",
779+
"@clerk/testing#build",
780+
"@clerk/ui#build",
781+
"@clerk/vue#build"
782+
],
766783
"env": [
767784
"CLEANUP",
768785
"CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET",
@@ -772,26 +789,19 @@
772789
"INTEGRATION_INSTANCE_KEYS",
773790
"INTEGRATION_STAGING_INSTANCE_KEYS"
774791
],
775-
"inputs": [
776-
"integration/**",
777-
"packages/*/package.json",
778-
"packages/*/src/**",
779-
"packages/*/tsconfig.json",
780-
"packages/*/tsconfig.build.json",
781-
"packages/*/tsconfig.declarations.json",
782-
"packages/*/tsdown.config.*",
783-
"packages/*/tsup.config.*",
784-
"packages/*/rspack.config.*",
785-
"packages/*/vite.config.*",
786-
"!packages/*/src/**/*.test.*",
787-
"!packages/*/src/**/__tests__/**",
788-
"!packages/*/src/**/__mocks__/**",
789-
"!packages/*/src/**/__snapshots__/**"
790-
],
792+
"inputs": ["integration/**", "!integration/playwright-report/**", "!integration/test-results/**"],
791793
"outputs": ["integration/playwright-report/**"],
792794
"outputLogs": "new-only"
793795
},
794796
"//#test:integration:custom": {
797+
"dependsOn": [
798+
"@clerk/backend#build",
799+
"@clerk/clerk-js#build",
800+
"@clerk/react#build",
801+
"@clerk/shared#build",
802+
"@clerk/testing#build",
803+
"@clerk/ui#build"
804+
],
795805
"env": [
796806
"CLEANUP",
797807
"CLERK_E2E_OAUTH_PROVIDER_CLIENT_SECRET",
@@ -801,22 +811,7 @@
801811
"INTEGRATION_INSTANCE_KEYS",
802812
"INTEGRATION_STAGING_INSTANCE_KEYS"
803813
],
804-
"inputs": [
805-
"integration/**",
806-
"packages/*/package.json",
807-
"packages/*/src/**",
808-
"packages/*/tsconfig.json",
809-
"packages/*/tsconfig.build.json",
810-
"packages/*/tsconfig.declarations.json",
811-
"packages/*/tsdown.config.*",
812-
"packages/*/tsup.config.*",
813-
"packages/*/rspack.config.*",
814-
"packages/*/vite.config.*",
815-
"!packages/*/src/**/*.test.*",
816-
"!packages/*/src/**/__tests__/**",
817-
"!packages/*/src/**/__mocks__/**",
818-
"!packages/*/src/**/__snapshots__/**"
819-
],
814+
"inputs": ["integration/**", "!integration/playwright-report/**", "!integration/test-results/**"],
820815
"outputs": ["integration/playwright-report/**"],
821816
"outputLogs": "new-only"
822817
},

0 commit comments

Comments
 (0)