-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yash Khare <[email protected]>
- Loading branch information
1 parent
4c075fc
commit ef98b3d
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,7 @@ jobs: | |
- name: run Lighthouse CI for Keploy.io Deployed Website | ||
run: | | ||
npm install -g @lhci/[email protected] | ||
lhci autorun --upload.target=temporary-public-storage --config=lighthouserckeploy.json || echo "LHCI failed!" | ||
lhci autorun --upload.target=temporary-public-storage --config=lighthouserckeploy.json || echo "LHCI failed!" | ||
- name: Compare Lighthouse Reports | ||
run: | | ||
node scripts/compare-lhci-reports.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const fs = require('fs'); | ||
|
||
function loadReport(path) { | ||
if (!fs.existsSync(path)) { | ||
console.error(`Report not found at path: ${path}`); | ||
process.exit(1); | ||
} | ||
const data = fs.readFileSync(path, 'utf8'); | ||
return JSON.parse(data); | ||
} | ||
|
||
const appReportPath = './lhci-reports/app/latest-run/report.json'; | ||
const keployReportPath = './lhci-reports/keploy.io/latest-run/report.json'; | ||
|
||
const appReport = loadReport(appReportPath); | ||
const keployReport = loadReport(keployReportPath); | ||
|
||
const categories = ['performance', 'accessibility', 'best-practices', 'seo']; | ||
|
||
let allPass = true; | ||
|
||
categories.forEach(category => { | ||
const appScore = appReport.categories[category].score; | ||
const keployScore = keployReport.categories[category].score; | ||
console.log(`Comparing ${category}: App=${appScore} vs Keploy.io=${keployScore}`); | ||
if (appScore < keployScore) { | ||
console.error(`Score for ${category} is lower in the application (${appScore}) than Keploy.io (${keployScore})`); | ||
allPass = false; | ||
} | ||
}); | ||
|
||
if (!allPass) { | ||
console.error('Lighthouse scores are lower than the baseline. Failing the CI job.'); | ||
process.exit(1); | ||
} else { | ||
console.log('All Lighthouse scores are equal or better than the baseline.'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters