Skip to content

Commit 3e051c1

Browse files
committed
ci: cover undeclared test inputs in the change gate
The root test setup in packages/shared and the vendored mobile tarballs now run everything, and the scripts tests run whenever an app or provider-cursor they read changes.
1 parent 53b24aa commit 3e051c1

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

‎.github/scripts/ci-changes.cjs‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ const INERT = [
2121
/^LICENSE$/,
2222
];
2323

24+
// Run everything: the root vite.config.ts loads the first as setup for every
25+
// package's tests, and the vendored mobile tarballs are installed dependencies.
26+
const RUNS_EVERYTHING = [
27+
/^packages\/shared\/src\/(HostProcess|testing\/longTempDir)\.ts$/,
28+
/^apps\/mobile\/deps\//,
29+
];
30+
2431
// Paths outside a package, or files inside one that other packages read
2532
// through relative imports rather than a package.json dependency.
2633
const EXTRA_OWNERS = [
@@ -33,8 +40,19 @@ const EXTRA_OWNERS = [
3340
];
3441
const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
3542

36-
// Tests that import another package's sources without declaring it.
37-
const TEST_ONLY_DEPS = { "@t3tools/provider-pi": ["@t3tools/client-runtime"] };
43+
// Tests that read another package's files without declaring it. The scripts
44+
// tests read app manifests, assets, and sources (cursor-sdk-packaging,
45+
// third-party-licenses, brand-assets, build-desktop-artifact).
46+
const TEST_ONLY_DEPS = {
47+
"@t3tools/provider-pi": ["@t3tools/client-runtime"],
48+
"@t3tools/scripts": [
49+
"@t3tools/desktop",
50+
"@t3tools/mobile",
51+
"@t3tools/web",
52+
"t3",
53+
"@t3tools/provider-cursor",
54+
],
55+
};
3856
// Declared dependencies that only feed a build step: the server bundles the
3957
// built web app (apps/server/vite.config.ts) but never imports it.
4058
const BUILD_ONLY_DEPS = { t3: ["@t3tools/web"] };
@@ -93,7 +111,9 @@ function ownersOf(file, packages) {
93111
if (INERT.some((pattern) => pattern.test(file))) return [];
94112
// A manifest can change dependencies or versions other packages read.
95113
if (path.posix.basename(file) === "package.json") return null;
96-
if (RUST.test(file)) return [];
114+
if (RUNS_EVERYTHING.some((pattern) => pattern.test(file))) return null;
115+
// scripts/build-desktop-artifact.test.ts reads the crates' sources.
116+
if (RUST.test(file)) return ["@t3tools/scripts"];
97117

98118
const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
99119
const owner = packages
@@ -120,6 +140,8 @@ function decide(files, packages, full) {
120140
}
121141
}
122142

143+
// Release smoke reads scripts/ itself, not what the scripts tests read.
144+
let scriptsChanged = everything;
123145
if (everything) {
124146
affected = all;
125147
} else {
@@ -134,6 +156,7 @@ function decide(files, packages, full) {
134156
}
135157
}
136158
}
159+
scriptsChanged = affected.has("@t3tools/scripts");
137160
for (const [name, deps] of Object.entries(TEST_ONLY_DEPS)) {
138161
if (deps.some((dep) => affected.has(dep))) affected.add(name);
139162
}
@@ -155,7 +178,7 @@ function decide(files, packages, full) {
155178
test_web: has("@t3tools/web"),
156179
test_server: has("t3"),
157180
rust: everything || rust,
158-
release_smoke: everything || has("@t3tools/scripts"),
181+
release_smoke: scriptsChanged,
159182
mobile_native: files === null || files.some((file) => MOBILE_NATIVE.test(file)),
160183
},
161184
};

0 commit comments

Comments
 (0)