From 2165ed0c337d6b22c215ab070f05d9194b326375 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 24 May 2026 11:40:26 +0100 Subject: [PATCH] fix ci --- README.md | 2 +- package.json | 2 +- scripts/install-playwright-deps.mjs | 32 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 scripts/install-playwright-deps.mjs diff --git a/README.md b/README.md index 5b9c014..ccb3b1f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ required client JavaScript. ```sh npm install -npx playwright install chromium # required before `npm run qa:overflow` +npx playwright install --with-deps chromium # required before `npm run qa:overflow` ``` ## Commands diff --git a/package.json b/package.json index 0a80d10..1f56552 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "build": "astro build", "preview": "astro preview", "qa:no-js": "node scripts/check-no-js.mjs", - "qa:overflow": "node scripts/check-overflow.mjs", + "qa:overflow": "node scripts/install-playwright-deps.mjs && node scripts/check-overflow.mjs", "qa": "npm run typecheck && npm run lint && npm run build && npm run qa:no-js && npm run qa:overflow" }, "repository": { diff --git a/scripts/install-playwright-deps.mjs b/scripts/install-playwright-deps.mjs new file mode 100644 index 0000000..2cb2ac8 --- /dev/null +++ b/scripts/install-playwright-deps.mjs @@ -0,0 +1,32 @@ +import { spawnSync } from 'node:child_process'; +import { existsSync } from 'node:fs'; +import { chromium } from 'playwright'; + +const isLinux = process.platform === 'linux'; + +if (!isLinux) { + process.exit(0); +} + +const executablePath = chromium.executablePath(); +let needsInstall = !existsSync(executablePath); + +if (!needsInstall) { + const ldd = spawnSync('ldd', [executablePath], { encoding: 'utf8' }); + const output = `${ldd.stdout ?? ''}${ldd.stderr ?? ''}`; + needsInstall = ldd.status !== 0 || output.includes('not found'); +} + +if (!needsInstall) { + process.exit(0); +} + +const result = spawnSync('playwright', ['install', '--with-deps', 'chromium'], { + stdio: 'inherit', +}); + +if (result.error) { + throw result.error; +} + +process.exit(result.status ?? 1);