mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-25 01:35:31 +00:00
* fix(server): serve agent MCP over the 2026-07-28 protocol Reasoning: - The bundled `@modelcontextprotocol/sdk@1.29.0` only speaks up to protocol `2025-11-25`, while current MCP clients (Claude Code, Codex, Grok CLI, ACP harnesses) send `mcp-protocol-version: 2026-07-28` and get `400 Bad Request: Unsupported protocol version` on the first request after `initialize`. The agent then runs without any Paseo tool, so `list_agents`, `create_agent`, and the rest silently disappear from the tool surface (#3009). - Widening the accepted version list (the approach in #4570 / #4375) hides the rejection but leaves the server implementing 2025 semantics while telling the client it speaks 2026-07-28. Changes: - Replace the v1 `StreamableHTTPServerTransport` wiring in `bootstrap.ts` with the v2 dual-era `createMcpHandler(..., { legacy: "stateless" })` plus `toNodeHandler` from `@modelcontextprotocol/node`. Modern 2026-07-28 requests and 2025-era clients are served by the same handler; per-request stateless serving is unchanged. - Move `agent/mcp-server.ts` to `@modelcontextprotocol/server` (`McpServer`, `ServerContext`, `context.mcpReq.signal`). - Keep `@modelcontextprotocol/sdk` for the existing client-side integrations (e.g. the OMP MCP bridge). - Assert the JSON-RPC `-32602` rejection in `mcp-server.test.ts`: a call to an unregistered tool is a protocol error, which the v1 server folded into an `isError` result. Verification: - `npx tsc -p packages/server/tsconfig.server.json` clean; `npm run typecheck` clean; `oxfmt`/`oxlint` clean on the touched files. - `npm ci --dry-run` accepts the lockfile. - `packages/server`: `mcp-server.test.ts` 194/194, `agent-mcp.e2e.test.ts` 8/8, `mcp-parity.e2e.test.ts` 38/38. - Manual check on macOS against a real daemon: a `dsh` agent (sends 2026-07-28) lists Paseo tools (`create_workspace`, `list_workspaces`, `create_agent`) and the daemon logs zero `MCP transport error` / `Unsupported protocol version` entries. * test(server): cover the modern MCP envelope on the agent endpoint Reasoning: - Greptile flagged that the tool registration used a `registerTool` re-cast, which defeats the SDK's type check on a path every agent tool call goes through. - The modern (2026-07-28) path had no regression coverage, so a looser "accept the version header" implementation would also pass the existing tests. Changes: - Narrow only the schema at the registration boundary (`inputSchema as StandardSchemaWithJSON`) and document why: Paseo declares schemas through the `zod` root entry, the SDK types them through `zod/v4` core; same runtime, distinct type identities. - Add a modern-protocol test that drives `createMcpHandler` with a per-request envelope (`_meta` protocol version + `mcp-method` header) and asserts the catalog tools come back. Verification: - `npx vitest run src/server/agent/mcp-server.test.ts` 195/195. - `npx tsc -p packages/server/tsconfig.server.json` clean; `oxfmt` / `oxlint` clean. * test(server): expect the agent MCP handler's own rejection The stateless MCP handler answers a body-less POST with 415 (unsupported media type) instead of the old transport's 406. The smoke test only needs the route to be live before the reload and gone after it, so assert that answer and say why the code changed. * fix(server): give native host tools the schema the agent MCP serves The agent MCP endpoint now registers tools with @modelcontextprotocol/server, which converts input schemas with zod at the draft 2020-12 target. The OpenCode bridge and OMP host tools still serialized through the v1 SDK internals as draft-07, so the plugin parity test (native schema equals advertised schema) failed. Serialize with the same zod conversion so one schema reaches both paths, and drop the dependency on unexported v1 SDK internals. OpenCode reads both dialects and defaults to 2020-12. OMP rewrites draft-07 to 2020-12 before sending to a model. * test(server): negotiate the agent MCP with pinned, auto and legacy clients Drive a real daemon's /mcp/agents with @modelcontextprotocol/client 2.4.0: - pinned to 2026-07-28: fails on the v1 transport ("server did not offer pinned protocol version 2026-07-28"). - auto: falls back to 2025-11-25 on the v1 transport. The test also asserts that the daemon logs no transport errors. - legacy: the 2025-era compatibility guard. Run the block in test:integration so CI keeps it, and translate the modern envelope test comment to English. * test(ci): route the agent MCP negotiation block through server integration The block shares the existing name-filtered vitest invocation, so it adds no extra vitest start to the Windows integration job. * test(website): play the orchestration scene on a held page clock The scene player advances at most 64ms per animation frame, so on a CI runner where headless WebKit paints a few frames a second the scene ran in slow motion and missed the 20s wait for the subagents pill. The test now pauses Playwright's page clock after hydration, checks the empty chat, then runs the clock past the scene before asserting the roster. --------- Co-authored-by: Ouyang Xingyuan <galaxyroaming@qq.com>
978 lines
38 KiB
JavaScript
978 lines
38 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
import { readFileSync, readdirSync, mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { relative as relativePath } from "node:path";
|
|
import test from "node:test";
|
|
import { runInNewContext } from "node:vm";
|
|
|
|
import { PUBLISH_WORKSPACES } from "./publish-release-packages.mjs";
|
|
|
|
const repoRoot = new URL("../", import.meta.url);
|
|
const ciWorkflowPath = new URL(".github/workflows/ci.yml", repoRoot);
|
|
const dockerWorkflowPath = new URL(".github/workflows/docker.yml", repoRoot);
|
|
const nixWorkflowPath = new URL(".github/workflows/nix.yml", repoRoot);
|
|
const filtersPath = new URL(".github/ci-paths.yml", repoRoot);
|
|
const serverTsconfigPath = new URL("packages/server/tsconfig.server.json", repoRoot);
|
|
const desktopPackagePath = new URL("packages/desktop/package.json", repoRoot);
|
|
|
|
const gatedCiJobs = new Map([
|
|
["quality", { name: "quality", contracts: ["format", "quality", "relay", "sdk"] }],
|
|
["typecheck", { name: "typecheck", contract: "quality" }],
|
|
["server-tests-ubuntu", { name: "server-tests (ubuntu-latest)", contracts: ["server", "hub"] }],
|
|
["server-tests-windows", { name: "server-tests (windows-latest)", contracts: ["server", "hub"] }],
|
|
[
|
|
"server-integration-windows",
|
|
{ name: "server-integration (windows-latest)", contract: "server" },
|
|
],
|
|
[
|
|
"server-tests-macos",
|
|
{ name: "server-tests (macos-latest, file observation)", contract: "server" },
|
|
],
|
|
["desktop-tests-ubuntu", { name: "desktop-tests (ubuntu-latest)", contract: "desktop" }],
|
|
["desktop-tests-windows", { name: "desktop-tests (windows-latest)", contract: "desktop" }],
|
|
["app-tests", { name: "app-tests", contract: "app" }],
|
|
["playwright-1", { name: "playwright (shard 1/8)", contract: "browser" }],
|
|
["playwright-2", { name: "playwright (shard 2/8)", contract: "browser" }],
|
|
["playwright-3", { name: "playwright (shard 3/8)", contract: "browser" }],
|
|
["playwright-4", { name: "playwright (shard 4/8)", contract: "browser" }],
|
|
["playwright-5", { name: "playwright (shard 5/8)", contract: "browser" }],
|
|
["playwright-6", { name: "playwright (shard 6/8)", contract: "browser" }],
|
|
["playwright-7", { name: "playwright (shard 7/8)", contract: "browser" }],
|
|
["playwright-8", { name: "playwright (shard 8/8)", contract: "browser" }],
|
|
["cli-tests-1", { name: "cli-tests (shard 1/3)", contract: "cli" }],
|
|
["cli-tests-2", { name: "cli-tests (shard 2/3)", contract: "cli" }],
|
|
["cli-tests-3", { name: "cli-tests (shard 3/3)", contract: "cli" }],
|
|
]);
|
|
|
|
function jobBlocks(source) {
|
|
const jobs = new Map();
|
|
let currentJob;
|
|
|
|
for (const line of (source.split("\njobs:\n")[1] ?? source).split("\n")) {
|
|
const jobMatch = /^ ([a-z0-9_-]+):\s*$/.exec(line);
|
|
if (jobMatch) {
|
|
currentJob = jobMatch[1];
|
|
jobs.set(currentJob, []);
|
|
continue;
|
|
}
|
|
if (currentJob) jobs.get(currentJob).push(line);
|
|
}
|
|
return jobs;
|
|
}
|
|
|
|
function loadFilters(path) {
|
|
const filters = {};
|
|
let currentFilter;
|
|
|
|
for (const line of readFileSync(path, "utf8").split("\n")) {
|
|
const filterMatch = /^([a-z_]+):\s*$/.exec(line);
|
|
if (filterMatch) {
|
|
currentFilter = filterMatch[1];
|
|
filters[currentFilter] = [];
|
|
continue;
|
|
}
|
|
const patternMatch = /^ - "([^"]+)"\s*$/.exec(line);
|
|
if (currentFilter && patternMatch) filters[currentFilter].push(patternMatch[1]);
|
|
}
|
|
return filters;
|
|
}
|
|
|
|
function filesUnder(relativeDirectory, predicate) {
|
|
const directory = new URL(`${relativeDirectory}/`, repoRoot);
|
|
return readdirSync(directory, { recursive: true, withFileTypes: true })
|
|
.filter((entry) => entry.isFile())
|
|
.map((entry) =>
|
|
[relativeDirectory, relativePath(directory.pathname, entry.parentPath), entry.name]
|
|
.filter(Boolean)
|
|
.join("/")
|
|
.replaceAll("\\", "/"),
|
|
)
|
|
.filter(predicate)
|
|
.sort();
|
|
}
|
|
|
|
test("gated checks are statically named jobs with real job-level gating", () => {
|
|
const workflowSource = readFileSync(ciWorkflowPath, "utf8");
|
|
const jobs = jobBlocks(workflowSource);
|
|
const trigger = workflowSource.split("jobs:", 1)[0];
|
|
|
|
assert.match(trigger, /^\s+merge_group:\s*$/m);
|
|
assert.doesNotMatch(workflowSource, /strategy:\s*\n\s+matrix:/);
|
|
assert.doesNotMatch(workflowSource, /RUN_TESTS|Skip unaffected|No .* changes detected/);
|
|
|
|
for (const [jobId, expected] of gatedCiJobs) {
|
|
const job = jobs.get(jobId)?.join("\n");
|
|
assert.ok(job, `missing static job ${jobId}`);
|
|
assert.match(job, new RegExp(`^ name: ${expected.name.replace(/[()]/g, "\\$&")}$`, "m"));
|
|
assert.match(job, /needs\.changes\.outputs\.full != 'false'/);
|
|
for (const contract of expected.contracts ?? [expected.contract]) {
|
|
assert.match(job, new RegExp(`needs\\.changes\\.outputs\\.${contract} != 'false'`));
|
|
}
|
|
}
|
|
});
|
|
|
|
test("pull-request checks run for every base branch, including stacked PRs", () => {
|
|
for (const workflowPath of [
|
|
ciWorkflowPath,
|
|
new URL(".github/workflows/desktop-packages.yml", repoRoot),
|
|
]) {
|
|
const trigger = readFileSync(workflowPath, "utf8").split("jobs:", 1)[0];
|
|
const pullRequest = trigger.match(/^ pull_request:\n((?: .*\n)*)/m);
|
|
assert.ok(pullRequest, `${workflowPath.pathname} runs on pull requests`);
|
|
assert.doesNotMatch(pullRequest[1], /branches/);
|
|
}
|
|
});
|
|
|
|
test("change gating allows superseded workflow runs to cancel", () => {
|
|
const ci = readFileSync(ciWorkflowPath, "utf8");
|
|
assert.match(
|
|
ci,
|
|
/^concurrency:\n group: ci-\$\{\{ github\.workflow \}\}-\$\{\{ github\.ref \}\}\n cancel-in-progress: true$/m,
|
|
"a newer push to any ref, main included, cancels the superseded run",
|
|
);
|
|
for (const workflowPath of [ciWorkflowPath, dockerWorkflowPath, nixWorkflowPath]) {
|
|
const source = readFileSync(workflowPath, "utf8");
|
|
assert.doesNotMatch(
|
|
source,
|
|
/\$\{\{\s*always\(\)/,
|
|
"always() keeps jobs alive after concurrency cancellation; use !cancelled() for fail-open gating",
|
|
);
|
|
}
|
|
});
|
|
|
|
test("published npm packages declare and ship the repository license", () => {
|
|
const rootManifest = JSON.parse(readFileSync(new URL("package.json", repoRoot), "utf8"));
|
|
assert.match(rootManifest.scripts["release:publish"], /scripts\/publish-release-packages\.mjs/);
|
|
const workspaceArgs = PUBLISH_WORKSPACES.map((workspace) => `--workspace=${workspace}`);
|
|
const packed = JSON.parse(
|
|
execFileSync("npm", ["pack", "--dry-run", "--ignore-scripts", "--json", ...workspaceArgs], {
|
|
cwd: repoRoot,
|
|
encoding: "utf8",
|
|
}),
|
|
);
|
|
const manifests = new Map(
|
|
rootManifest.workspaces.map((workspace) => {
|
|
const directory = new URL(`${workspace}/`, repoRoot);
|
|
const manifest = JSON.parse(readFileSync(new URL("package.json", directory), "utf8"));
|
|
return [manifest.name, { directory, manifest }];
|
|
}),
|
|
);
|
|
const licenses = packed.map(({ name, files }) => ({
|
|
name,
|
|
license: manifests.get(name).manifest.license,
|
|
files: files.filter((file) => file.path === "LICENSE").map((file) => file.path),
|
|
}));
|
|
assert.deepEqual(
|
|
licenses,
|
|
PUBLISH_WORKSPACES.map((workspace) => ({
|
|
name: workspace,
|
|
license: "Apache-2.0",
|
|
files: ["LICENSE"],
|
|
})),
|
|
);
|
|
const repositoryLicense = readFileSync(new URL("LICENSE", repoRoot), "utf8");
|
|
for (const { name } of packed) {
|
|
const { directory } = manifests.get(name);
|
|
assert.equal(readFileSync(new URL("LICENSE", directory), "utf8"), repositoryLicense, name);
|
|
}
|
|
});
|
|
|
|
test("focused contracts stay inside existing required checks", () => {
|
|
const jobs = jobBlocks(readFileSync(ciWorkflowPath, "utf8"));
|
|
const changes = jobs.get("changes")?.join("\n") ?? "";
|
|
const server = jobs.get("server-tests-ubuntu")?.join("\n") ?? "";
|
|
const desktop = jobs.get("desktop-tests-ubuntu")?.join("\n") ?? "";
|
|
|
|
assert.match(changes, /scripts\/daemon-launch-contract\.test\.mjs/);
|
|
assert.doesNotMatch(changes, /Install dependencies|npm run build/);
|
|
|
|
assert.match(server, /test:hub-cli-contract/);
|
|
assert.match(server, /npm run test --workspace=@getpaseo\/server/);
|
|
assert.ok(!jobs.has("hub-cli-contract"));
|
|
|
|
assert.match(desktop, /test:e2e:renderer/);
|
|
assert.match(desktop, /test:e2e:browser-tabs/);
|
|
assert.match(desktop, /npm run test --workspace=@getpaseo\/desktop/);
|
|
assert.ok(!jobs.has("desktop-browser-bridge"));
|
|
assert.ok(!jobs.has("playwright-desktop"));
|
|
});
|
|
|
|
test("ordinary CI keeps app tests without prebuilding Android modules", () => {
|
|
const source = readFileSync(ciWorkflowPath, "utf8");
|
|
const app = jobBlocks(source).get("app-tests").join("\n");
|
|
assert.match(app, /npm run build:app-deps/);
|
|
assert.match(app, /npm run test --workspace=@getpaseo\/app/);
|
|
assert.doesNotMatch(source, /test:android|expo prebuild|gradlew|actions\/setup-java/);
|
|
});
|
|
|
|
test("server builds exclude test utilities at every domain depth", () => {
|
|
const tsconfig = JSON.parse(readFileSync(serverTsconfigPath, "utf8"));
|
|
assert.ok(tsconfig.exclude.includes("src/server/**/test-utils/**"));
|
|
assert.ok(!tsconfig.exclude.includes("src/server/test-utils/**"));
|
|
});
|
|
|
|
test("PR routing declares stable behavior ownership", () => {
|
|
const filters = loadFilters(filtersPath);
|
|
assert.deepEqual(filters, {
|
|
routing: [".github/ci-paths.yml"],
|
|
workspace: [
|
|
".mise.toml",
|
|
".tool-versions",
|
|
"package.json",
|
|
"package-lock.json",
|
|
"patches/**",
|
|
"scripts/**",
|
|
"tsconfig.json",
|
|
"tsconfig.base.json",
|
|
"vitest.config.ts",
|
|
],
|
|
ci: [".github/actions/**", ".github/workflows/ci.yml"],
|
|
format: [
|
|
".agents/**/*.{cjs,css,html,js,json,jsonc,jsx,md,mjs,ts,tsx,yaml,yml}",
|
|
".github/**/*.{cjs,css,html,js,json,jsonc,jsx,md,mjs,ts,tsx,yaml,yml}",
|
|
"**/*.{cjs,css,html,js,json,jsonc,jsx,md,mjs,ts,tsx,yaml,yml}",
|
|
"packages/expo-two-way-audio/**",
|
|
],
|
|
quality: ["**/*.{cjs,js,json,jsx,mjs,ts,tsx}", "packages/expo-two-way-audio/**"],
|
|
hub: ["packages/cli/src/commands/hub/**", "packages/server/src/server/hub/**"],
|
|
server: ["plugins/**", "packages/server/**", "packages/app/e2e/support/fixtures/recording.*"],
|
|
desktop: [
|
|
"packages/desktop/**",
|
|
"packages/app/src/desktop/**",
|
|
"packages/app/src/**/*.electron.{ts,tsx}",
|
|
"packages/server/src/server/browser-tools/**",
|
|
"packages/app/e2e/support/**",
|
|
"packages/app/*config.{cjs,js,ts}",
|
|
"packages/app/package.json",
|
|
],
|
|
app: [
|
|
"packages/app/**",
|
|
"packages/expo-two-way-audio/**",
|
|
"packages/react-native-enriched-markdown/**",
|
|
],
|
|
sdk: [
|
|
"packages/plugin/**",
|
|
"plugin-examples/**",
|
|
"public-docs/plugins/**",
|
|
"packages/client/**",
|
|
"packages/highlight/**",
|
|
"packages/protocol/**",
|
|
],
|
|
browser: [
|
|
"packages/server/src/server/agent/provider-snapshot-manager.ts",
|
|
"packages/server/src/server/session/provider/provider-catalog-session.ts",
|
|
"packages/client/src/compat/normalize-provider-models.ts",
|
|
"packages/protocol/src/client-capabilities.ts",
|
|
"packages/server/src/server/agent/provider-registry.ts",
|
|
"packages/server/src/server/agent/agent-sdk-types.ts",
|
|
"packages/server/src/server/agent/providers/codex-app-server-agent.ts",
|
|
"packages/server/src/server/agent/providers/claude/agent.ts",
|
|
"packages/server/src/server/agent/plugin-provider.ts",
|
|
"packages/server/src/server/plugins/{index,plugin-process,plugin-process-protocol,runtime}.ts",
|
|
"packages/server/src/executable-resolution/**",
|
|
"packages/plugin/src/server/provider.ts",
|
|
"packages/app/src/!(desktop)/**",
|
|
"packages/app/e2e/browser/**",
|
|
"packages/app/e2e/support/**",
|
|
"packages/app/assets/**",
|
|
"packages/app/public/**",
|
|
"packages/app/index.ts",
|
|
"packages/app/*config.{cjs,js,ts}",
|
|
"packages/app/package.json",
|
|
"packages/react-native-enriched-markdown/**",
|
|
],
|
|
relay: ["packages/relay/**"],
|
|
cli: ["packages/cli/**"],
|
|
});
|
|
});
|
|
|
|
test("cross-package invariants live in the suite that owns them", () => {
|
|
const cliTests = filesUnder("packages/cli", (path) => path.endsWith(".test.ts"));
|
|
assert.ok(cliTests.length > 0);
|
|
for (const path of cliTests) {
|
|
assert.doesNotMatch(
|
|
readFileSync(new URL(path, repoRoot), "utf8"),
|
|
/server\/src\/server\/test-utils/,
|
|
path,
|
|
);
|
|
}
|
|
|
|
const protocolWireCompatibility = new URL(
|
|
"packages/protocol/src/messages.wire-compat.test.ts",
|
|
repoRoot,
|
|
);
|
|
assert.match(readFileSync(protocolWireCompatibility, "utf8"), /wire schema compatibility/);
|
|
});
|
|
|
|
test("browser and desktop tests have exclusive, directory-owned suites", () => {
|
|
const filters = loadFilters(filtersPath);
|
|
const browserSpecs = filesUnder("packages/app/e2e", (path) => path.endsWith(".spec.ts"));
|
|
const desktopSpecs = filesUnder("packages/desktop/e2e", (path) => path.endsWith(".spec.ts"));
|
|
|
|
assert.ok(browserSpecs.length > 0);
|
|
assert.ok(desktopSpecs.length > 0);
|
|
assert.ok(browserSpecs.every((path) => path.startsWith("packages/app/e2e/browser/")));
|
|
assert.ok(desktopSpecs.every((path) => path.startsWith("packages/desktop/e2e/")));
|
|
|
|
const desktopPackage = JSON.parse(readFileSync(desktopPackagePath, "utf8"));
|
|
assert.match(desktopPackage.scripts.test, /--exclude ["']e2e\/\*\*["']/);
|
|
|
|
for (const path of browserSpecs) {
|
|
assert.doesNotMatch(
|
|
readFileSync(new URL(path, repoRoot), "utf8"),
|
|
/paseoDesktop|injectDesktopBridge/,
|
|
);
|
|
}
|
|
for (const path of desktopSpecs) {
|
|
assert.ok(path.startsWith("packages/desktop/e2e/"));
|
|
}
|
|
|
|
const routingSource = readFileSync(filtersPath, "utf8");
|
|
assert.doesNotMatch(routingSource, /desktop_bridge|playwright_desktop|browser-\*|browser-\*\//);
|
|
assert.deepEqual(filters.desktop, [
|
|
"packages/desktop/**",
|
|
"packages/app/src/desktop/**",
|
|
"packages/app/src/**/*.electron.{ts,tsx}",
|
|
"packages/server/src/server/browser-tools/**",
|
|
"packages/app/e2e/support/**",
|
|
"packages/app/*config.{cjs,js,ts}",
|
|
"packages/app/package.json",
|
|
]);
|
|
assert.deepEqual(filters.browser, [
|
|
"packages/server/src/server/agent/provider-snapshot-manager.ts",
|
|
"packages/server/src/server/session/provider/provider-catalog-session.ts",
|
|
"packages/client/src/compat/normalize-provider-models.ts",
|
|
"packages/protocol/src/client-capabilities.ts",
|
|
"packages/server/src/server/agent/provider-registry.ts",
|
|
"packages/server/src/server/agent/agent-sdk-types.ts",
|
|
"packages/server/src/server/agent/providers/codex-app-server-agent.ts",
|
|
"packages/server/src/server/agent/providers/claude/agent.ts",
|
|
"packages/server/src/server/agent/plugin-provider.ts",
|
|
"packages/server/src/server/plugins/{index,plugin-process,plugin-process-protocol,runtime}.ts",
|
|
"packages/server/src/executable-resolution/**",
|
|
"packages/plugin/src/server/provider.ts",
|
|
"packages/app/src/!(desktop)/**",
|
|
"packages/app/e2e/browser/**",
|
|
"packages/app/e2e/support/**",
|
|
"packages/app/assets/**",
|
|
"packages/app/public/**",
|
|
"packages/app/index.ts",
|
|
"packages/app/*config.{cjs,js,ts}",
|
|
"packages/app/package.json",
|
|
"packages/react-native-enriched-markdown/**",
|
|
]);
|
|
});
|
|
|
|
test("packaging runs on main without allocating pull-request runners", () => {
|
|
for (const workflowPath of [dockerWorkflowPath, nixWorkflowPath]) {
|
|
const source = readFileSync(workflowPath, "utf8");
|
|
const trigger = source.split("jobs:", 1)[0];
|
|
assert.match(trigger, /push:\s*\n\s+branches: \[main\]/);
|
|
assert.doesNotMatch(trigger, /pull_request/);
|
|
assert.doesNotMatch(source, /dorny\/paths-filter/);
|
|
}
|
|
const docker = readFileSync(dockerWorkflowPath, "utf8");
|
|
assert.match(
|
|
docker,
|
|
/group: docker-\$\{\{ github\.workflow \}\}-\$\{\{ github\.event_name == 'workflow_dispatch' && inputs\.publish == 'true' && format\('publish-\{0\}', inputs\.paseo_version \|\| github\.run_id\) \|\| github\.ref \}\}/,
|
|
"manual Docker release retries use their own concurrency group so main pushes never cancel them",
|
|
);
|
|
assert.match(
|
|
docker,
|
|
/cancel-in-progress: \$\{\{ !startsWith\(github\.ref, 'refs\/tags\/'\) && !\(github\.event_name == 'workflow_dispatch' && inputs\.publish == 'true'\) \}\}/,
|
|
"Docker cancels superseded non-tag main checks while preserving tag and manual publish runs",
|
|
);
|
|
const nix = readFileSync(nixWorkflowPath, "utf8");
|
|
assert.match(nix.split("jobs:", 1)[0], /^\s+workflow_dispatch:/m);
|
|
});
|
|
|
|
test("CI and desktop packaging verify release branches isolated from main traffic", () => {
|
|
const ciTrigger = readFileSync(ciWorkflowPath, "utf8").split("jobs:", 1)[0];
|
|
assert.match(ciTrigger, /push:\s*\n\s+branches: \[main, "release\/\*\*"\]/);
|
|
|
|
const source = readFileSync(new URL(".github/workflows/desktop-packages.yml", repoRoot), "utf8");
|
|
const trigger = source.split("jobs:", 1)[0];
|
|
assert.match(trigger, /push:\s*\n\s+branches: \[main, "release\/\*\*"\]/);
|
|
assert.match(trigger, /^\s+workflow_dispatch:/m);
|
|
assert.match(trigger, /pull_request:\s*\n\s+paths:/);
|
|
assert.match(trigger, /- "packages\/desktop\/\*\*"/);
|
|
assert.match(trigger, /^\s+cancel-in-progress: true$/m);
|
|
assert.doesNotMatch(source, /dorny\/paths-filter/);
|
|
for (const action of ["actions/checkout", "actions/setup-node", "actions/upload-artifact"]) {
|
|
assert.match(source, new RegExp(`${action}@[0-9a-f]{40} # v\\d+\\.\\d+\\.\\d+`));
|
|
}
|
|
});
|
|
|
|
test("stable iOS releases upload once and distribute to external testers before App Store review", () => {
|
|
const source = readFileSync(
|
|
new URL("packages/app/.eas/workflows/release-mobile.yml", repoRoot),
|
|
"utf8",
|
|
);
|
|
const jobs = jobBlocks(source);
|
|
const uploads = [...jobs.entries()].filter(
|
|
([, lines]) =>
|
|
lines.some((line) => /^ type: (submit|testflight)$/.test(line)) &&
|
|
lines.some((line) => line.includes("needs.build_ios.outputs.build_id")),
|
|
);
|
|
assert.equal(uploads.length, 1, "the iOS binary must be uploaded exactly once");
|
|
const [distributionId, distributionLines] = uploads[0];
|
|
const distribution = distributionLines.join("\n");
|
|
assert.match(distribution, /^ type: testflight$/m);
|
|
assert.match(distribution, /external_groups:\s*\n\s+- Paseo Beta/);
|
|
assert.match(distribution, /^ submit_beta_review: true$/m);
|
|
|
|
const review = jobs.get("submit_ios_for_review").join("\n");
|
|
assert.match(review, new RegExp(`needs: \\[build_ios, ${distributionId}\\]`));
|
|
assert.match(review, /APP_VERSION="\$\{\{ needs\.build_ios\.outputs\.app_version \}\}"/);
|
|
assert.match(
|
|
review,
|
|
/APP_BUILD_VERSION="\$\{\{ needs\.build_ios\.outputs\.app_build_version \}\}"/,
|
|
);
|
|
assert.match(review, /bundle exec fastlane ios submit_review/);
|
|
});
|
|
|
|
test("eight Playwright shards share two-worker coverage", () => {
|
|
const source = readFileSync(ciWorkflowPath, "utf8");
|
|
const jobs = jobBlocks(source);
|
|
assert.equal(jobs.size, 21);
|
|
for (let shard = 1; shard <= 8; shard++) {
|
|
const job = jobs.get(`playwright-${shard}`).join("\n");
|
|
assert.match(job, new RegExp(`PLAYWRIGHT_SHARD: "${shard}/8"`));
|
|
assert.match(job, new RegExp(`PLAYWRIGHT_ARTIFACT: "${shard}"`));
|
|
assert.match(
|
|
job,
|
|
shard === 1 ? /steps: &playwright_test_steps/ : /steps: \*playwright_test_steps/,
|
|
);
|
|
}
|
|
const shared = jobs.get("playwright-1").join("\n");
|
|
assert.match(shared, /E2E_WORKERS: "2"/);
|
|
const weights = /PWTEST_SHARD_WEIGHTS: "([\d:]+)"/.exec(shared)[1].split(":").map(Number);
|
|
assert.equal(weights.length, 8);
|
|
assert.ok(weights.every((weight) => weight > 0));
|
|
assert.match(shared, /npm run test:e2e --workspace=@getpaseo\/app -- --shard=/);
|
|
|
|
// No fan-in result job: a gate needs its own runner and under contention it
|
|
// queued 8m08s behind the last shard. Required checks name the shards directly.
|
|
assert.equal(jobs.has("playwright"), false);
|
|
});
|
|
|
|
test("quality preserves commands and routes each domain independently after failures", () => {
|
|
const jobs = jobBlocks(readFileSync(ciWorkflowPath, "utf8"));
|
|
const quality = jobs.get("quality").join("\n");
|
|
assert.doesNotMatch(quality, /^\s+continue-on-error:/m);
|
|
const commands = {
|
|
format: ["npm run format:check"],
|
|
quality: [
|
|
"npx --yes lockfile-lint --path package-lock.json --type npm --allowed-hosts npm --validate-https --validate-integrity",
|
|
"npm audit signatures",
|
|
"npm run lint",
|
|
"node --test scripts/oxlint/paseo-plugin.test.mjs",
|
|
],
|
|
relay: ["npm run build:relay", "npm run test --workspace=@getpaseo/relay"],
|
|
sdk: [
|
|
"npm run build:relay && npm run build:client",
|
|
"npm run build:plugin",
|
|
"npm run test --workspace=@getpaseo/plugin",
|
|
"npm run test --workspace=@getpaseo/protocol",
|
|
"npm run test --workspace=@getpaseo/client",
|
|
"npm run test --workspace=@getpaseo/highlight",
|
|
"npm run typecheck:examples --workspace=@getpaseo/client",
|
|
],
|
|
};
|
|
const checks = [...quality.matchAll(/ if: \$\{\{ (.+) \}\}\n run: (.+)/g)];
|
|
assert.deepEqual(
|
|
checks.map(([, , command]) => command),
|
|
Object.values(commands).flat(),
|
|
);
|
|
const domains = Object.keys(commands);
|
|
function accepts(expression, outputs, { cancelled = false, installed = true } = {}) {
|
|
// Prior checks have failed: success() is false. Explicit !cancelled() must
|
|
// override Actions' default success condition so later domains still run.
|
|
assert.match(expression, /!cancelled\(\)/);
|
|
return runInNewContext(expression, {
|
|
needs: { changes: { outputs } },
|
|
steps: { install: { outcome: installed ? "success" : "failure" } },
|
|
cancelled: () => cancelled,
|
|
success: () => false,
|
|
});
|
|
}
|
|
const disabled = { full: "false", ...Object.fromEntries(domains.map((key) => [key, "false"])) };
|
|
const jobCondition = / if: \$\{\{ (.+) \}\}/.exec(quality)[1];
|
|
assert.equal(accepts(jobCondition, disabled), false);
|
|
for (const selected of domains) {
|
|
const outputs = { ...disabled, [selected]: "true" };
|
|
assert.equal(accepts(jobCondition, outputs), true);
|
|
for (const [, expression, command] of checks) {
|
|
assert.equal(accepts(expression, outputs), commands[selected].includes(command), command);
|
|
}
|
|
}
|
|
for (const [, expression] of checks) {
|
|
assert.equal(accepts(expression, { ...disabled, full: "true" }), true);
|
|
assert.equal(accepts(expression, {}), true, "missing routing outputs fail open");
|
|
assert.equal(accepts(expression, {}, { cancelled: true }), false);
|
|
assert.equal(accepts(expression, {}, { installed: false }), false);
|
|
}
|
|
assert.equal(accepts(jobCondition, {}, { cancelled: true }), false);
|
|
});
|
|
|
|
test("Windows units and integration run independently with complete routed coverage", () => {
|
|
const source = readFileSync(ciWorkflowPath, "utf8");
|
|
const jobs = jobBlocks(source);
|
|
const ubuntu = jobs.get("server-tests-ubuntu").join("\n");
|
|
const windows = jobs.get("server-tests-windows").join("\n");
|
|
const integration = jobs.get("server-integration-windows").join("\n");
|
|
assert.match(ubuntu, /run: npm run test --workspace=@getpaseo\/server/);
|
|
assert.match(windows, /run: npm run test:unit --workspace=@getpaseo\/server/);
|
|
assert.doesNotMatch(windows, /run: npm run test(?: |:integration)/);
|
|
assert.match(integration, /run: npm run test:integration --workspace=@getpaseo\/server/);
|
|
assert.doesNotMatch(integration, /test:unit|server_plugin_tests|server_hub_contract/);
|
|
for (const job of [windows, integration]) {
|
|
assert.match(job, /^ needs: changes$/m, "both phases become eligible independently");
|
|
assert.match(job, /^ runs-on: windows-latest$/m);
|
|
assert.doesNotMatch(job, /continue-on-error|maxWorkers|--exclude/);
|
|
for (const step of [
|
|
"server_capacity",
|
|
"server_checkout",
|
|
"server_node",
|
|
"server_fetch",
|
|
"server_install",
|
|
"server_agent_clis",
|
|
"server_build",
|
|
]) {
|
|
assert.match(ubuntu, new RegExp(`&${step}\\b`));
|
|
assert.match(job, new RegExp(`- \\*${step}\\b`));
|
|
}
|
|
assert.match(job, /env: \*server_test_env/);
|
|
}
|
|
assert.match(windows, /- \*server_plugin_tests/);
|
|
assert.match(windows, /- \*server_hub_contract/);
|
|
assert.match(ubuntu, /run: npm run test --workspace=@getpaseo\/builtin-plugins/);
|
|
assert.match(ubuntu, /run: npm run test:hub-cli-contract --workspace=@getpaseo\/server/);
|
|
|
|
const scripts = JSON.parse(
|
|
readFileSync(new URL("packages/server/package.json", repoRoot), "utf8"),
|
|
).scripts;
|
|
assert.equal(scripts.test, "npm run test:unit && npm run test:integration");
|
|
assert.equal(scripts["test:unit"], 'vitest run --fileParallelism --exclude "**/*.e2e.test.ts"');
|
|
const invocations = scripts["test:integration"].split(" && ");
|
|
// 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 --fileParallelism --maxWorkers=3 "),
|
|
),
|
|
);
|
|
assert.doesNotMatch(invocations[0], / -t /);
|
|
assert.equal(
|
|
invocations[1],
|
|
'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 src/server/agent/agent-mcp.e2e.test.ts -t "agent MCP protocol negotiation|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:\s*1\b/);
|
|
|
|
function condition(job) {
|
|
return / if: \$\{\{ (.+) \}\}/.exec(job)[1];
|
|
}
|
|
function selected(expression, outputs, cancelled = false) {
|
|
return runInNewContext(expression, {
|
|
needs: { changes: { outputs } },
|
|
cancelled: () => cancelled,
|
|
});
|
|
}
|
|
const unitCondition = condition(windows);
|
|
const integrationCondition = condition(integration);
|
|
const unitStep = / - name: Run server unit tests\n if: \$\{\{ (.+) \}\}/.exec(
|
|
windows,
|
|
)[1];
|
|
const hubStep =
|
|
/ - &server_hub_contract\n name: Run Hub CLI\/daemon contract\n if: \$\{\{ (.+) \}\}/.exec(
|
|
ubuntu,
|
|
)[1];
|
|
const pluginStep =
|
|
/ - &server_plugin_tests\n name: Run built-in plugin tests\n if: \$\{\{ (.+) \}\}/.exec(
|
|
ubuntu,
|
|
)[1];
|
|
for (const [outputs, units, integrations, hub] of [
|
|
[{ full: "true", server: "false", hub: "false" }, true, true, false],
|
|
[{ full: "false", server: "true", hub: "false" }, true, true, false],
|
|
[{ full: "false", server: "false", hub: "true" }, true, false, true],
|
|
[{ full: "false", server: "false", hub: "false" }, false, false, false],
|
|
[{}, true, true, false],
|
|
]) {
|
|
assert.equal(selected(unitCondition, outputs), units);
|
|
assert.equal(selected(integrationCondition, outputs), integrations);
|
|
assert.equal(selected(unitStep, outputs), integrations);
|
|
assert.equal(selected(pluginStep, outputs), integrations);
|
|
assert.equal(selected(hubStep, outputs), hub);
|
|
assert.equal(selected(unitCondition, outputs, true), false);
|
|
assert.equal(selected(integrationCondition, outputs, true), false);
|
|
}
|
|
});
|
|
|
|
test("desktop release creates release-manifests before entering it and uses the xcrun retry script", () => {
|
|
const workflow = readFileSync(new URL(".github/workflows/desktop-release.yml", repoRoot), "utf8");
|
|
assert.match(workflow, /scripts\/macos-xcrun-retry\.sh/);
|
|
assert.match(workflow, /mkdir -p release-manifests\s*\n\s+cd release-manifests/);
|
|
});
|
|
|
|
test("macOS release xcrun wrapper retries transient stapling and notarization failures without rebuilding", async (t) => {
|
|
const wrapperSource = readFileSync(new URL("scripts/macos-xcrun-retry.sh", repoRoot), "utf8");
|
|
const networkLostError =
|
|
'Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."';
|
|
const notaryTimeoutWithId =
|
|
'Error: HTTPError(statusCode: nil, error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=https://appstoreconnect.apple.com/notary/v2/submissions/ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba?})';
|
|
const notaryOfflineWithId =
|
|
'Error: HTTPError(statusCode: nil, error: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=https://appstoreconnect.apple.com/notary/v2/submissions/ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba?})';
|
|
const notaryUploadTimeout =
|
|
'Error: HTTPError(statusCode: nil, error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out.")';
|
|
const acceptedJson = JSON.stringify({
|
|
id: "ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba",
|
|
message: "Successfully received submission info",
|
|
status: "Accepted",
|
|
});
|
|
const invalidJson = JSON.stringify({
|
|
id: "ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba",
|
|
message: "Submission invalid",
|
|
status: "Invalid",
|
|
});
|
|
|
|
const cases = [
|
|
{
|
|
name: "stapler success",
|
|
steps: [{ code: 0, output: "stapled" }],
|
|
args: ["stapler", "staple", "-v", "Paseo signed.app"],
|
|
expected: 0,
|
|
expectedCalls: [["stapler", "staple", "-v", "Paseo signed.app"]],
|
|
expectPattern: /stapled/,
|
|
},
|
|
{
|
|
name: "stapler transient then success",
|
|
steps: [
|
|
{ code: 68, output: networkLostError },
|
|
{ code: 0, output: "stapled" },
|
|
],
|
|
args: ["stapler", "staple", "-v", "Paseo signed.app"],
|
|
expected: 0,
|
|
expectedCalls: [
|
|
["stapler", "staple", "-v", "Paseo signed.app"],
|
|
["stapler", "staple", "-v", "Paseo signed.app"],
|
|
],
|
|
expectPattern: /stapled/,
|
|
},
|
|
{
|
|
name: "stapler exhausted network retries",
|
|
steps: [
|
|
{ code: 68, output: networkLostError },
|
|
{ code: 68, output: networkLostError },
|
|
{ code: 68, output: networkLostError },
|
|
{ code: 68, output: networkLostError },
|
|
],
|
|
args: ["stapler", "staple", "-v", "Paseo signed.app"],
|
|
expected: 68,
|
|
expectedCalls: Array.from({ length: 4 }, () => [
|
|
"stapler",
|
|
"staple",
|
|
"-v",
|
|
"Paseo signed.app",
|
|
]),
|
|
expectPattern: /network connection was lost/,
|
|
},
|
|
{
|
|
name: "stapler non-network error is not retried",
|
|
steps: [{ code: 68, output: "ticket not found" }],
|
|
args: ["stapler", "staple", "-v", "Paseo signed.app"],
|
|
expected: 68,
|
|
expectedCalls: [["stapler", "staple", "-v", "Paseo signed.app"]],
|
|
expectPattern: /ticket not found/,
|
|
},
|
|
{
|
|
name: "notarytool switches to wait when polling fails after upload and emits clean JSON",
|
|
steps: [
|
|
{ code: 1, output: notaryTimeoutWithId },
|
|
{ code: 1, output: notaryOfflineWithId },
|
|
{ code: 0, output: acceptedJson },
|
|
],
|
|
args: [
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--password",
|
|
"pw",
|
|
"--team-id",
|
|
"team",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
expected: 0,
|
|
expectedCalls: [
|
|
[
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--password",
|
|
"pw",
|
|
"--team-id",
|
|
"team",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
[
|
|
"notarytool",
|
|
"wait",
|
|
"ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba",
|
|
"--apple-id",
|
|
"id",
|
|
"--password",
|
|
"pw",
|
|
"--team-id",
|
|
"team",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
[
|
|
"notarytool",
|
|
"wait",
|
|
"ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba",
|
|
"--apple-id",
|
|
"id",
|
|
"--password",
|
|
"pw",
|
|
"--team-id",
|
|
"team",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
],
|
|
expectCleanJson: true,
|
|
},
|
|
{
|
|
name: "notarytool retries submit when upload fails before submission ID exists",
|
|
steps: [
|
|
{ code: 1, output: notaryUploadTimeout },
|
|
{ code: 0, output: acceptedJson },
|
|
],
|
|
args: [
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
expected: 0,
|
|
expectedCalls: [
|
|
[
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
[
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
],
|
|
expectCleanJson: true,
|
|
},
|
|
{
|
|
name: "notarytool deterministic Invalid rejection is never retried",
|
|
steps: [{ code: 0, output: invalidJson }],
|
|
args: [
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
expected: 0,
|
|
expectedCalls: [
|
|
[
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
],
|
|
expectCleanJson: true,
|
|
},
|
|
{
|
|
name: "notarytool bad credentials error is never retried",
|
|
steps: [{ code: 1, output: "Error: HTTP status code: 401. Invalid credentials." }],
|
|
args: [
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
expected: 1,
|
|
expectedCalls: [
|
|
[
|
|
"notarytool",
|
|
"submit",
|
|
"/tmp/Paseo.zip",
|
|
"--apple-id",
|
|
"id",
|
|
"--wait",
|
|
"--output-format",
|
|
"json",
|
|
],
|
|
],
|
|
expectPattern: /Invalid credentials/,
|
|
},
|
|
];
|
|
for (const scenario of cases) {
|
|
await t.test(scenario.name, () => {
|
|
const directory = mkdtempSync(join(tmpdir(), "xcrun-retry-"));
|
|
try {
|
|
const statePath = join(directory, "state.json");
|
|
const realXcrun = join(directory, "real-xcrun");
|
|
const wrapperPath = join(directory, "xcrun");
|
|
writeFileSync(wrapperPath, wrapperSource, { mode: 0o755 });
|
|
writeFileSync(join(directory, "sleep"), "#!/bin/sh\nexit 0\n", { mode: 0o755 });
|
|
writeFileSync(statePath, JSON.stringify({ steps: scenario.steps, calls: [] }));
|
|
writeFileSync(
|
|
realXcrun,
|
|
`#!/usr/bin/env node
|
|
const fs = require("node:fs");
|
|
const state = JSON.parse(fs.readFileSync(process.env.XCRUN_STATE, "utf8"));
|
|
state.calls.push(process.argv.slice(2));
|
|
const next = state.steps.shift();
|
|
fs.writeFileSync(process.env.XCRUN_STATE, JSON.stringify(state));
|
|
if (!next) process.exit(99);
|
|
process.stdout.write(next.output + "\\n");
|
|
process.exit(next.code);
|
|
`,
|
|
{ mode: 0o755 },
|
|
);
|
|
const result = spawnSync("bash", [wrapperPath, ...scenario.args], {
|
|
encoding: "utf8",
|
|
env: {
|
|
...process.env,
|
|
PASEO_REAL_XCRUN: realXcrun,
|
|
XCRUN_STATE: statePath,
|
|
PATH: `${directory}:${process.env.PATH}`,
|
|
},
|
|
timeout: 5000,
|
|
});
|
|
assert.equal(result.status, scenario.expected, result.stdout + result.stderr);
|
|
const state = JSON.parse(readFileSync(statePath, "utf8"));
|
|
assert.deepEqual(state.calls, scenario.expectedCalls);
|
|
if (scenario.expectCleanJson) {
|
|
// @electron/notarize merges stdout and stderr before calling JSON.parse.
|
|
const parsed = JSON.parse((result.stdout + result.stderr).trim());
|
|
assert.equal(parsed.id, "ee2872f3-65d9-49f7-b2b5-adcdfe2db6ba");
|
|
}
|
|
if (scenario.expectPattern) {
|
|
assert.match(result.stdout + result.stderr, scenario.expectPattern);
|
|
}
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true });
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// GitHub retires macOS 14 on 2026-11-02; brownouts already reject these jobs.
|
|
test("workflows avoid retired macOS 14 runners", () => {
|
|
for (const path of filesUnder(".github/workflows", (candidate) => /\.ya?ml$/.test(candidate))) {
|
|
assert.doesNotMatch(
|
|
readFileSync(new URL(path, repoRoot), "utf8"),
|
|
/macos-14(?:-large|-xlarge)?\b/,
|
|
path,
|
|
);
|
|
}
|
|
});
|
|
|
|
test("macOS jobs use latest runners while preserving release architectures", () => {
|
|
for (const [workflow, jobId] of [
|
|
[ciWorkflowPath, "server-tests-macos"],
|
|
[nixWorkflowPath, "build-desktop-darwin"],
|
|
]) {
|
|
assert.match(
|
|
jobBlocks(readFileSync(workflow, "utf8")).get(jobId).join("\n"),
|
|
/^ runs-on: macos-latest$/m,
|
|
);
|
|
}
|
|
const release = readFileSync(new URL(".github/workflows/desktop-release.yml", repoRoot), "utf8");
|
|
assert.match(release, /runner: macos-latest\n\s+electron_arch: arm64/);
|
|
// GitHub has no standard macos-latest-intel alias; use the newest Intel image.
|
|
assert.match(release, /runner: macos-26-intel\n\s+electron_arch: x64/);
|
|
});
|
|
|
|
test("Nix desktop packaging resolves the workspace-local builder", () => {
|
|
const source = readFileSync(new URL("nix/desktop-package.nix", repoRoot), "utf8");
|
|
const invocation = source.match(/^\s+([^\n]*electron-builder) \\\n/m)?.[1];
|
|
assert.ok(invocation, "Nix invokes the desktop packaging tool");
|
|
const directory = mkdtempSync(join(tmpdir(), "nix-builder-resolution-"));
|
|
try {
|
|
const desktop = join(directory, "packages/desktop");
|
|
mkdirSync(join(desktop, "node_modules/.bin"), { recursive: true });
|
|
mkdirSync(join(desktop, "node_modules/electron-builder"));
|
|
writeFileSync(
|
|
join(desktop, "node_modules/electron-builder/package.json"),
|
|
JSON.stringify({
|
|
name: "electron-builder",
|
|
version: "1.0.0",
|
|
bin: { "electron-builder": "../.bin/electron-builder" },
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(directory, "package.json"),
|
|
JSON.stringify({ private: true, workspaces: ["packages/desktop"] }),
|
|
);
|
|
writeFileSync(
|
|
join(desktop, "package.json"),
|
|
JSON.stringify({
|
|
name: "desktop-fixture",
|
|
private: true,
|
|
devDependencies: { "electron-builder": "1.0.0" },
|
|
}),
|
|
);
|
|
writeFileSync(
|
|
join(desktop, "node_modules/.bin/electron-builder"),
|
|
'#!/bin/sh\nprintf "workspace-builder\\n"\n',
|
|
{ mode: 0o755 },
|
|
);
|
|
const result = spawnSync("sh", ["-c", `${invocation} --version`], {
|
|
cwd: desktop,
|
|
encoding: "utf8",
|
|
});
|
|
assert.equal(result.status, 0, result.stderr);
|
|
assert.equal(result.stdout.trim(), "workspace-builder");
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true });
|
|
}
|
|
});
|