Skip to content

Commit

Permalink
fix: 결과 파일 임시저장소에 저장하기
Browse files Browse the repository at this point in the history
  • Loading branch information
a-honey committed Dec 1, 2024
1 parent 0bab2f2 commit f88aa06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 69 deletions.
52 changes: 3 additions & 49 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
11 changes: 11 additions & 0 deletions lighthouserc.js
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",
},
},
};
20 changes: 0 additions & 20 deletions lighthouserc.json

This file was deleted.

0 comments on commit f88aa06

Please sign in to comment.