-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
14 additions
and
69 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 |
---|---|---|
|
@@ -26,54 +26,8 @@ jobs: | |
yarn build | ||
- name: Run Lighthouse CI | ||
env: | ||
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} | ||
run: | | ||
npm install -g @lhci/cli | ||
lhci autorun || echo "Fail to Run Lighthouse CI!" | ||
- name: Upload Lighthouse Results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: lighthouse-report | ||
path: .lighthouseci | ||
include-hidden-files: true | ||
|
||
- name: Check LHCI Output | ||
run: | | ||
echo "Checking lhci_reports directory..." | ||
ls -la ./lhci_reports || echo "lhci_reports directory does not exist" | ||
- name: Format Lighthouse Score | ||
id: format_lighthouse_score | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const results = JSON.parse(fs.readFileSync("/home/runner/work/admin-2/admin-2/lhci_reports/manifest.json")); | ||
let comments = `| Performance | First Contentful Paint | Speed Index | Time to Interactive | Total Blocking Time | Largest Contentful Paint | Cumulative Layout Shift |\n`; | ||
results.forEach((result) => { | ||
const { summary, jsonPath } = result; | ||
const details = JSON.parse(fs.readFileSync(jsonPath)); | ||
const { audits } = details; | ||
const formatResult = (res) => Math.round(res * 100); | ||
Object.keys(summary).forEach( | ||
(key) => (summary[key] = formatResult(summary[key])) | ||
); | ||
const score = (res) => (res >= 90 ? "🟢" : res >= 50 ? "🟠" : "🔴"); | ||
comments += `| ${score(summary.performance)} ${summary.performance} | ${score(audits["first-contentful-paint"].score * 100)} ${audits["first-contentful-paint"].displayValue} | ${score(audits["speed-index"].score * 100)} ${audits["speed-index"].displayValue} | ${score(audits["interactive"].score * 100)} ${audits["interactive"].displayValue} | ${score(audits["total-blocking-time"].score * 100)} ${audits["total-blocking-time"].displayValue} | ${score(audits["largest-contentful-paint"].score * 100)} ${audits["largest-contentful-paint"].displayValue} | ${score(audits["cumulative-layout-shift"].score * 100)} ${audits["cumulative-layout-shift"].displayValue} |\n`; | ||
}); | ||
core.setOutput('comments', comments) | ||
- name: Comment on PR | ||
uses: unsplash/[email protected] | ||
npm install -g @lhci/[email protected] | ||
lhci autorun | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} | ||
with: | ||
msg: ${{ steps.format_lighthouse_score.outputs.comments }} | ||
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} |
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,11 @@ | ||
module.exports = { | ||
ci: { | ||
collect: { | ||
url: ["http://localhost:4173/"], | ||
startServerCommand: "yarn run preview", | ||
}, | ||
upload: { | ||
target: "temporary-public-storage", | ||
}, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.