mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-22 11:54:35 +01:00
build(server): omit tests from production compilation (#19383)
Use a separate production TypeScript configuration that excludes colocated tests while retaining every runtime source input and keeping tests in source typechecking. Verify the real compiler input sets and bound compiler-list capture for the larger source graph. Validation: focused compiler-input regression passes; fresh CI has 61 passing checks and three optional skips on 181ad8d; Greptile Apex is 5/5 with no unresolved comments. Co-Authored-By: Scott Goodson <scottgoodson@gmail.com> Co-Authored-By: Devin Foley <devin@paperclip.ing> Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
4 files changed
+46
-3
No files matched your search
+1
-1
@@ -36,7 +36,7 @@
|
||||
"dev": "tsx src/index.ts",
|
||||
"dev:watch": "cross-env PAPERCLIP_MIGRATION_PROMPT=never PAPERCLIP_MIGRATION_AUTO_APPLY=true tsx ./scripts/dev-watch.ts",
|
||||
"prepare:ui-dist": "bash ../scripts/prepare-server-ui-dist.sh",
|
||||
"build": "pnpm run prepare:runner-vendor && node scripts/verify-runner-vendor-dependencies.mjs && node ../scripts/run-tsc.mjs && mkdir -p dist/onboarding-assets dist/built-ins dist/services/scripts dist/vendor/paperclip-runner && cp -R src/onboarding-assets/. dist/onboarding-assets/ && cp -R src/built-ins/. dist/built-ins/ && cp -R src/services/scripts/. dist/services/scripts/ && cp -Rf ../packages/paperclip-runner/dist/. dist/vendor/paperclip-runner/ && cp ../packages/paperclip-runner/scripts/install-copilot-assets.mjs ../packages/paperclip-runner/scripts/materialize-copilot-binary.mjs ../packages/paperclip-runner/scripts/copilot-inner-distribution.mjs dist/ && node dist/install-copilot-assets.mjs && node scripts/write-build-stamp.mjs",
|
||||
"build": "pnpm run prepare:runner-vendor && node scripts/verify-runner-vendor-dependencies.mjs && node ../scripts/run-tsc.mjs -p tsconfig.build.json && mkdir -p dist/onboarding-assets dist/built-ins dist/services/scripts dist/vendor/paperclip-runner && cp -R src/onboarding-assets/. dist/onboarding-assets/ && cp -R src/built-ins/. dist/built-ins/ && cp -R src/services/scripts/. dist/services/scripts/ && cp -Rf ../packages/paperclip-runner/dist/. dist/vendor/paperclip-runner/ && cp ../packages/paperclip-runner/scripts/install-copilot-assets.mjs ../packages/paperclip-runner/scripts/materialize-copilot-binary.mjs ../packages/paperclip-runner/scripts/copilot-inner-distribution.mjs dist/ && node dist/install-copilot-assets.mjs && node scripts/write-build-stamp.mjs",
|
||||
"prepack": "pnpm run prepare:ui-dist && pnpm run build",
|
||||
"postpack": "rm -rf ui-dist",
|
||||
"clean": "rm -rf dist",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
const serverRoot = fileURLToPath(new URL("../", import.meta.url));
|
||||
|
||||
function compilerInputs(args) {
|
||||
const result = spawnSync(process.execPath, ["../scripts/run-tsc.mjs", ...args, "--listFilesOnly"], {
|
||||
cwd: serverRoot,
|
||||
encoding: "utf8",
|
||||
maxBuffer: 8 * 1024 * 1024,
|
||||
timeout: 30_000,
|
||||
});
|
||||
if (result.error) throw result.error;
|
||||
expect(result.status, result.stderr || result.stdout).toBe(0);
|
||||
return result.stdout.split(/\r?\n/).filter((file) => file.startsWith(path.join(serverRoot, "src", path.sep)));
|
||||
}
|
||||
|
||||
it("omits co-located tests from the build while retaining source typecheck coverage", () => {
|
||||
const { scripts } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
||||
const command = scripts.build.split("&&").map((part) => part.trim())
|
||||
.find((part) => part.startsWith("node ../scripts/run-tsc.mjs"));
|
||||
expect(command).toBeDefined();
|
||||
const production = compilerInputs(command.split(/\s+/).slice(2));
|
||||
const source = compilerInputs(["-p", "tsconfig.json"]);
|
||||
const isTest = (file) => /\.test\.tsx?$/.test(file);
|
||||
|
||||
expect(source.filter(isTest).length).toBeGreaterThan(0);
|
||||
expect(production.filter(isTest)).toEqual([]);
|
||||
const productionFiles = new Set(production);
|
||||
const testTree = path.join(serverRoot, "src", "__tests__", path.sep);
|
||||
expect(source.filter((file) => !isTest(file) && !file.startsWith(testTree) && !productionFiles.has(file))).toEqual([]);
|
||||
}, 60_000);
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["src/__tests__", "src/**/*.test.ts", "src/**/*.test.tsx"]
|
||||
}
|
||||
Reference in new issue
Block a user