repositories / pi-ext

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)

.ci/ci.kdl

Modified
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; }"
14 14 run "mise trust"
15 15 run "mise install"
16 16 // Luci's capability-free container replaces Firefox's incompatible content sandbox.
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"
20 20 required true

CHANGELOG.md

Modified
2 2 # Changelog
4 4 ## Unreleased
6 +## 0.1.4
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
6 12 ## 0.1.3
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";
14 14 const html =
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");
56 56 res.end(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;
63 63 try {

extensions/chrome-cdp/__e2e__/chromium.ts

Added
new file mode 100644
1 +import { writeFile } from "node:fs/promises";
2 +import { join } from "node:path";
3 +import { chromium } from "@playwright/test";
5 +/** CI's capability-free container provides isolation; runtime flag policy stays unchanged. */
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`, {
14 + mode: 0o700,
15 + });
16 + return wrapper;

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);
11 15 try {
17 21 browserPid: 0,
20 - const b = await Browser.launch({});
24 + const b = await Browser.launch({
25 + executablePath: await testChromiumExecutable(fixture),
26 + });
21 27 await b.close();
22 28 assert.equal(existsSync(stale), false);
23 29 assert.equal(existsSync(unknown), true);
24 30 } finally {
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 () => {
27 27 await writeFile(
28 28 join(fixtureRoot, ".pi", "settings.json"),
29 29 JSON.stringify({
30 - "chrome-cdp": { artifactDir, executablePath: chromium.executablePath() },
30 + "chrome-cdp": {
31 + artifactDir,
32 + executablePath: await testChromiumExecutable(fixtureRoot),
33 + },
33 36 const handlers: Record<string, Function> = {};

extensions/the-system/__tests__/board-server.test.ts

Modified
134 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);
139 + let renders = 0;
140 + const client = await open(root, (index, _board, _proposals, revision) => {
141 + renders += 1;
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",
146 + );
147 + const status =
148 + plan?.metadata.type === "plan" ? plan.metadata.status : "missing";
149 + writeFileSync(
150 + path.join(directory, "index.html"),
151 + `<body data-revision="${revision}" data-status="${status}">`,
152 + "utf8",
153 + );
154 + return { directory };
155 + });
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

Modified
230 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();
235 + return updated;
236 + });
233 237 respondJson(response, 200, result);
234 238 return;

package-lock.json

Modified
2 2 "name": "pi-ext",
3 - "version": "0.1.3",
3 + "version": "0.1.4",
4 4 "lockfileVersion": 3,
5 5 "requires": true,
6 6 "packages": {
7 7 "": {
8 8 "name": "pi-ext",
9 - "version": "0.1.3",
9 + "version": "0.1.4",
10 10 "workspaces": [
11 11 "extensions/*"

package.json

Modified
2 2 "name": "pi-ext",
3 - "version": "0.1.3",
3 + "version": "0.1.4",
4 4 "private": true,
5 5 "type": "module",
6 6 "workspaces": [

scripts/e2e.mjs

Modified
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.
26 + const cacheRoot =
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");
25 30 const env = {
26 31 ...parent,
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

Modified
38 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",
44 + CI: "true",
45 + PI_EXT_CI_CACHE_ROOT: "/cache/toolchains",
46 + NPM_CONFIG_CACHE: "/cache/npm",
47 + });
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",
56 + });
57 + expect(local.PLAYWRIGHT_BROWSERS_PATH).toBe("/tmp/isolated/browsers");
58 +});
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]]);