From ba093e0777a1480d45e4391a65b54b4b7c8bd40f Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Mon, 23 Nov 2026 01:12:02 -0500 Subject: [PATCH] fix(ci): rerun TODO scans against the host interpreter --- .../filesystem/staticTaskCache.test.ts | 55 ++++++++++++++++++- turbo.json | 1 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/tests/boundary/filesystem/staticTaskCache.test.ts b/tests/boundary/filesystem/staticTaskCache.test.ts index 9672f8f24c..0077494eeb 100644 --- a/tests/boundary/filesystem/staticTaskCache.test.ts +++ b/tests/boundary/filesystem/staticTaskCache.test.ts @@ -1,7 +1,7 @@ import { spawnSync } from "node:child_process"; import { createRequire } from "node:module"; import { mkdir, readFile, rm, symlink, writeFile } from "node:fs/promises"; -import { dirname, join, resolve } from "node:path"; +import { delimiter, dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { expect, it } from "vitest"; @@ -23,13 +23,18 @@ const dryRunSchema = z.object({ tasks: z.array(z.object({ taskId: z.string(), hash: z.string() })), }); -const execute = (command: string, args: string[], cwd: string) => +const execute = ( + command: string, + args: string[], + cwd: string, + env = process.env, +) => spawnSync(process.execPath, [command, ...args], { cwd, encoding: "utf8", timeout: 30_000, maxBuffer: 16 * 1024 * 1024, - env: process.env, + env, }); const readRootConfig = async () => @@ -99,6 +104,7 @@ const runTurbo = ( task: string, cacheDirectory: string, dryRun = false, + env = process.env, ) => execute( turbo, @@ -111,6 +117,7 @@ const runTurbo = ( cacheDirectory, ], root, + env, ); const taskHash = (root: string, task: string, cacheDirectory: string) => { @@ -123,6 +130,48 @@ const taskHash = (root: string, task: string, cacheDirectory: string) => { return entry.hash; }; +it.skipIf(process.platform === "win32")( + "reruns the debt scan when the host Python tokenizer stops working", + async () => { + const root = await createTestTempDirectory("rea-static-todo-"); + const host = await createTestTempDirectory("rea-static-todo-host-"); + const cache = join(host, "cache"); + const python = join(host, "python3"); + const env = { + ...process.env, + PATH: [host, process.env.PATH ?? ""].join(delimiter), + }; + await writeTaskFixture(root, ["scan:todos"], { + "scan:todos": "node scripts/scan-todos.mjs", + }); + await mkdir(join(root, "scripts")); + await mkdir(join(root, "bridge")); + await symlink( + join(repository, "node_modules"), + join(root, "node_modules"), + "junction", + ); + await writeFile( + join(root, "scripts/scan-todos.mjs"), + await readFile(join(repository, "scripts/scan-todos.mjs"), "utf8"), + ); + await writeFile( + join(root, "bridge/sample.py"), + 'sample = "TODO: example text"\n', + ); + // Keep PATH and repository inputs fixed while the host interpreter changes. + await writeFile(python, "#!/bin/sh\nprintf '[]\\n'\n", { mode: 0o755 }); + const warm = runTurbo(root, "scan:todos", cache, false, env); + expect(warm.status, warm.stdout + warm.stderr).toBe(0); + + await writeFile(python, "#!/bin/sh\nexit 1\n"); + const degraded = runTurbo(root, "scan:todos", cache, false, env); + const output = degraded.stdout + degraded.stderr; + expect(degraded.status, output).toBe(1); + expect(output).toContain("bridge/sample.py:1"); + }, +); + it("restores a real lint report across cold, warm, and fresh consumer checkouts", async () => { const producer = await createTestTempDirectory("rea-static-cache-producer-"); const consumer = await createTestTempDirectory("rea-static-cache-consumer-"); diff --git a/turbo.json b/turbo.json index f00d3a958b..e51c3633d0 100644 --- a/turbo.json +++ b/turbo.json @@ -137,6 +137,7 @@ "outputs": [".cache/static-checks/jscpd/jscpd-report.json"] }, "scan:todos": { + "cache": false, "inputs": [ "bridge/**/*.{java,py}", "scripts/**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",