-
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.
devops: run lhci on bot and user landings (#75)
* devops: debug github actions * devops: run lhci on bot and user landings
- Loading branch information
1 parent
15179c2
commit 88c230d
Showing
1 changed file
with
20 additions
and
18 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 |
---|---|---|
|
@@ -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 | ||
|
@@ -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/[email protected] | ||
|