Skip to content

Commit 99be504

Browse files
only21milclaude
andauthored
fix(scripts): check:changed no longer passes failing .github/scripts tests (#28296)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 5d0de82 commit 99be504

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

‎scripts/check-changed.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
docReaderTests,
2222
gitLines,
2323
runSteps,
24+
splitTests,
2425
type Step,
2526
} from "./check-changed.ts";
2627
import { decide, readWorkspace } from "../.github/scripts/ci-changes.cjs";
@@ -142,6 +143,24 @@ describe("check:changed", () => {
142143
}),
143144
);
144145

146+
it("runs the .github/scripts node:test files with node --test, not vitest", () => {
147+
assert.deepStrictEqual(
148+
splitTests([
149+
"apps/server/src/ws.test.ts",
150+
".github/scripts/ci-changes.test.cjs",
151+
".github\\scripts\\thread-transfer-report.test.cjs",
152+
"scripts/check-changed.test.ts",
153+
]),
154+
{
155+
vitestTests: ["apps/server/src/ws.test.ts", "scripts/check-changed.test.ts"],
156+
nodeTests: [
157+
".github/scripts/ci-changes.test.cjs",
158+
".github\\scripts\\thread-transfer-report.test.cjs",
159+
],
160+
},
161+
);
162+
});
163+
145164
it.effect("fails instead of returning an empty file list when git exits nonzero", () => {
146165
const spawner = (exitCode: number) =>
147166
ChildProcessSpawner.make(() =>

‎scripts/check-changed.ts‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ export const comparisonBase = Effect.fn("checkChanged.comparisonBase")(function*
174174

175175
const CODE = /\.[cm]?[jt]sx?$/;
176176
const TEST = /\.test\.[cm]?[jt]sx?$/;
177+
// CI runs the .github/scripts tests with `node --test`; vitest passes a failing node:test file.
178+
const NODE_TEST = /^\.github[/\\]scripts[/\\]/;
179+
export const splitTests = (tests: Iterable<string>) => {
180+
const all = [...tests];
181+
return {
182+
vitestTests: all.filter((file) => !NODE_TEST.test(file)),
183+
nodeTests: all.filter((file) => NODE_TEST.test(file)),
184+
};
185+
};
177186
const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
178187

179188
// A flag wins over its environment variable; either must be a positive integer.
@@ -319,6 +328,7 @@ const checkChanged = Effect.fn("checkChanged")(function* (input: {
319328
for (const test of docReaderTests(files)) tests.add(test);
320329
// It reads files other than the ones beside it, so no changed file selects it.
321330
if (affected.includes("t3")) tests.add("apps/server/src/provider/AgentContextBudget.test.ts");
331+
const { vitestTests, nodeTests } = splitTests(tests);
322332

323333
// React Compiler coverage compiles every client source file, so run only the
324334
// changed files' cases, in one extra step: a -t filter in the main test step
@@ -485,19 +495,29 @@ const checkChanged = Effect.fn("checkChanged")(function* (input: {
485495
]
486496
: []),
487497
// From the repo root, the root vite.config.ts hands each file to its package's config.
488-
...(tests.size > 0
498+
...(vitestTests.length > 0
489499
? [
490500
{
491-
...command(`test (${tests.size} files)`, [
501+
...command(`test (${vitestTests.length} files)`, [
492502
"test",
493503
"run",
494504
"--passWithNoTests",
495-
...tests,
505+
...vitestTests,
496506
]),
497507
serial: true,
498508
},
499509
]
500510
: []),
511+
...(nodeTests.length > 0
512+
? [
513+
command(`node --test (${nodeTests.length} files)`, [
514+
"exec",
515+
"node",
516+
"--test",
517+
...nodeTests,
518+
]),
519+
]
520+
: []),
501521
...(compilerApps.length > 0
502522
? [
503523
{

0 commit comments

Comments
 (0)