From 76031163690fb25597799efecddb167f62f22943 Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Mon, 14 Sep 2026 21:19:20 +0100 Subject: [PATCH] ci(lighthouse): stop lhci reading the form factor as a CLI flag lhci treats every LHCI_* environment variable as a command-line option, so LHCI_PRESET=mobile reached `lhci assert` as an invalid --preset and failed both jobs after the audits had run. Use LIGHTHOUSE_FORM_FACTOR instead. Also upload the reports: upload-artifact v4+ skips dot-directories such as .lighthouseci unless include-hidden-files is set. --- .github/workflows/tests.yml | 9 ++++++--- README.md | 2 +- lighthouserc.cjs | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6ff0904..1a67a22 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,7 +86,7 @@ jobs: strategy: fail-fast: false matrix: - preset: [mobile, desktop] + form-factor: [mobile, desktop] steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 @@ -97,13 +97,16 @@ jobs: # The homepage streams public stats from the database, so audit against a real stack. - run: npx supabase start - run: npm run test:lighthouse + # Not LHCI_*: lhci reads any LHCI_ variable as a CLI flag (LHCI_PRESET became `--preset`). env: - LHCI_PRESET: ${{ matrix.preset }} + LIGHTHOUSE_FORM_FACTOR: ${{ matrix.form-factor }} - uses: actions/upload-artifact@v6 if: always() with: - name: lighthouse-${{ matrix.preset }} + name: lighthouse-${{ matrix.form-factor }} path: .lighthouseci/ + # upload-artifact v4+ skips dot-directories unless told otherwise. + include-hidden-files: true if-no-files-found: ignore - if: always() run: npx supabase stop diff --git a/README.md b/README.md index 3014953..7c9f7a7 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ The test suite is split by responsibility so a failure points to the correct lay - `lighthouserc.cjs` audits the public pages with Lighthouse CI (`npm run test:lighthouse`, which builds and serves the Node output). PRs fail if Performance, Accessibility, Best Practices or SEO drops below 90, or if LCP, TBT, CLS, script, stylesheet or total transfer size exceeds its budget. - CI runs it with both the mobile and desktop profiles (`LHCI_PRESET=desktop`). + CI runs it with both the mobile and desktop profiles (`LIGHTHOUSE_FORM_FACTOR=desktop`). - `tests/bdd/features/performance.feature` holds time budgets for signed-in pages Lighthouse can't reach: opening a Pokédex and switching between it and the Pokédex list. diff --git a/lighthouserc.cjs b/lighthouserc.cjs index 0c367df..a6c2315 100644 --- a/lighthouserc.cjs +++ b/lighthouserc.cjs @@ -1,8 +1,10 @@ // Lighthouse CI: `npm run test:lighthouse` builds the Node adapter output, serves it and audits the // public pages. Any category below 90 fails the run (and so the PR). -// Set LHCI_PRESET=desktop to audit with the desktop profile; the default is Lighthouse's mobile -// profile (slow 4G + CPU throttling), which is the stricter of the two. -const preset = process.env.LHCI_PRESET === 'desktop' ? 'desktop' : undefined; +// Set LIGHTHOUSE_FORM_FACTOR=desktop to audit with the desktop profile; the default is Lighthouse's +// mobile profile (slow 4G + CPU throttling), which is the stricter of the two. The variable must not +// start with LHCI_: lhci treats those as CLI flags, so LHCI_PRESET was passed to `lhci assert` as +// an invalid `--preset`. +const preset = process.env.LIGHTHOUSE_FORM_FACTOR === 'desktop' ? 'desktop' : undefined; module.exports = { ci: {