perf(test): parallelize harder — unlock worker count, split build-output, bump workspace concurrency
- All 8 vitest configs now default maxWorkers to \`cpus().length - 1\` instead of the arbitrary \`Math.min(4, …)\` cap. Respects an explicit VITEST_MAX_WORKERS override for constrained environments (CI, laptops on battery). CLI keeps \`fileParallelism: false\` — audit found real shared state (process.chdir in agent-import, dist/ races in build-exe suites) that needs refactoring before we can flip it. - packages/dashboard: move the mobile build-output smoke test (which invokes \`pnpm build:client\` via execSync, ~3s per run) into a dedicated \`test:build\` script so \`pnpm test\` isn't gated by it. A matching root script keeps CI wiring simple. - Root: bump --workspace-concurrency from 2 → 4 so core/engine/cli/ desktop can pipeline against dashboard's tail. - Drop the now-redundant VITEST_MAX_WORKERS=4 prefix from the root scripts; the per-package configs pick up cpu count themselves. Dashboard test suite: 182s → 38s (5x) on a 10-core machine. Full workspace run: ~3m15 → 2m29. All tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,8 @@
|
||||
"dev": "pnpm build && pnpm typecheck && pnpm dev:serve",
|
||||
"dev:serve": "vite dev",
|
||||
"postinstall": "chmod +x node_modules/.pnpm/node-pty*/node_modules/node-pty/prebuilds/darwin-*/spawn-helper node_modules/.pnpm/node-pty*/node_modules/node-pty/prebuilds/darwin-*/*.node 2>/dev/null || true",
|
||||
"test": "vitest run --silent=passed-only --reporter=dot",
|
||||
"test": "vitest run --silent=passed-only --reporter=dot --exclude '**/build-output.test.ts'",
|
||||
"test:build": "vitest run --silent=passed-only --reporter=dot app/__tests__/build-output.test.ts",
|
||||
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.app.json"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { resolve } from "node:path";
|
||||
import { cpus } from "node:os";
|
||||
|
||||
const defaultMaxWorkers = 2;
|
||||
const defaultMaxWorkers = Math.max(1, cpus().length - 1);
|
||||
const requestedMaxWorkers = Number.parseInt(process.env.VITEST_MAX_WORKERS ?? String(defaultMaxWorkers), 10);
|
||||
const maxWorkers = Math.max(1, Math.min(4, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers));
|
||||
const maxWorkers = Math.max(1, Number.isFinite(requestedMaxWorkers) ? requestedMaxWorkers : defaultMaxWorkers);
|
||||
process.env.VITEST_MAX_WORKERS = String(maxWorkers);
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
Reference in New Issue
Block a user