perf(ci): speed up server tests, Playwright shards, desktop/website E2E, and apt cache (#10504)

* perf(ci): cut PR CI wall-clock time across server tests, Playwright shards, and workflow setup

* fix(ci): guard empty apt cache copy, use 100% Vitest workers in CI, revert Playwright to 2 workers with built supervisor
This commit is contained in:
Mohamed Boudra authored and GitHub committed 2026-11-22 16:42:52 +07:00
1 parent 234ddf8dd7
commit 9cb521dda2
19 files changed
+207 -53

No files matched your search

+28 -5
View File
@@ -20,6 +20,8 @@ env:
# CI does not use the CUDA execution provider, and the onnxruntime-node
# postinstall download from NuGet is large enough to make npm ci flaky.
ONNXRUNTIME_NODE_INSTALL: skip
NPM_CONFIG_AUDIT: "false"
NPM_CONFIG_FUND: "false"
jobs:
changes:
@@ -165,8 +167,29 @@ jobs:
- name: Run website tests
run: npx vitest run packages/website/src --bail=1
# WebKit needs about 180 system packages (125 MB) from the Ubuntu mirror. The mirror
# sometimes serves them at under 100 kB/s, which turns a 1-minute step into 25 minutes.
# Keep the downloaded .deb files in the Actions cache so apt installs them without the mirror.
- name: Restore website browser system packages
uses: actions/cache@v4
with:
path: ~/website-browser-debs
key: website-browser-debs-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: website-browser-debs-${{ runner.os }}-
- name: Install website test browsers
run: npx playwright install --with-deps chromium webkit
run: |
mkdir -p ~/website-browser-debs
shopt -s nullglob
cached_debs=(~/website-browser-debs/*.deb)
if (( ${#cached_debs[@]} > 0 )); then
sudo cp "${cached_debs[@]}" /var/cache/apt/archives/
fi
npx playwright install --with-deps chromium webkit
archive_debs=(/var/cache/apt/archives/*.deb)
if (( ${#archive_debs[@]} > 0 )); then
cp "${archive_debs[@]}" ~/website-browser-debs/
fi
- name: Verify website mockups
run: npm run test:e2e --workspace=@getpaseo/website
@@ -466,9 +489,9 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
E2E_WORKERS: "2"
# File groups are weighted by observed reporter durations.
# Share of the test list per shard, rebalanced from the Playwright step
# minutes of five eight-shard runs so the slowest and fastest shards meet.
PWTEST_SHARD_WEIGHTS: "85:94:117:128:91:103:127:85"
# Share of the test list per shard, rebalanced from main and PR eight-shard
# durations so the slowest and fastest shards meet.
PWTEST_SHARD_WEIGHTS: "90:114:100:104:108:112:112:90"
- name: Upload test artifacts
uses: actions/upload-artifact@v4
@@ -582,7 +605,7 @@ jobs:
# Source tests do not read PASEO_CLI_TEST_SHARD. Run them once, on the
# shortest E2E shard, after its runner has built the server stack.
- name: Run CLI source tests
if: ${{ env.PASEO_CLI_TEST_SHARD == '3' }}
if: ${{ env.PASEO_CLI_TEST_SHARD == '2' }}
run: npm run test:unit --workspace=@getpaseo/cli
# The dependency watchers write build outputs, so run them after the parallel CLI tests.
@@ -6,6 +6,7 @@ import {
type ChildProcess,
type SpawnOptions,
} from "node:child_process";
import { existsSync } from "node:fs";
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import net from "node:net";
import { tmpdir } from "node:os";
@@ -229,7 +230,11 @@ export async function startIsolatedHostDaemon(
stdio: ["ignore", "ignore", "pipe"],
detached: false,
};
const spawned = publishedPackageRoot
const builtSupervisor = path.join(serverDir, "dist/scripts/supervisor-entrypoint.js");
const useBuiltSupervisor = Boolean(
publishedPackageRoot || (process.env.CI && existsSync(builtSupervisor)),
);
const spawned = useBuiltSupervisor
? spawn(process.execPath, ["dist/scripts/supervisor-entrypoint.js"], spawnOptions)
: spawnTsx("scripts/supervisor-entrypoint.ts", ["--dev"], spawnOptions);
+1 -1
View File
@@ -12,7 +12,7 @@ export default defineConfig({
timeout: 10_000,
},
fullyParallel: false,
workers: 1,
workers: Number(process.env.E2E_WORKERS ?? (process.env.CI ? "2" : "1")),
retries: process.env.CI ? 1 : 0,
reporter: [["list"]],
use: {
+1 -1
View File
@@ -90,7 +90,7 @@
"speech:transcribe:local": "tsx scripts/transcribe-local-wav.ts",
"test": "npm run test:unit && npm run test:integration",
"test:unit": "vitest run --fileParallelism --exclude \"**/*.e2e.test.ts\"",
"test:integration": "vitest run --maxWorkers=1 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/plugins/worktree-manager.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --maxWorkers=1 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t \"merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
"test:integration": "vitest run --fileParallelism --maxWorkers=3 src/server/git-filename-diffs.e2e.test.ts src/server/daemon-e2e/checkout-diff-content.e2e.test.ts src/server/daemon-e2e/create-agent-mode.e2e.test.ts src/server/daemon-e2e/filesystem.e2e.test.ts src/server/daemon-e2e/file-download.e2e.test.ts src/server/daemon-e2e/cli-logs-follow.e2e.test.ts src/server/creation/creation.e2e.test.ts src/server/daemon-e2e/creation-status.e2e.test.ts src/server/daemon-e2e/persisted-creation-caller.e2e.test.ts src/server/daemon-e2e/terminal-workspace-sdk.e2e.test.ts src/server/daemon-e2e/terminal-worker-lifecycle.e2e.test.ts src/server/workspace-create-worktree-source.e2e.test.ts src/server/daemon-e2e/models.e2e.test.ts src/server/daemon-e2e/live-preferences.e2e.test.ts src/server/daemon-e2e/oversized-message.e2e.test.ts src/server/agent/model-catalog.e2e.test.ts src/server/plugins/plugin-paseo-api.e2e.test.ts src/server/plugins/usage-sources.e2e.test.ts src/server/plugins/lifecycle.e2e.test.ts src/server/plugins/worktree-manager.e2e.test.ts src/server/connected-hosts/hosts.e2e.test.ts src/server/owned-subscriptions.e2e.test.ts && vitest run --fileParallelism --maxWorkers=3 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t \"merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history\"",
"test:hub-cli-contract": "vitest run --maxWorkers=1 src/server/hub/hub-cli-contract.test.ts",
"test:integration:all": "npm run test:e2e",
"test:integration:real": "vitest run real.e2e.test.ts",
@@ -11,6 +11,7 @@ import type {
ManagedProcessReapResult,
} from "./managed-processes/managed-processes.js";
import { createPaseoDaemon, type PaseoDaemonConfig } from "./bootstrap.js";
import { BuiltinPluginLoader } from "./plugins/builtin/index.js";
import { createTestAgentClients } from "./test-utils/fake-agent-client.js";
let tempRoot: string | null = null;
@@ -47,6 +48,10 @@ describe("daemon managed process bootstrap", () => {
managedProcesses,
} as PaseoDaemonConfig,
pino({ level: "silent" }),
{
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
},
);
try {
@@ -27,6 +27,7 @@ describe("bootstrap provider availability", () => {
test("loads a persisted Codex record without spawning a missing Codex binary", async () => {
const { createPaseoDaemon } = await import("./bootstrap.js");
const { BuiltinPluginLoader } = await import("./plugins/builtin/index.js");
const root = await mkdtemp(path.join(os.tmpdir(), "paseo-bootstrap-provider-"));
tempRoots.push(root);
const gitPath = execFileSync(process.platform === "win32" ? "where" : "which", ["git"], {
@@ -93,7 +94,10 @@ describe("bootstrap provider availability", () => {
process.on("unhandledRejection", onUnhandledRejection);
process.on("uncaughtException", onUncaughtException);
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }));
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
try {
await expect(daemon.agentStorage.listAll()).resolves.toHaveLength(1);
await expect(daemon.agentManager.listProviderAvailability()).resolves.toContainEqual({
@@ -13,6 +13,7 @@ import { afterEach, describe, expect, test, vi } from "vitest";
import { WebSocket } from "ws";
import { createPaseoDaemon, parseListenString, type PaseoDaemonConfig } from "./bootstrap.js";
import { BuiltinPluginLoader } from "./plugins/builtin/index.js";
import { loadConfig } from "./config.js";
import {
FileBackedProjectRegistry,
@@ -193,7 +194,10 @@ describe("paseo daemon bootstrap", () => {
voiceTts: { provider: "local", explicit: true, enabled: false },
},
};
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }));
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
let client: DaemonClient | null = null;
let proxyUpstream: http.Server | null = null;
@@ -467,7 +471,10 @@ describe("paseo daemon bootstrap", () => {
standaloneListen: `127.0.0.1:${address.port}`,
},
};
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }));
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
try {
await expect(daemon.start()).rejects.toThrow();
@@ -580,6 +587,8 @@ describe("paseo daemon bootstrap", () => {
speech: undefined,
};
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
hubRelationshipRemote: remote,
});
const starting = daemon.start();
@@ -720,7 +729,10 @@ export default function contribute(plugin: unknown) {
? {}
: { "startup-rollback": { source: "directory", path: pluginDirectory } },
};
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }));
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
try {
await expect(daemon.start()).rejects.toThrow();
@@ -812,7 +824,10 @@ export default function contribute(plugin: unknown) {
};
try {
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }));
const daemon = await createPaseoDaemon(config, pino({ level: "silent" }), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
try {
await daemon.start();
expect(daemon.getListenTarget()).toBeDefined();
@@ -943,7 +958,10 @@ export default function contribute(plugin: unknown) {
speech: undefined,
};
const daemon = await createPaseoDaemon(config, logger);
const daemon = await createPaseoDaemon(config, logger, {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
});
try {
await daemon.start();
+2
View File
@@ -518,6 +518,7 @@ export interface PaseoDaemon {
export interface PaseoDaemonDependencies {
builtinPlugins?: BuiltinPluginLoader;
lazyTerminalWorker?: boolean;
hubRelationshipRemote?: HubRelationshipRemote;
hubRelationshipClock?: HubRelationshipClock;
hubRelationshipRetryPolicy?: HubRelationshipRetryPolicy;
@@ -736,6 +737,7 @@ export async function createPaseoDaemon(
paseoVersion: daemonVersion,
logger,
getTerminalActivityUrl: () => createTerminalActivityUrl(boundListenTarget),
eagerLaunch: !dependencies.lazyTerminalWorker,
});
applyTerminalAgentHookSetting({ store: daemonConfigStore, logger });
@@ -1,8 +1,8 @@
import { execFile } from "node:child_process";
import { execFileSync } from "node:child_process";
import { EventEmitter } from "node:events";
import { existsSync, readFileSync, realpathSync, statSync, watch } from "node:fs";
import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
import { existsSync, readFileSync, realpathSync, rmSync, statSync, watch } from "node:fs";
import { cp, mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
import { networkInterfaces, platform, tmpdir } from "node:os";
import path from "node:path";
import { promisify } from "node:util";
@@ -21,6 +21,7 @@ import type {
SessionOutboundMessage,
} from "../../messages.js";
import { createPaseoDaemon, type PaseoDaemon, type PaseoDaemonConfig } from "../../bootstrap.js";
import { BuiltinPluginLoader } from "../../plugins/builtin/index.js";
import type { WebSocketLike } from "../../websocket-server.js";
import type {
AgentClient,
@@ -64,6 +65,35 @@ const SOCKET_URL = "wss://hub.test/daemon";
const REPOSITORY_ROOT = path.resolve(import.meta.dirname, "../../../../../..");
const REMOVAL_RETRY_CODES = new Set(["EBUSY", "ENOTEMPTY", "EPERM"]);
let hubGitTemplatePromise: Promise<string> | null = null;
let hubGitTemplateDir: string | null = null;
function getHubGitTemplate(): Promise<string> {
if (!hubGitTemplatePromise) {
hubGitTemplatePromise = (async () => {
const dir = await mkdtemp(path.join(tmpdir(), "paseo-hub-git-template-"));
execFileSync("git", ["init", "-b", "main", dir], { stdio: "ignore" });
execFileSync("git", ["-C", dir, "config", "user.email", "hub@test.invalid"]);
execFileSync("git", ["-C", dir, "config", "user.name", "Hub Test"]);
execFileSync("git", ["-C", dir, "commit", "--allow-empty", "-m", "initial"], {
stdio: "ignore",
});
hubGitTemplateDir = dir;
process.once("exit", () => {
if (hubGitTemplateDir) {
try {
rmSync(hubGitTemplateDir, { recursive: true, force: true });
} catch {
// Best-effort cleanup on process exit.
}
}
});
return dir;
})();
}
return hubGitTemplatePromise;
}
async function removeDirectoryAfterWritesSettle(directory: string): Promise<void> {
for (let retry = 0; retry < 10; retry += 1) {
try {
@@ -1399,15 +1429,10 @@ export class HubRelationshipHarness {
private async createHome(): Promise<void> {
this.root = await mkdtemp(path.join(tmpdir(), "paseo-hub-relationship-"));
await cp(await getHubGitTemplate(), this.root, { recursive: true });
this.paseoHome = path.join(this.root, ".paseo");
const staticDir = path.join(this.root, "static");
await Promise.all([mkdir(this.paseoHome, { recursive: true }), mkdir(staticDir)]);
execFileSync("git", ["init", "-b", "main", this.root], { stdio: "ignore" });
execFileSync("git", ["-C", this.root, "config", "user.email", "hub@test.invalid"]);
execFileSync("git", ["-C", this.root, "config", "user.name", "Hub Test"]);
execFileSync("git", ["-C", this.root, "commit", "--allow-empty", "-m", "initial"], {
stdio: "ignore",
});
this.config = {
listen: "0.0.0.0:0",
paseoHome: this.paseoHome,
@@ -1435,6 +1460,8 @@ export class HubRelationshipHarness {
},
});
this.daemon = await createPaseoDaemon(this.config, pino({ level: "trace" }, destination), {
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
hubRelationshipRemote: this.remote,
hubRelationshipClock: this.clock,
hubRelationshipRetryPolicy: this.clock,
@@ -397,11 +397,15 @@ export async function compilePlugin(entryPaths: {
clientBundle: string | null;
serverBundle: string | null;
}> {
const [clientBundle, serverBundle] = await Promise.all([
entryPaths.client ? compileTarget(entryPaths.client, "client") : null,
entryPaths.server ? compileTarget(entryPaths.server, "server") : null,
// Settle both targets before rethrowing so the compiler worker has no build
// left in flight when it replies with an error and can stay warm for reuse.
const [clientResult, serverResult] = await Promise.allSettled([
entryPaths.client ? compileTarget(entryPaths.client, "client") : Promise.resolve(null),
entryPaths.server ? compileTarget(entryPaths.server, "server") : Promise.resolve(null),
]);
return { clientBundle, serverBundle };
if (clientResult.status === "rejected") throw clientResult.reason;
if (serverResult.status === "rejected") throw serverResult.reason;
return { clientBundle: clientResult.value, serverBundle: serverResult.value };
}
const CLIENT_ENTRY_FILENAMES = ["index.client.ts", "index.client.tsx"] as const;
@@ -134,9 +134,6 @@ class PluginCompiler {
Object.assign(error, reply.properties);
if (reply.errors) Object.assign(error, { errors: reply.errors });
if (reply.warnings) Object.assign(error, { warnings: reply.warnings });
// Promise.all can reject while the other target is still compiling.
// Retire the compiler before another request can enter it.
this.stopWorker(worker);
reject(error);
}
};
@@ -3,6 +3,7 @@ import { execFile } from "node:child_process";
import { promisify } from "node:util";
import pino from "pino";
import { createPaseoDaemon } from "../bootstrap.js";
import { BuiltinPluginLoader } from "./builtin/index.js";
import { loadConfig } from "../config.js";
import { createRequire } from "node:module";
import { runInNewContext } from "node:vm";
@@ -218,6 +219,10 @@ test("password-protected config reload preserves startup auth and session constr
staticDir: home,
},
pino({ level: "silent" }),
{
builtinPlugins: new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: true,
},
);
await daemon.start();
const target = daemon.getListenTarget();
@@ -57,6 +57,7 @@ interface TestPaseoDaemonOptions {
pluginsEnabled?: PaseoDaemonConfig["pluginsEnabled"];
pluginRegistryUrl?: PaseoDaemonConfig["pluginRegistryUrl"];
builtinPlugins?: BuiltinPluginLoader;
lazyTerminalWorker?: boolean;
plugins?: PaseoDaemonConfig["plugins"];
}
@@ -110,6 +111,7 @@ export async function createTestPaseoDaemon(
const logger = options.logger ?? pino({ level: "silent" });
const daemon = await createPaseoDaemon(config, logger, {
builtinPlugins: options.builtinPlugins ?? new BuiltinPluginLoader(undefined, []),
lazyTerminalWorker: options.lazyTerminalWorker ?? true,
serverFeatureOverrides: {
daemonStatusRpc: options.daemonStatusRpcCapability,
relayConfig: options.relayConfigCapability,
@@ -1,9 +1,9 @@
import { execFileSync } from "node:child_process";
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
import { cpSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { expect, onTestFinished, test } from "vitest";
import { afterAll, expect, onTestFinished, test } from "vitest";
import { DaemonClient } from "./test-utils/index.js";
import { WebSocket } from "ws";
@@ -22,22 +22,50 @@ import { createTestPaseoDaemon } from "./test-utils/paseo-daemon.js";
// the created worktree's observable branch is the only honest evidence the
// request fields reached git.
function createGitRepoWithBranch(): { repoDir: string; tempRoot: string } {
const tempRoot = mkdtempSync(path.join(tmpdir(), "workspace-create-worktree-source-"));
const repoDir = path.join(tempRoot, "repo");
execFileSync("git", ["init", "-b", "main", repoDir], { stdio: "pipe" });
execFileSync("git", ["config", "core.autocrlf", "false"], { cwd: repoDir, stdio: "pipe" });
let templateRepoRoot: string | null = null;
let templateRepoDir: string | null = null;
function getTemplateGitRepoWithBranch(): string {
if (templateRepoDir) return templateRepoDir;
templateRepoRoot = mkdtempSync(path.join(tmpdir(), "workspace-create-worktree-source-template-"));
templateRepoDir = path.join(templateRepoRoot, "repo");
execFileSync("git", ["init", "-b", "main", templateRepoDir], { stdio: "pipe" });
execFileSync("git", ["config", "core.autocrlf", "false"], {
cwd: templateRepoDir,
stdio: "pipe",
});
execFileSync("git", ["config", "user.email", "test@getpaseo.local"], {
cwd: repoDir,
cwd: templateRepoDir,
stdio: "pipe",
});
execFileSync("git", ["config", "user.name", "Paseo Test"], {
cwd: templateRepoDir,
stdio: "pipe",
});
execFileSync("git", ["config", "user.name", "Paseo Test"], { cwd: repoDir, stdio: "pipe" });
execFileSync("git", ["-c", "commit.gpgsign=false", "commit", "--allow-empty", "-m", "initial"], {
cwd: repoDir,
cwd: templateRepoDir,
stdio: "pipe",
});
// An existing branch the checkout action must target by refName.
execFileSync("git", ["branch", "feature/existing-branch"], { cwd: repoDir, stdio: "pipe" });
execFileSync("git", ["branch", "feature/existing-branch"], {
cwd: templateRepoDir,
stdio: "pipe",
});
return templateRepoDir;
}
afterAll(() => {
if (templateRepoRoot) {
rmSync(templateRepoRoot, { recursive: true, force: true });
templateRepoRoot = null;
templateRepoDir = null;
}
});
function createGitRepoWithBranch(): { repoDir: string; tempRoot: string } {
const tempRoot = mkdtempSync(path.join(tmpdir(), "workspace-create-worktree-source-"));
const repoDir = path.join(tempRoot, "repo");
cpSync(getTemplateGitRepoWithBranch(), repoDir, { recursive: true });
return { repoDir, tempRoot };
}
@@ -997,6 +997,11 @@ export interface StartWorkerTerminalManagerOptions {
logger: Logger;
getTerminalActivityUrl?: () => string | null;
requestTimeoutMs?: number;
/**
* When false, skip launching a fresh terminal worker until the first terminal
* is created (existing workers are still adopted). Production leaves this true.
*/
eagerLaunch?: boolean;
}
// The current worker plus one draining a previous protocol. Every live worker counts,
@@ -1269,7 +1274,7 @@ export async function startWorkerTerminalManager(
};
await prune();
if (!current) {
if (!current && options.eagerLaunch !== false) {
try {
current = await startCurrent();
} catch (error) {
+30 -8
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { describe, it, expect, beforeEach, afterEach, afterAll } from "vitest";
import { execFileSync, execSync, spawnSync } from "child_process";
import {
cpSync,
existsSync,
mkdtempSync,
rmSync,
@@ -98,16 +99,37 @@ import {
writePaseoWorktreeMetadata,
} from "./worktree-metadata.js";
let templateRepoRoot: string | null = null;
let templateRepoDir: string | null = null;
function getTemplateRepoDir(): string {
if (templateRepoDir) return templateRepoDir;
templateRepoRoot = realpathSync.native(mkdtempSync(join(tmpdir(), "checkout-git-template-")));
templateRepoDir = join(templateRepoRoot, "repo");
mkdirSync(templateRepoDir, { recursive: true });
execFileSync("git", ["init", "-b", "main"], { cwd: templateRepoDir });
execFileSync("git", ["config", "user.email", "test@test.com"], { cwd: templateRepoDir });
execFileSync("git", ["config", "user.name", "Test"], { cwd: templateRepoDir });
writeFileSync(join(templateRepoDir, "file.txt"), "hello\n");
execFileSync("git", ["add", "."], { cwd: templateRepoDir });
execFileSync("git", ["-c", "commit.gpgsign=false", "commit", "-m", "initial"], {
cwd: templateRepoDir,
});
return templateRepoDir;
}
afterAll(() => {
if (templateRepoRoot) {
rmSync(templateRepoRoot, { recursive: true, force: true });
templateRepoRoot = null;
templateRepoDir = null;
}
});
function initRepo(): { tempDir: string; repoDir: string } {
const tempDir = realpathSync.native(mkdtempSync(join(tmpdir(), "checkout-git-test-")));
const repoDir = join(tempDir, "repo");
mkdirSync(repoDir, { recursive: true });
execFileSync("git", ["init", "-b", "main"], { cwd: repoDir });
execFileSync("git", ["config", "user.email", "test@test.com"], { cwd: repoDir });
execFileSync("git", ["config", "user.name", "Test"], { cwd: repoDir });
writeFileSync(join(repoDir, "file.txt"), "hello\n");
execFileSync("git", ["add", "."], { cwd: repoDir });
execFileSync("git", ["-c", "commit.gpgsign=false", "commit", "-m", "initial"], { cwd: repoDir });
cpSync(getTemplateRepoDir(), repoDir, { recursive: true });
return { tempDir, repoDir };
}
+3
View File
@@ -19,6 +19,9 @@ export default defineConfig({
setupFiles: [path.resolve(__dirname, "./src/test-utils/vitest-setup.ts")],
pool: "forks",
fileParallelism: false,
// On 4-CPU CI runners, Vitest's default (availableParallelism - 1 = 3) leaves
// 25% of the runner idle during parallel unit suites. CLI --maxWorkers still overrides this.
maxWorkers: process.env.CI ? "100%" : undefined,
exclude: ["**/node_modules/**", "**/dist/**", "**/.claude/**", "**/.dev/**"],
},
});
+1 -1
View File
@@ -5,7 +5,7 @@ const baseURL = process.env.WEBSITE_TEST_URL ?? "http://127.0.0.1:8187";
export default defineConfig({
testDir: "./e2e",
workers: 1,
workers: process.env.CI ? 4 : 1,
use: { baseURL, screenshot: "only-on-failure", trace: "retain-on-failure" },
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
+7 -3
View File
@@ -554,14 +554,18 @@ test("Windows units and integration run independently with complete routed cover
// Each vitest start costs about half a minute on Windows, so the
// name-filtered files share one invocation and one combined filter.
assert.equal(invocations.length, 2);
assert.ok(invocations.every((command) => command.startsWith("vitest run --maxWorkers=1 ")));
assert.ok(
invocations.every((command) =>
command.startsWith("vitest run --fileParallelism --maxWorkers=3 "),
),
);
assert.doesNotMatch(invocations[0], / -t /);
assert.equal(
invocations[1],
'vitest run --maxWorkers=1 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t "merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history"',
'vitest run --fileParallelism --maxWorkers=3 src/server/agent/providers/omp/history.e2e.test.ts src/server/daemon-e2e/git-operations.e2e.test.ts src/server/session.create-agent-worktree-autoarchive.e2e.test.ts src/server/agent/providers/opencode-bridge.local.e2e.test.ts src/server/daemon-e2e/relay-transport.e2e.test.ts -t "merges into|creates a worktree and auto-archives both|versioned runtime|oversized attachments|connected hosts|password-protected daemon refuses|replays selected OMP history"',
);
const serverConfig = readFileSync(new URL("packages/server/vitest.config.ts", repoRoot), "utf8");
assert.doesNotMatch(serverConfig, /maxWorkers/);
assert.doesNotMatch(serverConfig, /maxWorkers:\s*1\b/);
function condition(job) {
return / if: \$\{\{ (.+) \}\}/.exec(job)[1];