A comprehensive Lighthouse CI automation tool that performs website performance audits and automatically uploads reports to GitHub Gists for easy sharing and viewing.
This repository automates web performance testing using Google Lighthouse CI and provides a seamless way to:
- π Run Lighthouse audits on multiple URLs with different device configurations
- π± Test both mobile and desktop performance separately
- π Generate detailed performance reports with metrics like Performance, Accessibility, Best Practices, SEO, and PWA scores
- π Upload reports to GitHub Gists for easy sharing and online viewing
- π View reports directly in Lighthouse's online viewer
- π§ͺ Support dry-run mode for testing without actual uploads
Currently configured to test Cupra Official websites (Danish and Finnish markets), but easily configurable for any website.
- Node.js (v18+ recommended)
- pnpm package manager
- GitHub Personal Access Token with gist creation permissions
-
Clone the repository
git clone <repository-url> cd lighthouseReports
-
Install dependencies
pnpm install
-
Set up GitHub token
# For local development export GH_TOKEN="your_github_personal_access_token" # Or create a .env file (don't commit this!) echo "GH_TOKEN=your_github_personal_access_token" > .env
| Script | Description |
|---|---|
pnpm test |
Run all Jest tests |
pnpm run lhci |
Run Lighthouse CI with main config |
pnpm run lhci:mobile |
Run mobile-specific Lighthouse audits |
pnpm run lhci:desktop |
Run desktop-specific Lighthouse audits |
pnpm run lhci:all |
Run both mobile and desktop audits |
pnpm run upload-gist |
Upload generated reports to GitHub Gists |
-
Run performance audits:
# Test both mobile and desktop pnpm run lhci:all # Or run individually pnpm run lhci:mobile pnpm run lhci:desktop
-
Upload results to GitHub:
# Upload all generated reports pnpm run upload-gist # Or with dry-run to test first node --loader ts-node/esm src/upload-gist.ts --dry-run
-
View your reports:
- Reports are uploaded as GitHub Gists
- Each gist can be viewed in Lighthouse Viewer
- URLs are automatically generated and displayed
Edit the URLs in .lighthouserc.mobile.cjs and .lighthouserc.desktop.cjs:
module.exports = {
ci: {
collect: {
url: [
'https://your-website.com',
'https://your-website.com/another-page',
],
// ... other settings
}
}
};The configurations include:
Mobile Configuration:
- Form factor: Mobile device simulation
- Standard mobile throttling
- 3 runs per URL for accuracy
Desktop Configuration:
- Form factor: Desktop (1024x850 resolution)
- Faster network throttling (10Mbps)
- No CPU throttling for desktop performance
- 3 runs per URL for accuracy
# Upload with custom gist ID
node --loader ts-node/esm src/upload-gist.ts --gist=your-gist-id
# Dry run mode (test without uploading)
node --loader ts-node/esm src/upload-gist.ts --dry-run
# Upload specific file
node --loader ts-node/esm src/upload-gist.ts --file=path/to/report.jsonWhen you run the uploader, you'll see output like:
π Lighthouse Gist Uploader - Multiple Reports Mode
ββββββββββββββββββββββββββββββββββββββββββββββββββ
π Main manifest loaded
π± Mobile manifest loaded
π₯οΈ Desktop manifest loaded
β
Found representative run for mobile: Performance 87%
β
Found representative run for desktop: Performance 94%
π Uploading 2 representative runs...
π€ Processing mobile report...
β
MOBILE gist created: abc123def456
π Viewer: https://googlechrome.github.io/lighthouse/viewer/?gist=abc123def456
π€ Processing desktop report...
β
DESKTOP gist created: def456ghi789
π Viewer: https://googlechrome.github.io/lighthouse/viewer/?gist=def456ghi789
π SUMMARY - 2 Gists Created:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1. MOBILE
π Performance: 87%
π Gist ID: abc123def456
π Viewer: https://googlechrome.github.io/lighthouse/viewer/?gist=abc123def456
2. DESKTOP
π Performance: 94%
π Gist ID: def456ghi789
π Viewer: https://googlechrome.github.io/lighthouse/viewer/?gist=def456ghi789
π Average Performance: 91%
The project includes comprehensive Jest tests:
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test -- --watch
# Run specific test file
pnpm test -- readAllManifests.test.ts- ES2020 modules with TypeScript
- Strict mode enabled for better code quality
- Import extensions required for proper ES module resolution
- TypeScript - Type-safe JavaScript
- Node.js - Runtime environment
- Lighthouse CI - Performance testing
- Octokit - GitHub API integration
- Jest - Testing framework
- Yargs - CLI argument parsing
- pnpm - Fast, disk space efficient package manager
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Run tests (
pnpm test) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Perfect for automated performance monitoring in your CI/CD pipeline:
# GitHub Actions example
- name: Run Lighthouse CI
run: |
pnpm run lhci:all
pnpm run upload-gist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- Track performance changes over time
- Compare mobile vs desktop performance
- Share results with team members via Gist URLs
- Monitor core web vitals and accessibility scores
Use the performance scores to implement quality gates in your deployment process.
"Cannot find module" errors:
- Ensure you're using Node.js 18+
- Run
pnpm installto reinstall dependencies
GitHub API errors:
- Verify your
GH_TOKENis set correctly - Ensure the token has
gistpermissions - Check your GitHub API rate limits
Lighthouse CI failures:
- Verify the target URLs are accessible
- Check network connectivity
- Review Lighthouse CI logs in
.lighthouse-ci/directory
Run with dry-run first to test configuration:
node --loader ts-node/esm src/upload-gist.ts --dry-runThis project is available for use under your preferred license terms.
β
Multi-device testing (Mobile & Desktop)
β
Automated Gist uploads with GitHub integration
β
Beautiful CLI output with emojis and progress indicators
β
Comprehensive test coverage with Jest
β
TypeScript support with ES modules
β
Dry-run mode for safe testing
β
Clean architecture for maintainability
β
Easy configuration for different websites
β
Detailed performance metrics and summaries
Perfect for teams wanting to automate and share web performance monitoring! π