This document describes the complete Lighthouse CI implementation for issue #511.
.lighthouserc.json (Main Configuration)
- 3 runs per URL (for statistical significance)
- Score assertions for all categories
- Performance: ≥ 90
- Accessibility: ≥ 95
- Best Practices: ≥ 90
- SEO: ≥ 90
- Temporary public storage for results
.lighthouserc.extended.json (Advanced Metrics)
- Web Vitals tracking
- FCP, LCP, CLS thresholds
- Additional performance details
- For deeper analysis
.github/workflows/lighthouse.yml
Features:
- ✅ Automatic Vercel preview URL detection
- ✅ Waits for Vercel deployment (5-minute timeout)
- ✅ Runs Lighthouse CI against preview
- ✅ Posts results as PR comment
- ✅ Fails if scores below thresholds
- ✅ Uploads artifacts (30-day retention)
- ✅ Supports manual trigger with custom URL
Triggers:
- Every PR (opened, synchronized, reopened)
- File changes in frontend-scaffold/
- Manual workflow dispatch
docs/LIGHTHOUSE_CI_SETUP.md (Comprehensive)
- Configuration explanation
- Integration points
- Troubleshooting guide
- Performance tips
- Local testing instructions
LIGHTHOUSE_CI_QUICK_START.md (Developer Guide)
- Quick start for developers
- Common issues & fixes
- Performance tips
- FAQs
- Before-pushing checklist
LIGHTHOUSE_CONFIGURATIONS.md (Reference)
- Desktop configuration details
- Mobile configuration (for future)
- Why different thresholds
- Configuration comparison
- ✅ GitHub Actions workflow created
- ✅ Triggers on PR events
- ✅ Automatic Vercel integration
- ✅ Waits for deployment if needed
- ✅ 3 runs per URL averaged (statistical significance)
- ✅ Results uploaded to temporary storage
- ✅ Artifacts retained for 30 days
- ✅ Can review historical trends
- ✅ Assertions fail below thresholds
- ✅ CI check fails PR merge
- ✅ PR comment shows specific failures
- ✅ Clear guidance on what failed
- ✅ Performance > 90
- ✅ Accessibility > 95
- ✅ Best Practices > 90
- ✅ SEO > 90
- ✅ Desktop configured and active
- ✅ Mobile configuration prepared
- ✅ Can be enabled with single config change
| Category | Desktop | Mobile | Rationale |
|---|---|---|---|
| Performance | 90 | 85* | Mobile more constrained |
| Accessibility | 95 | 95 | Universal standard |
| Best Practices | 90 | 85* | Device limitations |
| SEO | 90 | 90 | Crawlability same |
*Mobile configuration ready, not yet enabled
PR Opened
↓
Wait for Vercel Deployment (detected from comments)
↓
Install Lighthouse CI
↓
Run 3 Lighthouse audits
↓
Average results
↓
Check against thresholds
↓
Post PR comment
↓
Fail/Pass CI check
↓
Upload artifacts (30 days)
Measured in Lighthouse:
- FCP (First Contentful Paint): When first content visible
- LCP (Largest Contentful Paint): When largest content visible
- CLS (Cumulative Layout Shift): Visual stability
- TTI (Time to Interactive): When page is interactive
- TBT (Total Blocking Time): JavaScript blocking
WCAG AA compliance:
- Color contrast (4.5:1 for text)
- ARIA labels
- Semantic HTML
- Keyboard navigation
- Form associations
Web standards compliance:
- HTTPS everywhere
- No console errors
- No deprecated APIs
- CSP headers
- Browser compatibility
Search engine optimization:
- Mobile friendly
- Meta descriptions
- Robots.txt
- Structured data
- Internal linking
PR created
↓
Vercel preview deployed
↓
Lighthouse CI runs
↓
Results posted to PR
↓
Required status check: ✅ Pass or ❌ Fail
↓
Can't merge if failed
- Results archived for trend analysis
- Can review improvement over time
- Track performance of main branch
Quick Check Before Pushing:
# Install (one-time)
npm install -g @lhci/cli
# Run locally
cd frontend-scaffold
npm run dev
# In another terminal:
lhci autorun --config=../.lighthouserc.json --url=http://localhost:3000Review PR Results:
- Check PR comment after workflow completes
- Look for scores and opportunities
- Fix if below thresholds
Manual Trigger with Custom URL:
gh workflow run lighthouse.yml -f url=https://custom-url.vercel.appAutomatic Checks:
- Every PR automatically checked
- Vercel integration seamless
- No manual action needed
- Results always visible in PR
Track Trends:
- View artifacts after each run
- Compare scores over time
- Identify performance trends
- Celebrate improvements
Edit .lighthouserc.json:
"categories:performance": ["error", { "minScore": 0.85 }] // Lower to 85"categories:seo": ["warn", { "minScore": 0.8 }] // Warn instead of error
"categories:pwa": ["error", { "minScore": 0.7 }] // Enable PWA checks"first-contentful-paint": ["error", { "maxNumericValue": 1500 }],
"largest-contentful-paint": ["error", { "maxNumericValue": 2500 }],
"cumulative-layout-shift": ["error", { "maxNumericValue": 0.1 }]| Document | Purpose | Read Time |
|---|---|---|
| This file | Complete implementation | 10 min |
| docs/LIGHTHOUSE_CI_SETUP.md | Technical setup & troubleshooting | 15 min |
| LIGHTHOUSE_CI_QUICK_START.md | Developer guide | 10 min |
| LIGHTHOUSE_CONFIGURATIONS.md | Configuration reference | 5 min |
Solution: Wait for Vercel deployment or use manual trigger
Solution: Review PR comment, implement recommendations, re-push
Solution: Check Vercel build logs, fix issues, try again
- Bundle size monitored (via npm run analyze)
- Performance scores affected by bundle
- Optimize together for best results
- Uses GitHub script for automation
- Posts comments via GitHub API
- Uses artifact storage for results
- Detects preview URLs from comments
- Can also check deployment statuses
- Manual URL override available
After implementation:
- ✅ Every PR has performance check
- ✅ Performance regressions blocked
- ✅ Scores tracked over time
- ✅ Team aware of performance impact
- ✅ Consistent quality maintained
- Review PR comment after running
- Understand your baseline scores
- Note any opportunities
- Implement top optimization suggestions
- Improve scores over iterations
- Build familiarity with metrics
- Monitor trends in artifacts
- Set ambitious targets
- Celebrate performance improvements
- Share results with team
Created:
.lighthouserc.json- Main configuration.lighthouserc.extended.json- Advanced metrics.github/workflows/lighthouse.yml- CI workflowdocs/LIGHTHOUSE_CI_SETUP.md- Technical guideLIGHTHOUSE_CI_QUICK_START.md- Developer guideLIGHTHOUSE_CONFIGURATIONS.md- Configuration referenceIMPLEMENTATION_LIGHTHOUSE_CI.md- This file
- Automatic Detection: Finds Vercel preview URL automatically
- Smart Waiting: Waits up to 5 minutes for deployment
- Clear Reporting: Posts detailed results in PR comment
- Enforcement: Blocks merge if thresholds not met
- Historical Tracking: Keeps results for 30 days
- Developer Friendly: Quick start guide and local testing
- Flexible: Supports manual triggers and custom URLs
- Extensible: Easy to enable mobile audits
- Standard Thresholds: Industry-standard best practices
- Web Vitals Ready: Can track Core Web Vitals
What You Get:
- ✅ Automatic performance monitoring
- ✅ Accessibility enforcement
- ✅ Best practices verification
- ✅ SEO compliance checking
- ✅ Regression prevention
- ✅ Historical tracking
- ✅ Developer guidance
- ✅ CI/CD integration
Status: Ready for production deployment
Implementation Date: May 26, 2026 Issue: #511 - Add Lighthouse CI for automated performance monitoring Status: ✅ Complete and Ready