Skip to content
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

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
f792044
Added Lighthouse
Chandupuram Jul 10, 2023
544bf99
Change
Chandupuram Jul 10, 2023
6ba3fa1
Change
Chandupuram Jul 10, 2023
430e4a1
Change
Chandupuram Jul 10, 2023
ab8d76d
Change
Chandupuram Jul 10, 2023
6517116
Commit
Chandupuram Jul 10, 2023
fbcfb3f
Design
Chandupuram Jul 10, 2023
cc437ab
Style path
Chandupuram Jul 10, 2023
b410ea5
Pages
Chandupuram Jul 10, 2023
ac87ab3
Hello
Chandupuram Jul 10, 2023
d1b0b3d
OUT
Chandupuram Jul 10, 2023
d78691f
Pages/EN
Chandupuram Jul 10, 2023
9e6f089
URL
Chandupuram Jul 10, 2023
a2af08a
GIT PUSH
Chandupuram Jul 10, 2023
87c9185
Added now
Chandupuram Jul 10, 2023
8028482
Added Package
Chandupuram Jul 10, 2023
b5b5786
Version Change
Chandupuram Jul 10, 2023
2c3aed6
EN
Chandupuram Jul 10, 2023
1ea408c
staticDistDir
Chandupuram Jul 10, 2023
0da80fd
npx lighthouse-ci --collect
Chandupuram Jul 10, 2023
a106230
space
Chandupuram Jul 10, 2023
a364fa5
steps
Chandupuram Jul 10, 2023
417f524
URL
Chandupuram Jul 10, 2023
713ba94
collect
Chandupuram Jul 10, 2023
5a4c621
version change
Chandupuram Jul 10, 2023
5c397ec
Port change
Chandupuram Jul 10, 2023
6fe55cc
URL version change
Chandupuram Jul 10, 2023
c3d0267
Added
Chandupuram Jul 10, 2023
ff5d41e
ENV Removed
Chandupuram Jul 11, 2023
978299c
Added
Chandupuram Jul 11, 2023
d797f51
Changes Done
Chandupuram Jul 11, 2023
6879fd7
Added NPX
Chandupuram Jul 11, 2023
c7bbc29
Added ENV
Chandupuram Jul 11, 2023
f3b62fa
ENV AND ASSERTIONS
Chandupuram Jul 11, 2023
a186a99
Final Touch
Chandupuram Jul 11, 2023
a4d9e3f
Added URLS
Chandupuram Jul 15, 2023
bebaaff
Removed BE
Chandupuram Jul 15, 2023
e96ba62
Removed GL
Chandupuram Jul 16, 2023
1ad6f03
Removed blog
Chandupuram Jul 16, 2023
f95581a
Removed NL
Chandupuram Jul 16, 2023
cfd72a3
Added Values
Chandupuram Jul 16, 2023
1b73c67
LightHouse Recommended
Chandupuram Jul 16, 2023
254f676
Done
Chandupuram Jul 16, 2023
58368b8
File name changed
Chandupuram Jul 16, 2023
2479086
Requested Changes
Chandupuram Jul 16, 2023
9ecc17c
Removed the unused package
Chandupuram Jul 16, 2023
3c56456
Merge branch 'main' into final-commit
ovflowd Jul 19, 2023
06f8534
Merge branch 'main' into final-commit
bmuenzenmeyer Jul 20, 2023
ca023f7
Added Custom Methods
Chandupuram Jul 23, 2023
2be0c19
Merge branch 'main' into final-commit
ovflowd Jul 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/lighthouse-ci.yml
Copy link
Member

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"`

Copy link
Author

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Google Lighthouse

on:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct, I believe the on here should be of pull_request, since this should be updated on every Pull Request.

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 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be set. By default it will use GITHUB_TOKEN which is already an Environment Variable

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);
Copy link
Member

Choose a reason for hiding this comment

The 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 }}
26 changes: 26 additions & 0 deletions .lighthouserc.json
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"
}
}
}