fix(ci): harden ARM smoke and browser checks

This commit is contained in:
Vincent Koc
2026-06-03 07:30:04 -07:00
parent acacd32415
commit d3ab7e92ef
15 changed files with 473 additions and 54 deletions

View File

@@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import {
resolvePlaywrightChromiumExecutablePath,
systemChromiumExecutableCandidates,
} from "./control-ui-e2e.ts";
describe("resolvePlaywrightChromiumExecutablePath", () => {
it("uses a runnable system Chromium when the cached Playwright executable cannot start", () => {
const systemExecutable = systemChromiumExecutableCandidates[1];
expect(
resolvePlaywrightChromiumExecutablePath(
"/cache/chromium/chrome",
{},
(candidate) => candidate === systemExecutable,
),
).toBe(systemExecutable);
});
it("keeps explicit Chromium overrides authoritative", () => {
expect(
resolvePlaywrightChromiumExecutablePath(
"/cache/chromium/chrome",
{ PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH: " /custom/chromium " },
() => false,
),
).toBe("/custom/chromium");
});
});

View File

@@ -1,3 +1,4 @@
import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
import { createRequire } from "node:module";
import { createServer as createNetServer } from "node:net";
@@ -83,7 +84,7 @@ export type MockGatewayControls = {
};
const chromiumExecutableOverrideEnvKey = "PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH";
const systemChromiumExecutableCandidates = [
export const systemChromiumExecutableCandidates = [
"/snap/bin/chromium",
"/usr/bin/chromium-browser",
"/usr/bin/chromium",
@@ -99,22 +100,26 @@ function resolveRepoRoot(): string {
export function resolvePlaywrightChromiumExecutablePath(
defaultExecutablePath: string,
env: NodeJS.ProcessEnv = process.env,
canRun: (chromiumExecutablePath: string) => boolean = canRunPlaywrightChromium,
): string {
const executableOverride = env[chromiumExecutableOverrideEnvKey]?.trim();
if (executableOverride) {
return executableOverride;
}
if (existsSync(defaultExecutablePath)) {
if (canRun(defaultExecutablePath)) {
return defaultExecutablePath;
}
return (
systemChromiumExecutableCandidates.find((candidate) => existsSync(candidate)) ??
systemChromiumExecutableCandidates.find((candidate) => canRun(candidate)) ??
defaultExecutablePath
);
}
export function canRunPlaywrightChromium(chromiumExecutablePath: string): boolean {
return existsSync(chromiumExecutablePath);
if (!existsSync(chromiumExecutablePath)) {
return false;
}
return spawnSync(chromiumExecutablePath, ["--version"], { stdio: "ignore" }).status === 0;
}
export async function startControlUiE2eServer(): Promise<ControlUiE2eServer> {

View File

@@ -168,7 +168,7 @@ describeControlUiE2e("Control UI mocked Gateway E2E", () => {
beforeAll(async () => {
if (!chromiumAvailable) {
throw new Error(
`Playwright Chromium is not installed at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install chromium\`, set PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH to a compatible browser, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
`Playwright Chromium is not installed or cannot start at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install --with-deps chromium\`, set PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH to a compatible browser, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
);
}
server = await startControlUiE2eServer();

View File

@@ -90,7 +90,7 @@ describeControlUiE2e("Control UI chat picker mocked Gateway E2E", () => {
beforeAll(async () => {
if (!chromiumAvailable) {
throw new Error(
`Playwright Chromium is not installed at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install chromium\`, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
`Playwright Chromium is not installed or cannot start at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install --with-deps chromium\`, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
);
}
server = await startControlUiE2eServer();

View File

@@ -115,7 +115,7 @@ describeControlUiE2e("Control UI cron mocked Gateway E2E", () => {
beforeAll(async () => {
if (!chromiumAvailable) {
throw new Error(
`Playwright Chromium is not installed at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install chromium\`, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
`Playwright Chromium is not installed or cannot start at ${chromiumExecutablePath}. Run \`pnpm --dir ui exec playwright install --with-deps chromium\`, or set OPENCLAW_UI_E2E_ALLOW_MISSING_CHROMIUM=1 only when intentionally skipping this lane.`,
);
}
server = await startControlUiE2eServer();