-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Lighthouse-CI #5492 #5521
Add Lighthouse-CI #5492 #5521
Changes from all commits
f792044
544bf99
6ba3fa1
430e4a1
ab8d76d
6517116
fbcfb3f
cc437ab
b410ea5
ac87ab3
d1b0b3d
d78691f
9e6f089
a2af08a
87c9185
8028482
b5b5786
2c3aed6
1ea408c
0da80fd
a106230
a364fa5
417f524
713ba94
5a4c621
5c397ec
6fe55cc
c3d0267
ff5d41e
978299c
d797f51
6879fd7
c7bbc29
f3b62fa
a186a99
a4d9e3f
bebaaff
e96ba62
1ad6f03
f95581a
cfd72a3
1b73c67
254f676
58368b8
2479086
9ecc17c
3c56456
06f8534
ca023f7
2be0c19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Google Lighthouse | ||
|
||
on: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is correct, I believe the |
||
issue_comment: | ||
types: [edited] | ||
|
||
jobs: | ||
generate_lighthouse_audit: | ||
timeout-minutes: 30 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add comment to PR | ||
id: loading_comment_to_pr | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.LIGHTHOUSE_APP_TOKEN }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be set. By default it will use |
||
number: ${{ github.event.issue.number }} | ||
header: lighthouse | ||
message: | | ||
Running Lighthouse audit... | ||
- name: Capture Vercel preview URL | ||
id: vercel_preview_url | ||
uses: aaimio/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.LIGHTHOUSE_APP_TOKEN }} | ||
- uses: actions/checkout@v3 | ||
- name: Audit preview URL with Lighthouse | ||
id: lighthouse_audit | ||
uses: treosh/lighthouse-ci-action@v10 | ||
with: | ||
urls: | | ||
${{ steps.vercel_preview_url.outputs.vercel_preview_url }} | ||
uploadArtifacts: true | ||
temporaryPublicStorage: true | ||
- name: Format lighthouse score | ||
id: format_lighthouse_score | ||
uses: actions/github-script@v3 | ||
with: | ||
github-token: ${{secrets.LIGHTHOUSE_APP_TOKEN}} | ||
script: | | ||
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary | ||
const links = ${{ steps.lighthouse_audit.outputs.links }} | ||
|
||
const formatResult = (res) => Math.round((res * 100)) | ||
Object.keys(result).forEach(key => result[key] = formatResult(result[key])) | ||
|
||
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴' | ||
|
||
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') | ||
|
||
core.setOutput("comment", comment); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The indentation of this line is wrong. |
||
- name: Add comment to PR | ||
id: comment_to_pr | ||
uses: marocchino/sticky-pull-request-comment@v1 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.LIGHTHOUSE_APP_TOKEN }} | ||
number: ${{ github.event.issue.number }} | ||
header: lighthouse | ||
message: | | ||
${{ steps.format_lighthouse_score.outputs.comment }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"ci": { | ||
"collect": { | ||
"startServerCommand": "npm run serve", | ||
"startServerReadyPattern": "Server running at http://localhost:3000/", | ||
"url": [ | ||
"http://localhost:3000/en", | ||
ovflowd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"http://localhost:3000/en/about", | ||
"http://localhost:3000/en/download", | ||
"http://localhost:3000/en/docs", | ||
"http://localhost:3000/en/get-involved", | ||
"http://localhost:3000/en/blog" | ||
], | ||
"numberOfRuns": 1, | ||
"settings": { | ||
"preset": "desktop" | ||
} | ||
}, | ||
"upload": { | ||
"target": "temporary-public-storage" | ||
ovflowd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
"assert": { | ||
"preset": "lighthouse:recommended" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't create yet another GitHub Actions Workflow, this should be added on the
build-and-analysis.yml
Workflow, as a separate job. It can just be called "lighthouse"Also, it'd be great to give a
name:
field as "Google Lighthouse"`There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move this to build and analysis.yml and also the name