From 2439c318441582325a4bd5b2744f5a43cc2862a9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 20 Jan 2026 09:40:07 +0000 Subject: [PATCH] chore: tune vitest parallelism --- vitest.config.ts | 5 ++++- vitest.e2e.config.ts | 7 +++++++ vitest.live.config.ts | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vitest.config.ts b/vitest.config.ts index 752434dd10d..0f19a9b4e7f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,9 +1,12 @@ import path from "node:path"; +import os from "node:os"; import { fileURLToPath } from "node:url"; import { defineConfig } from "vitest/config"; const repoRoot = path.dirname(fileURLToPath(import.meta.url)); const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true"; +const cpuCount = os.cpus().length; +const localWorkers = Math.min(16, Math.max(4, Math.floor(cpuCount * 0.5))); export default defineConfig({ resolve: { @@ -15,7 +18,7 @@ export default defineConfig({ testTimeout: 60_000, hookTimeout: 120_000, pool: "forks", - maxWorkers: isCI ? 3 : 4, + maxWorkers: isCI ? 3 : localWorkers, include: [ "src/**/*.test.ts", "extensions/**/*.test.ts", diff --git a/vitest.e2e.config.ts b/vitest.e2e.config.ts index 40b27b9fa26..3531e7fe563 100644 --- a/vitest.e2e.config.ts +++ b/vitest.e2e.config.ts @@ -1,7 +1,14 @@ +import os from "node:os"; import { defineConfig } from "vitest/config"; +const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true"; +const cpuCount = os.cpus().length; +const e2eWorkers = isCI ? 2 : Math.min(4, Math.max(1, Math.floor(cpuCount * 0.25))); + export default defineConfig({ test: { + pool: "forks", + maxWorkers: e2eWorkers, include: ["test/**/*.e2e.test.ts"], setupFiles: ["test/setup.ts"], exclude: [ diff --git a/vitest.live.config.ts b/vitest.live.config.ts index 92202420687..f7cef15b2d2 100644 --- a/vitest.live.config.ts +++ b/vitest.live.config.ts @@ -2,6 +2,8 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { + pool: "forks", + maxWorkers: 1, include: ["src/**/*.live.test.ts"], setupFiles: ["test/setup.ts"], exclude: [