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

@ -98,6 +98,8 @@ function project(cfg: ShipConfig, files: Record<string, string>): { root: string
return { root, setConfig, cli: async args => {
const r = Bun.spawn(['bun', CLI, 'shots', 'capture', ...args], { cwd: root, stdout: 'pipe', stderr: 'pipe', env: { ...process.env, NO_COLOR: '1' } });
const [out, err, code] = await Promise.all([new Response(r.stdout).text(), new Response(r.stderr).text(), r.exited]);
// failed frames are warnings on stderr (exit 1): show them, or a CI failure only says which file is missing
if (code !== 0) console.error(`storebound shots capture ${args.join(' ')} (exit ${code}):\n${err}`);
return { out, err, code };
} };
}

View file

@ -11,6 +11,7 @@ import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { APPLE_COPY_NOTE, AUTOMATION_SWITCHES, browserPlan, chromeDataDir, consoleChromeArgs, CONSOLE_HOSTS, cookieApplies, copySession, devToolsEndpoint, filterCookies, GOOGLE_COPY_WARNING, GOOGLE_REJECTED, googleRejected, NEVER_COPY, openConsoleBrowser, parseUseChromeSession, pickProfile, PROVIDER_HOSTS, sessionFiles } from '../cli/console/session';
import { sandboxArgs } from '../cli/shots/browser';
import { capped, CLOSE_TIMEOUT_MS, LAUNCH_TIMEOUT_MS } from './helpers/browser';
const scratch = mkdtempSync(join(tmpdir(), 'sb-session-test-'));
@ -133,6 +134,17 @@ describe('Google session safety (device-bound cookies)', () => {
expect(a).toContain('--user-data-dir=/p');
expect(a.some(x => /user-agent/i.test(x))).toBe(false);
expect(consoleChromeArgs('/p', { headless: true })).toContain('--headless=new');
expect(consoleChromeArgs('/p', { sandbox: [] })).not.toContain('--no-sandbox');
expect(consoleChromeArgs('/p', { sandbox: ['--no-sandbox'] })).toContain('--no-sandbox');
});
test('--no-sandbox only for root on Linux or inside a container; never on macOS, Windows or for a normal user', () => {
const no = () => false, yes = () => true;
expect(sandboxArgs('linux', 0, no)).toEqual(['--no-sandbox']);
expect(sandboxArgs('linux', 1000, yes)).toEqual(['--no-sandbox']);
expect(sandboxArgs('linux', 1000, no)).toEqual([]);
expect(sandboxArgs('darwin', 0, yes)).toEqual([]);
expect(sandboxArgs('darwin', 501, no)).toEqual([]);
expect(sandboxArgs('win32', undefined, yes)).toEqual([]);
});
});