fix(ci): detect puppeteer chrome path for lighthouse
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 18s
Nightly QA / 🎭 Lighthouse (push) Successful in 3m38s
Build & Deploy / 🏗️ Build (push) Has been cancelled
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 QA (push) Has been cancelled
Nightly QA / 🔔 Notify (push) Has been cancelled
Nightly QA / 🔗 Links & Deps (push) Has been cancelled
Nightly QA / 🔍 Static Analysis (push) Has been cancelled
Nightly QA / ♿ Accessibility (push) Has been cancelled

This commit is contained in:
2026-03-02 13:24:06 +01:00
parent 1cfc0523f3
commit aa14f39dba

View File

@@ -80,7 +80,23 @@ async function main() {
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
});
const chromePath = process.env.CHROME_PATH || process.env.PUPPETEER_EXECUTABLE_PATH;
// Detect Chrome path from Puppeteer installation if not provided
let chromePath = process.env.CHROME_PATH || process.env.PUPPETEER_EXECUTABLE_PATH;
if (!chromePath) {
try {
const puppeteerInfo = execSync('npx puppeteer browsers latest chrome', {
encoding: 'utf8',
});
const match = puppeteerInfo.match(/executablePath: (.*)/);
if (match && match[1]) {
chromePath = match[1].trim();
console.log(`🔍 Detected Puppeteer Chrome at: ${chromePath}`);
}
} catch (e) {
console.warn('⚠️ Could not detect Puppeteer Chrome path automatically.');
}
}
const chromePathArg = chromePath ? `--collect.chromePath="${chromePath}"` : '';
// Clean up old reports
@@ -90,7 +106,7 @@ async function main() {
// Using a more robust way to execute and capture output
// We remove 'npx lhci upload' to keep everything local and avoid Google-hosted reports
const lhciCommand = `npx lhci collect ${urlArgs} ${chromePathArg} --config=config/lighthouserc.json --collect.settings.extraHeaders='${extraHeaders}' --collect.settings.chromeFlags="--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage" && npx lhci assert --config=config/lighthouserc.json`;
const lhciCommand = `CHROME_PATH="${chromePath}" npx lhci collect ${urlArgs} ${chromePathArg} --config=config/lighthouserc.json --collect.settings.extraHeaders='${extraHeaders}' --collect.settings.chromeFlags="--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage" && npx lhci assert --config=config/lighthouserc.json`;
console.log(`💻 Executing LHCI...`);
@@ -98,6 +114,7 @@ async function main() {
execSync(lhciCommand, {
encoding: 'utf8',
stdio: 'inherit',
env: { ...process.env, CHROME_PATH: chromePath },
});
} catch (err: any) {
console.warn('⚠️ LHCI assertion finished with warnings or errors.');