pi-ext
bugabingas pi extensions
owned by bugabinga
release: fix browser gates for v0.1.4
991349b8242e09fedf0f1d0d0e70d93ab06a2415
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (12)
9 9 mount "cache" "toolchains" "/cache/toolchains" 10 10 mount "cache" "npm" "/cache/npm" 11 - run "export HOME=/tmp/pi-ext-home MISE_DATA_DIR=/cache/toolchains/mise MISE_CACHE_DIR=/cache/toolchains/downloads GOCACHE=/cache/toolchains/go-build GOPATH=/cache/toolchains/go NPM_CONFIG_CACHE=/cache/npm && mkdir -p \"$HOME\" /cache/toolchains/bin" 11 + run "export HOME=/tmp/pi-ext-home MISE_DATA_DIR=/cache/toolchains/mise MISE_CACHE_DIR=/cache/toolchains/downloads GOCACHE=/cache/toolchains/go-build GOPATH=/cache/toolchains/go NPM_CONFIG_CACHE=/cache/npm PI_EXT_CI_CACHE_ROOT=/cache/toolchains && mkdir -p \"$HOME\" /cache/toolchains/bin" 12 12 run "export PATH=\"/cache/toolchains/bin:$HOME/.local/bin:$PATH\"" 13 13 run "command -v mise >/dev/null 2>&1 || { curl -fsSL https://mise.run | sh && cp \"$HOME/.local/bin/mise\" /cache/toolchains/bin/mise; }" 17 - run "CI=true MOZ_DISABLE_CONTENT_SANDBOX=1 mise run //:ci" 17 + run "CI=true MOZ_DISABLE_CONTENT_SANDBOX=1 xvfb-run -a mise run //:ci" 18 18 artifact "release" {
19 19 path ".pi/tmp/release-artifacts/manifest.json" 8 +- Refresh the System board's static output before acknowledging plan status changes
9 +- Run headed Chrome acceptance tests under Xvfb in CI, with sandbox isolation confined to the test executable wrapper
10 +- Reuse explicitly configured CI browser and download caches while keeping E2E HOME, agent data, and trust state isolated
8 14 - Persist Mise toolchains, downloads, Go build caches, and npm downloads across failed CI runs using durable cache mounts
extensions/chrome-cdp/__e2e__/browser.test.ts
Modified 6 6 import { createServer }
from "node:http";
7 7 import { tmpdir }
from "node:os";
8 8 import { join }
from "node:path";
9 -import { chromium }
from "@playwright/test";
10 9 import { test }
from "vitest";
11 10 import { Browser, executeOperations }
from "../browser.ts";
12 11 import { binaryKey, dataRoot }
from "../lib.ts";
12 +import { testChromiumExecutable }
from "./chromium.ts";
15 15 '<!doctype html><title>Chrome CDP fixture</title><main><h1>Ready</h1><button id="go">Go</button></main><script>console.error("fixture-error");document.querySelector("button").onclick=()=>{document.querySelector("h1").textContent="Done"};</script>';
55 55 res.
setHeader(
"Content-Type",
"text/html");
58 - const chromeExecutable
= chromium.
executablePath();
59 - const profile
= join(
dataRoot(),
binaryKey(chromeExecutable),
"pi-cdp-test");
60 58 const root
= await mkdtemp(
join(
tmpdir(),
"pi-chrome-cdp-"));
59 + const chromeExecutable
= await testChromiumExecutable(
root);
60 + const profile
= join(
dataRoot(),
binaryKey(chromeExecutable),
"pi-cdp-test");
61 61 let b
: Browser | undefined;
62 62 let ownsProfile
= false;
extensions/chrome-cdp/__e2e__/chromium.ts
Addednew file mode 100644 1 +import { writeFile }
from "node:fs/promises";
2 +import { join }
from "node:path";
3 +import { chromium }
from "@playwright/test";
6 +export async function testChromiumExecutable(root
: string)
: Promise<
string> {
7 + const executable
= chromium.
executablePath();
8 + if (
process.
env.CI
!== "true")
return executable;
9 + if (
!process.
env.PI_EXT_E2E_ROOT)
10 + throw new Error(
"Chrome CI requires the isolated E2E runner");
11 + const wrapper
= join(
root,
"chromium-ci");
12 + const quoted
= `'${executable.replaceAll("'", "'\\''")}'`;
13 + await writeFile(wrapper,
`#!/bin/sh\nexec ${quoted} --no-sandbox "$@"\n`, {
extensions/chrome-cdp/__e2e__/cleanup.test.ts
Modified 1 1 import assert
from "node:assert/strict";
2 2 import { existsSync }
from "node:fs";
3 3 import { mkdtemp, rm, writeFile }
from "node:fs/promises";
4 +import { tmpdir }
from "node:os";
5 +import { join }
from "node:path";
4 6 import { test }
from "vitest";
5 7 import { Browser }
from "../browser.ts";
6 8 import { TMP_PREFIX }
from "../lib.ts";
9 +import { testChromiumExecutable }
from "./chromium.ts";
8 11 test(
"only tagged dead-owner temporary directories are reclaimed",
async ()
=> {
12 + const fixture
= await mkdtemp(
join(
tmpdir(),
"chrome-cleanup-fixture-"));
9 13 const stale
= await mkdtemp(TMP_PREFIX);
10 14 const unknown
= await mkdtemp(TMP_PREFIX);
20 - const b
= await Browser.
launch({});
24 + const b
= await Browser.
launch({
25 + executablePath:
await testChromiumExecutable(fixture),
22 28 assert.
equal(
existsSync(stale),
false);
23 29 assert.
equal(
existsSync(unknown),
true);
25 31 await rm(stale, { recursive:
true, force:
true });
26 32 await rm(unknown, { recursive:
true, force:
true });
33 + await rm(fixture, { recursive:
true, force:
true });
extensions/chrome-cdp/__e2e__/extension.test.ts
Modified 3 3 import assert
from "node:assert/strict";
4 4 import { mkdir, mkdtemp, rm, writeFile }
from "node:fs/promises";
5 5 import { tmpdir }
from "node:os";
6 6 import { join }
from "node:path";
7 7 import { initTheme }
from "@earendil-works/pi-coding-agent";
8 -import { chromium }
from "@playwright/test";
9 8 import { afterEach, test }
from "vitest";
10 9 import chromeExtension
from "../index.ts";
10 +import { testChromiumExecutable }
from "./chromium.ts";
12 12 const fixtureRoots
: string[]
= [];
13 13 afterEach(
async ()
=> {
28 28 join(fixtureRoot,
".pi",
"settings.json"),
30 - "chrome-cdp": { artifactDir, executablePath: chromium.
executablePath() },
32 + executablePath:
await testChromiumExecutable(fixtureRoot),
33 36 const handlers
: Record<
string,
Function>
= {};
extensions/the-system/__tests__/board-server.test.ts
Modified134 134 assert.
equal(late.items[
"PX-ISSUE-ISSUE002"].state,
"done");
137 - it(
"toggles plan status on disk and rejects other documents",
async ()
=> {
137 + it(
"toggles plan status on disk and refreshes static output",
async ()
=> {
138 138 const root
= fixture();
139 - const client
= await open(
root);
140 + const client
= await open(
root, (index, _board, _proposals, revision)
=> {
142 + const directory
= mkdtempSync(path.
join(
tmpdir(),
"board-site-"));
143 + roots.
push(directory);
144 + const plan
= index.documents.
find(
145 + (document)
=> document.metadata.
id === "PX-PLAN-PLAN0001",
148 + plan?.metadata.
type === "plan" ? plan.metadata.
status : "missing";
150 + path.
join(directory,
"index.html"),
151 + `<body data-revision="${revision}" data-status="${status}">`,
154 + return { directory };
140 156 const planPath
= ".system/plans/PX-PLAN-PLAN0001-build/index.md";
142 158 const result
= await client.
post(
"/api/status", {
146 162 assert.
deepEqual(result, { id:
"PX-PLAN-PLAN0001", status:
"approved" });
147 163 assert.
match(
read(
root, planPath),
/^status: approved$/m);
164 + assert.
equal(renders,
2);
165 + assert.
match(
await client.
text(
"/"),
/data-status="approved"/);
149 167 await client.
post(
"/api/status", {
150 168 id:
"PX-PLAN-PLAN0001",
extensions/the-system/board-server.ts
Modified230 230 if (request.
method === "POST" && url.
pathname === "/api/status") {
231 231 const input
= await readJsonBody(request);
232 - const result
= await state.
enqueue(()
=> applyStatus(state.root, input));
232 + const result
= await state.
enqueue(()
=> {
233 + const updated
= applyStatus(state.root, input);
234 + state.
ensureSite();
233 237 respondJson(response,
200, result);
package-lock.json
Modified 4 4 "lockfileVersion":
3,
22 22 const originalConfig =
23 23 parent.MISE_CONFIG_DIR ??
24 24 join(parent.XDG_CONFIG_HOME ?? join(originalHome, ".config"), "mise");
25 + // Only the CI job's explicit disposable cache mount may outlive a run.
27 + parent.CI === "true" ? parent.PI_EXT_CI_CACHE_ROOT : undefined;
28 + if (cacheRoot && !isAbsolute(cacheRoot))
29 + throw new Error("CI cache root must be absolute");
27 32 HOME: join(root, "home"),
35 40 TMPDIR: join(root, "tmp"),
36 41 TMP: join(root, "tmp"),
37 42 TEMP: join(root, "tmp"),
38 - PLAYWRIGHT_BROWSERS_PATH: join(root, "browsers"),
39 - npm_config_cache: join(root, "npm-cache"),
43 + PLAYWRIGHT_BROWSERS_PATH: cacheRoot
44 + ? join(cacheRoot, "browsers")
45 + : join(root, "browsers"),
46 + npm_config_cache: cacheRoot
47 + ? (parent.NPM_CONFIG_CACHE ?? join(cacheRoot, "npm"))
48 + : join(root, "npm-cache"),
40 49 PI_CODING_AGENT_DIR: join(root, "agent"),
41 50 PI_BAK_E2E_S3: "0",
42 51 PI_EXT_E2E_ROOT: root,
43 52 MISE_CONFIG_DIR: originalConfig,
44 53 MISE_DATA_DIR: originalData,
45 - MISE_CACHE_DIR: join(root, "mise-cache"),
54 + MISE_CACHE_DIR: cacheRoot
55 + ? join(cacheRoot, "downloads")
56 + : join(root, "mise-cache"),
46 57 MISE_STATE_DIR: join(root, "mise-state"),
47 58 MISE_AUTO_INSTALL: "0",
48 59 MISE_TASK_RUN_AUTO_INSTALL: "0",
scripts/e2e.test.ts
Modified38 38 expect(env.MISE_AUTO_INSTALL).
toBe(
"0");
41 +it(
"reuses only explicitly configured CI binary and download caches", ()
=> {
42 + const env
= isolatedEnvironment(
"/tmp/isolated", {
43 + HOME:
"/tmp/ci-home",
45 + PI_EXT_CI_CACHE_ROOT:
"/cache/toolchains",
46 + NPM_CONFIG_CACHE:
"/cache/npm",
48 + expect(env.PLAYWRIGHT_BROWSERS_PATH).
toBe(
"/cache/toolchains/browsers");
49 + expect(env.npm_config_cache).
toBe(
"/cache/npm");
50 + expect(env.MISE_CACHE_DIR).
toBe(
"/cache/toolchains/downloads");
51 + expect(env.MISE_STATE_DIR).
toBe(
"/tmp/isolated/mise-state");
52 + expect(env.HOME).
toBe(
"/tmp/isolated/home");
53 + const local
= isolatedEnvironment(
"/tmp/isolated", {
54 + HOME:
"/home/owner",
55 + PI_EXT_CI_CACHE_ROOT:
"/cache/toolchains",
57 + expect(local.PLAYWRIGHT_BROWSERS_PATH).
toBe(
"/tmp/isolated/browsers");
41 60 it(
"filters only listed local E2E suites", ()
=> {
42 61 const tasks
= [
"//extensions/strata:e2e",
"//extensions/chrome-cdp:e2e"];
43 62 expect(
selectedTasks(tasks,
"strata")).
toEqual([tasks[
0]]);