ci on Linux: --no-sandbox for the Chromium storebound starts itself as root on Linux or in a container (sandboxArgs; Chromium refuses root without it), never on macOS / Windows / a normal user; workflow caches Playwright's browsers; capture-web prints the capture's stderr when a run fails

This commit is contained in:
CRTkafa 2026-10-13 02:51:48 +08:00
parent 8c7274edcc
commit 56591f4118
5 changed files with 42 additions and 5 deletions

View file

@ -42,7 +42,7 @@
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { homedir, tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { chromiumFor, installedBrowsers, type LaunchDeps, persistentExecutable, profileHolder } from '../shots/browser';
import { chromiumFor, installedBrowsers, type LaunchDeps, persistentExecutable, profileHolder, sandboxArgs } from '../shots/browser';
/* eslint-disable @typescript-eslint/no-explicit-any */
@ -250,10 +250,12 @@ export const AUTOMATION_SWITCHES = ['--enable-automation', '--remote-debugging-p
/**
* The command line of the Chrome storebound starts itself for the console window: its own user data dir, a DevTools
* port the OS picks (written to <dir>/DevToolsActivePort, loopback only), session restore, no automation markers, no
* first-run dialogs. Nothing else: Chrome keeps its own user agent, keychain and updates.
* first-run dialogs; --no-sandbox only where Chromium cannot start without it (root on Linux, a container:
* sandboxArgs). Nothing else: Chrome keeps its own user agent, keychain and updates.
*/
export function consoleChromeArgs(userDataDir: string, o: { headless?: boolean } = {}): string[] {
return [`--user-data-dir=${userDataDir}`, '--remote-debugging-port=0', '--no-first-run', '--no-default-browser-check', ...KEEP_SESSION_ARGS, ...NO_AUTOMATION_ARGS, ...(o.headless ? ['--headless=new'] : [])];
export function consoleChromeArgs(userDataDir: string, o: { headless?: boolean; sandbox?: string[] } = {}): string[] {
return [`--user-data-dir=${userDataDir}`, '--remote-debugging-port=0', '--no-first-run', '--no-default-browser-check', ...KEEP_SESSION_ARGS, ...NO_AUTOMATION_ARGS,
...(o.sandbox ?? sandboxArgs()), ...(o.headless ? ['--headless=new'] : [])];
}
/** One new tab for storebound; the tabs the session restore brought back are closed (they would compete for "the active tab"). */