This document explains how Lighthouse CI performance budget tests work in the ILN-Frontend project.
Lighthouse CI automatically audits the application's performance on every push and pull request to main and develop branches. It measures Core Web Vitals and other performance metrics against defined budgets.
The following performance budgets are enforced as errors (CI will fail if exceeded):
- Largest Contentful Paint (LCP): < 2.5s
- First Input Delay (FID): < 100ms
- Cumulative Layout Shift (CLS): < 0.1
- Total Byte Weight: < 200KB gzipped
Additional metrics are tracked as warnings (CI will not fail but will alert):
- Time to Interactive: < 3.8s
- First Contentful Paint: < 1.8s
- Performance Score: > 70
- Accessibility Score: > 90
- Best Practices Score: > 80
- SEO Score: > 80
Lighthouse CI audits the following pages:
/(home page)/marketplace/dashboard/lp/governance
- On each push/PR to
mainordevelop, the GitHub Actions workflow runs - The Next.js app is built in production mode
- Lighthouse CI runs 3 audits for each URL and averages the results
- Results are compared against the budget thresholds
- Reports are uploaded as GitHub Actions artifacts (retained for 30 days)
- Go to the Actions tab in the GitHub repository
- Click on the failed or successful workflow run
- Scroll to the Artifacts section at the bottom
- Download the
lighthouse-reportsartifact - Extract the ZIP file and open the HTML reports in your browser
To run Lighthouse CI locally:
# Build the app
npm run build
# Start the production server
npm start
# In another terminal, run Lighthouse CI
npx @lhci/cli autorunThe reports will be saved in the .lighthouseci/ directory.
Each HTML report shows:
- Performance Score: Overall performance rating (0-100)
- Core Web Vitals: LCP, FID, CLS with pass/fail status
- Opportunities: Suggestions to improve performance
- Diagnostics: Detailed metrics and resource analysis
If CI fails due to performance budget violations:
- Download the Lighthouse report to identify which metric failed
- Check the Opportunities section for specific improvement suggestions
- Common fixes:
- Optimize images (use WebP, lazy loading)
- Reduce JavaScript bundle size (code splitting, tree shaking)
- Minimize render-blocking resources
- Improve server response times
- Test locally before pushing to verify the fix
Lighthouse CI is configured in .lighthouserc.json:
ci.collect.url: Pages to auditci.assert.assertions: Budget thresholds and severity levelsci.upload: Report storage settings
The CI workflow is defined in .github/workflows/lighthouse.yml.