diff --git a/.githooks/commit-msg b/.githooks/commit-msg index 951f800..a28f26e 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -1,3 +1,5 @@ #!/bin/sh # Check the message against Conventional Commits (ADR 31). Enable: git config core.hooksPath .githooks +# A merge commit is skipped, as in CI: its message is git's "Merge branch …". +git rev-parse -q --verify MERGE_HEAD > /dev/null && exit 0 exec node scripts/check-commits.ts --file "$1" diff --git a/package.json b/package.json index 9efae7c..ee741cf 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "lint": "biome ci .", "format": "biome check --write .", "typecheck": "tsc -p tsconfig.json && pnpm -r typecheck", - "test": "vitest run", + "test": "vitest run --project unit && vitest run --project perf", "test:bun": "bun test ./fixtures ./packages/engine ./packages/shared ./packages/web ./scripts", "check": "pnpm lint && pnpm typecheck && pnpm test && pnpm test:mod && pnpm layers && pnpm scan && pnpm egress && pnpm supply-chain", "layers": "node scripts/check-layers.ts", diff --git a/packages/engine/test/providers/anthropic/estimate.test.ts b/packages/engine/test/providers/anthropic/estimate.test.ts index 4c9bad7..3afa98d 100644 --- a/packages/engine/test/providers/anthropic/estimate.test.ts +++ b/packages/engine/test/providers/anthropic/estimate.test.ts @@ -54,10 +54,9 @@ describe("imageSize", () => { }); test("reads only the header bytes: a huge image decodes no more than its first 64 KB", () => { - const huge = PNG_96x64 + "A".repeat(20_000_000); - const start = performance.now(); + // Not valid base64 after the first 64 KB: an image read whole would not decode. No clock, so no flake on CI. + const huge = `${PNG_96x64}${"A".repeat(200_000)}!!!!`; expect(imageSize(huge)).toEqual({ width: 96, height: 64 }); - expect(performance.now() - start).toBeLessThan(50); }); test("returns undefined for data that is not a known image format", () => { diff --git a/vitest.config.ts b/vitest.config.ts index a8935a1..9a3f412 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,6 +1,21 @@ import { configDefaults, defineConfig } from "vitest/config"; +// Load tests measure time, and take most of the CPU while they run. Beside the unit tests they made unit tests +// pass vitest's 5 s timeout on slow CI runners, and their own numbers noisy. So `pnpm test` runs `unit` (files in +// parallel) and then `perf` (one file at a time, nothing beside it). +const PERF = [ + "packages/engine/test/query/performance.test.ts", + "packages/engine/test/ingest/performance.test.ts", + "packages/engine/test/api/latency.test.ts", +]; + export default defineConfig({ - // The mod's tests import claude-code/testing and run under `claude plugin test` (pnpm test:mod). - test: { exclude: [...configDefaults.exclude, "packages/mod/**"] }, + test: { + // The mod's tests import claude-code/testing and run under `claude plugin test` (pnpm test:mod). + exclude: [...configDefaults.exclude, "packages/mod/**"], + projects: [ + { extends: true, test: { name: "unit", exclude: PERF } }, + { extends: true, test: { name: "perf", include: PERF, fileParallelism: false } }, + ], + }, });