Skip to content

Commit

Permalink
devops: run lhci on bot and user landings (#75)
Browse files Browse the repository at this point in the history
* devops: debug github actions

* devops: run lhci on bot and user landings
  • Loading branch information
gaboesquivel authored Apr 6, 2024
1 parent 15179c2 commit 88c230d
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
with:
urls: |
"https://${{ steps.vercel_preview_url.outputs.preview_url }}"
"https://${{ steps.vercel_preview_url.outputs.preview_url }}/b/moneybot"
"https://${{ steps.vercel_preview_url.outputs.preview_url }}/u/slug-1"
"https://${{ steps.vercel_preview_url.outputs.preview_url }}/p"
# budgetPath: '.github/lighthouse/budget.json'
uploadArtifacts: true
temporaryPublicStorage: true
Expand All @@ -44,28 +47,27 @@ jobs:
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_audit.outputs.links }}
const manifest = ${{ toJSON(steps.lighthouse_audit.outputs.manifest) }};
const links = ${{ toJSON(steps.lighthouse_audit.outputs.links) }};
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const formatResult = (res) => Math.round((res * 100));
const score = (res) => (res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴');
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
let comment = `⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:\n`;
comment += '| Category | Score |\n';
comment += '| --- | --- |\n';
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
Object.keys(manifest).forEach((page) => {
const result = manifest[page].summary;
const pageLink = manifest[page].url;
Object.keys(result).forEach((key) => {
const formattedScore = formatResult(result[key]);
comment += `| ${score(result[key])} ${key} | ${formattedScore} |\n`;
});
comment += `*Lighthouse ran on [${pageLink}](${pageLink})*\n\n`;
});
core.setOutput("comment", comment);
core.setOutput('comment', comment);
- name: Add comment to PR
id: comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2.9.0
Expand Down

0 comments on commit 88c230d

Please sign in to comment.