@webpresso/agent-config 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,8 +3,28 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Centralizes shared-runner detection, env var overrides, Stryker compatibility,
|
|
5
5
|
* and execArgv logic used by node.ts, react.ts, and react-router.ts.
|
|
6
|
+
*
|
|
7
|
+
* CI defaults intentionally use available cores for file-level parallelism so
|
|
8
|
+
* consumer repos on 2-vCPU GitHub/Ubicloud runners get maxWorkers=2 instead of
|
|
9
|
+
* the old floor(cpus*0.75)=1 serial bottleneck. Shared workspace runners
|
|
10
|
+
* (VP_RUN_CONCURRENCY_LIMIT) still force a single worker because outer
|
|
11
|
+
* parallelism already fan-outs packages.
|
|
6
12
|
*/
|
|
7
13
|
export declare const parsePositiveInt: (value: string | undefined) => number | undefined;
|
|
14
|
+
export interface ResolveDefaultMaxWorkersOptions {
|
|
15
|
+
/** Logical CPU count; defaults to `os.cpus().length`. */
|
|
16
|
+
readonly cpuCount?: number;
|
|
17
|
+
/** Env bag; defaults to `process.env`. */
|
|
18
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the default Vitest `maxWorkers` when `VITEST_MAX_WORKERS` is unset.
|
|
22
|
+
*
|
|
23
|
+
* - Shared workspace runners (`VP_RUN_CONCURRENCY_LIMIT`): always 1.
|
|
24
|
+
* - CI (`CI=true` / `CI=1`): use all logical CPUs (min 1) so 2-core runners get 2 workers.
|
|
25
|
+
* - Local/dev: 75% of CPUs (min 1) to leave headroom for the editor/OS.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveDefaultMaxWorkers(options?: ResolveDefaultMaxWorkersOptions): number;
|
|
8
28
|
export declare const resolvedPool: string;
|
|
9
29
|
export declare const resolvedMaxWorkers: number;
|
|
10
30
|
export declare const resolvedMinWorkers: number;
|
|
@@ -3,22 +3,38 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Centralizes shared-runner detection, env var overrides, Stryker compatibility,
|
|
5
5
|
* and execArgv logic used by node.ts, react.ts, and react-router.ts.
|
|
6
|
+
*
|
|
7
|
+
* CI defaults intentionally use available cores for file-level parallelism so
|
|
8
|
+
* consumer repos on 2-vCPU GitHub/Ubicloud runners get maxWorkers=2 instead of
|
|
9
|
+
* the old floor(cpus*0.75)=1 serial bottleneck. Shared workspace runners
|
|
10
|
+
* (VP_RUN_CONCURRENCY_LIMIT) still force a single worker because outer
|
|
11
|
+
* parallelism already fan-outs packages.
|
|
6
12
|
*/
|
|
7
13
|
import { cpus } from "node:os";
|
|
8
|
-
// Shared workspace runners need tighter worker caps to avoid oversubscription.
|
|
9
|
-
// `VP_RUN_CONCURRENCY_LIMIT` is the native Vite+ knob for shared task scheduling.
|
|
10
|
-
const underSharedWorkspaceRunner = !!process.env.VP_RUN_CONCURRENCY_LIMIT;
|
|
11
|
-
// Under a shared runner, default to a single Vitest worker per package.
|
|
12
|
-
// The workspace runner already provides outer parallelism, and allowing many
|
|
13
|
-
// inner fork workers causes frequent shutdown timeouts and EPIPE crashes on
|
|
14
|
-
// large happy-dom / integration suites.
|
|
15
|
-
const MAX_WORKERS = underSharedWorkspaceRunner ? 1 : Math.max(1, Math.floor(cpus().length * 0.75));
|
|
16
14
|
export const parsePositiveInt = (value) => {
|
|
17
15
|
if (!value || !/^\d+$/.test(value))
|
|
18
16
|
return;
|
|
19
17
|
const parsed = Number(value);
|
|
20
18
|
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
21
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the default Vitest `maxWorkers` when `VITEST_MAX_WORKERS` is unset.
|
|
22
|
+
*
|
|
23
|
+
* - Shared workspace runners (`VP_RUN_CONCURRENCY_LIMIT`): always 1.
|
|
24
|
+
* - CI (`CI=true` / `CI=1`): use all logical CPUs (min 1) so 2-core runners get 2 workers.
|
|
25
|
+
* - Local/dev: 75% of CPUs (min 1) to leave headroom for the editor/OS.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveDefaultMaxWorkers(options = {}) {
|
|
28
|
+
const env = options.env ?? process.env;
|
|
29
|
+
const underSharedWorkspaceRunner = Boolean(env.VP_RUN_CONCURRENCY_LIMIT);
|
|
30
|
+
if (underSharedWorkspaceRunner)
|
|
31
|
+
return 1;
|
|
32
|
+
const cpuCount = Math.max(1, Math.floor(options.cpuCount ?? cpus().length));
|
|
33
|
+
const inCi = env.CI === "true" || env.CI === "1";
|
|
34
|
+
if (inCi)
|
|
35
|
+
return cpuCount;
|
|
36
|
+
return Math.max(1, Math.floor(cpuCount * 0.75));
|
|
37
|
+
}
|
|
22
38
|
const requestedPool = process.env.VITEST_POOL;
|
|
23
39
|
const disableExecArgv = process.env.VITEST_DISABLE_EXEC_ARGV === "1";
|
|
24
40
|
const forcedMaxWorkers = parsePositiveInt(process.env.VITEST_MAX_WORKERS);
|
|
@@ -28,7 +44,7 @@ const isStryker = process.env.STRYKER_MUTATOR_WORKER !== undefined;
|
|
|
28
44
|
// Auto-clear execArgv to prevent ERR_WORKER_INVALID_EXEC_ARGV crashes.
|
|
29
45
|
// See: https://vitest.dev/config/pool.html#threads
|
|
30
46
|
export const resolvedPool = requestedPool === "threads" ? "threads" : "forks";
|
|
31
|
-
export const resolvedMaxWorkers = forcedMaxWorkers ??
|
|
47
|
+
export const resolvedMaxWorkers = forcedMaxWorkers ?? resolveDefaultMaxWorkers();
|
|
32
48
|
export const resolvedMinWorkers = forcedMinWorkers ?? 1;
|
|
33
49
|
// --max-old-space-size=1536: Cap V8 heap to 1.5GB (Node 24 default is 4.2GB).
|
|
34
50
|
// Actual worker RSS is 100-230MB; 1.5GB is 6× headroom while reducing phys_footprint
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpresso/agent-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Shared vitest, tsconfig, stryker, and workers-test config for webpresso consumers. Binary-free — pure test/config tooling.",
|
|
6
6
|
"homepage": "https://github.com/webpresso/agent-kit#readme",
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
"dist/esm",
|
|
17
17
|
"!dist/**/*.map",
|
|
18
18
|
"!dist/**/*.test.*",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
"README.md"
|
|
19
|
+
"LICENSE"
|
|
21
20
|
],
|
|
22
21
|
"type": "module",
|
|
23
22
|
"sideEffects": false,
|
|
@@ -124,6 +123,12 @@
|
|
|
124
123
|
"default": "./dist/esm/vitest/node-source.js"
|
|
125
124
|
}
|
|
126
125
|
},
|
|
126
|
+
"./vitest/pool-defaults": {
|
|
127
|
+
"import": {
|
|
128
|
+
"types": "./dist/esm/vitest/pool-defaults.d.ts",
|
|
129
|
+
"default": "./dist/esm/vitest/pool-defaults.js"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
127
132
|
"./vitest/react": {
|
|
128
133
|
"import": {
|
|
129
134
|
"types": "./dist/esm/vitest/react.d.ts",
|
|
@@ -179,9 +184,9 @@
|
|
|
179
184
|
},
|
|
180
185
|
"dependencies": {
|
|
181
186
|
"@vitejs/plugin-react": "^6.0.3",
|
|
182
|
-
"@webpresso/agent-core": "0.1.
|
|
187
|
+
"@webpresso/agent-core": "0.1.5",
|
|
183
188
|
"vite": "^8.1.5",
|
|
184
|
-
"vite-plus": "^0.2.
|
|
189
|
+
"vite-plus": "^0.2.5",
|
|
185
190
|
"vitest": "^4.1.10"
|
|
186
191
|
},
|
|
187
192
|
"peerDependencies": {
|
|
@@ -242,6 +247,7 @@
|
|
|
242
247
|
"./vitest/group-order": "./src/vitest/group-order.ts",
|
|
243
248
|
"./vitest/node": "./src/vitest/node.ts",
|
|
244
249
|
"./vitest/node-source": "./src/vitest/node-source.ts",
|
|
250
|
+
"./vitest/pool-defaults": "./src/vitest/pool-defaults.ts",
|
|
245
251
|
"./vitest/react": "./src/vitest/react.ts",
|
|
246
252
|
"./vitest/react-router": "./src/vitest/react-router.ts",
|
|
247
253
|
"./vitest/react-setup": "./src/vitest/react-setup.ts",
|