LibreChat/.github/workflows/lighthouse.yml
Danny Avila c883e9ef32
🔦 chore: Drop @lhci/cli and Run Lighthouse 13 Directly (#15687)
`@lhci/cli@0.15.1` pins `lighthouse` to an exact `12.6.1`, so the Lighthouse
lane could never move off a release whose `puppeteer-core` still depends on
`extract-zip` — an advisory with no patched version. That pin, not Lighthouse
itself, was holding 8 of the repository's 16 `npm audit` findings open.

LHCI was only ever a subprocess wrapper here: `audit.ts` shelled out to
`@lhci/cli/src/cli.js` for `collect` and `assert`, and LHCI's own node runner
shells out to `lighthouse/cli/index.js` in turn. Call that CLI directly, run
the three navigations in a loop, and assert the median budgets in TypeScript
next to the assertions `load.spec.ts` already makes.

- `npm audit`: 16 findings (7 high, 1 moderate, 8 low) -> 6 low. The remainder
  is the pre-existing `elliptic` chain under `vite-plugin-node-polyfills`,
  which has no fixed version and is unrelated to this lane.
- Lighthouse 13 removed `largest-contentful-paint-element` and moved the LCP
  node into `lcp-breakdown-insight`. Reading it through a `lcpElement` helper
  keeps the "the transcript must be the LCP element" guard working and makes
  the next rename fail loudly in one place.
- Reports move to `.lighthouse/` as `lhr-N.report.{json,html}`; cookie
  redaction, the API timing table and the desktop/provided-throttling settings
  are unchanged. Budgets are now printed as a table immediately before they are
  asserted, so the workflow's 80-line failure comment always contains them.
- `CHROME_PATH` and `LIGHTHOUSE_CHROME_FLAGS` are documented: chrome-launcher
  prefers the Windows Chrome under WSL, whose debugging port Linux cannot
  reach.
2026-09-06 23:20:22 -04:00

71 lines
2 KiB
YAML

name: Lighthouse CI
on:
pull_request:
paths:
- 'api/**'
- 'client/**'
- 'config/**'
- 'packages/**'
- 'e2e/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/lighthouse.yml'
- '!**.md'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
concurrency:
group: lighthouse-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lighthouse:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
E2E_CHROMIUM_CHANNEL: chrome
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: '24.16.0'
cache: npm
- run: npm ci
- run: npm run e2e:prepare
- run: google-chrome --version
- name: Audit serial database latency
id: audit
shell: bash
run: |
set -o pipefail
npm run lighthouse:run 2>&1 | tee lighthouse-ci.log
- name: Comment Lighthouse findings
if: ${{ failure() && steps.audit.outcome == 'failure' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
{
echo 'Lighthouse CI failed. The last 80 log lines contain the measured budgets and assertion failures.'
echo
echo '```text'
tail -n 80 lighthouse-ci.log
echo '```'
echo
echo "[Open the full run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)"
} > lighthouse-comment.md
gh pr comment "$PR_NUMBER" --body-file lighthouse-comment.md
- name: Upload Lighthouse reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v6
with:
name: lighthouse
path: |
.lighthouse/
lighthouse-ci.log
include-hidden-files: true
retention-days: 7