mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:10:45 +00:00
ci: cap extension shard vitest workers
This commit is contained in:
@@ -12,7 +12,10 @@ import {
|
||||
} from "./vitest/vitest.contracts-shared.ts";
|
||||
import { createGatewayVitestConfig } from "./vitest/vitest.gateway.config.ts";
|
||||
import { createPluginSdkLightVitestConfig } from "./vitest/vitest.plugin-sdk-light.config.ts";
|
||||
import { sharedVitestConfig } from "./vitest/vitest.shared.config.ts";
|
||||
import {
|
||||
resolveSharedVitestWorkerConfig,
|
||||
sharedVitestConfig,
|
||||
} from "./vitest/vitest.shared.config.ts";
|
||||
import { createUiVitestConfig } from "./vitest/vitest.ui.config.ts";
|
||||
import { createUnitFastVitestConfig } from "./vitest/vitest.unit-fast.config.ts";
|
||||
import unitUiConfig from "./vitest/vitest.unit-ui.config.ts";
|
||||
@@ -44,6 +47,39 @@ describe("projects vitest config", () => {
|
||||
expect(createContractsVitestConfig(pluginContractPatterns).test.pool).toBe("forks");
|
||||
});
|
||||
|
||||
it("honors explicit worker caps in CI vitest lanes", () => {
|
||||
expect(
|
||||
resolveSharedVitestWorkerConfig({
|
||||
env: { CI: "true", OPENCLAW_VITEST_MAX_WORKERS: "1" },
|
||||
isCI: true,
|
||||
isWindows: false,
|
||||
localScheduling: {
|
||||
fileParallelism: false,
|
||||
maxWorkers: 1,
|
||||
throttledBySystem: false,
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
fileParallelism: false,
|
||||
maxWorkers: 1,
|
||||
});
|
||||
expect(
|
||||
resolveSharedVitestWorkerConfig({
|
||||
env: { CI: "true" },
|
||||
isCI: true,
|
||||
isWindows: false,
|
||||
localScheduling: {
|
||||
fileParallelism: false,
|
||||
maxWorkers: 1,
|
||||
throttledBySystem: false,
|
||||
},
|
||||
}),
|
||||
).toEqual({
|
||||
fileParallelism: true,
|
||||
maxWorkers: 3,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps contract shards on the non-isolated fork runner by default", () => {
|
||||
const config = createContractsVitestConfig(pluginContractPatterns);
|
||||
expect(config.test.pool).toBe("forks");
|
||||
|
||||
@@ -76,7 +76,43 @@ const localScheduling = resolveLocalVitestScheduling(
|
||||
detectVitestHostInfo(),
|
||||
defaultPool,
|
||||
);
|
||||
const ciWorkers = isWindows ? 2 : 3;
|
||||
|
||||
function hasWorkerOverride(env: Record<string, string | undefined>): boolean {
|
||||
return Boolean((env.OPENCLAW_VITEST_MAX_WORKERS ?? env.OPENCLAW_TEST_WORKERS)?.trim());
|
||||
}
|
||||
|
||||
export function resolveSharedVitestWorkerConfig(params: {
|
||||
env?: Record<string, string | undefined>;
|
||||
isCI?: boolean;
|
||||
isWindows?: boolean;
|
||||
localScheduling?: LocalVitestScheduling;
|
||||
}): Pick<LocalVitestScheduling, "fileParallelism" | "maxWorkers"> {
|
||||
const env = params.env ?? process.env;
|
||||
const local = params.localScheduling ?? localScheduling;
|
||||
if (hasWorkerOverride(env)) {
|
||||
return {
|
||||
fileParallelism: local.fileParallelism,
|
||||
maxWorkers: local.maxWorkers,
|
||||
};
|
||||
}
|
||||
if (params.isCI ?? isCI) {
|
||||
return {
|
||||
fileParallelism: true,
|
||||
maxWorkers: (params.isWindows ?? isWindows) ? 2 : 3,
|
||||
};
|
||||
}
|
||||
return {
|
||||
fileParallelism: local.fileParallelism,
|
||||
maxWorkers: local.maxWorkers,
|
||||
};
|
||||
}
|
||||
|
||||
const workerConfig = resolveSharedVitestWorkerConfig({
|
||||
env: process.env,
|
||||
isCI,
|
||||
isWindows,
|
||||
localScheduling,
|
||||
});
|
||||
|
||||
if (!isCI && localScheduling.throttledBySystem && shouldPrintVitestThrottle(process.env)) {
|
||||
console.error(
|
||||
@@ -118,8 +154,8 @@ export const sharedVitestConfig = {
|
||||
isolate: false,
|
||||
pool: defaultPool,
|
||||
runner: nonIsolatedRunnerPath,
|
||||
maxWorkers: isCI ? ciWorkers : localScheduling.maxWorkers,
|
||||
fileParallelism: isCI ? true : localScheduling.fileParallelism,
|
||||
maxWorkers: workerConfig.maxWorkers,
|
||||
fileParallelism: workerConfig.fileParallelism,
|
||||
forceRerunTriggers: [
|
||||
"package.json",
|
||||
"pnpm-lock.yaml",
|
||||
|
||||
Reference in New Issue
Block a user