Skip to content

Commit

Permalink
ci: add lighthouse benchmark in Github Actions (#3708)
Browse files Browse the repository at this point in the history
* chore: added lighthouse recommended config for index page

* chore: added lighthouse config files

* chore: added lighthouse config files

* chore: added lighthouse config files

* chore: added lighthouse assertions

* chore: added lighthouse settings for categories

* chore: added lighthouse settings for only Audits

* chore: added lighthouse settings for preset

* chore: added lighthouse settings for preset

* chore: added lighthouse settings for preset

* chore: added lighthouse settings for dom size in performance

* chore: added categories

* chore: added lighthouse config

---------

Co-authored-by: Rajdeep Chandra <[email protected]>
  • Loading branch information
Rajdeepc and Rajdeep Chandra authored Feb 8, 2024
1 parent 4ff403e commit 80d2228
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/lighthouse/lighthouse-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
extends: 'lighthouse:default',
settings: {
onlyCategories: [
// Excluded categories do not currently pass
// "accessibility",
// "best-practices",
'performance',
// "pwa",
// "seo"
],
// Excluded audits do not currently pass
// metrics/first-contentful-paint', 'metrics/largest-contentful-paint','metrics/first-meaningful-paint', 'metrics/speed-index', 'screenshot-thumbnails',
// performance audits: https://github.com/GoogleChrome/lighthouse/blob/ed04b10ccfa4e82ee5cd5b437e474a12c1ba52d0/core/config/default-config.js#L178
onlyAudits: ['first-meaningful-paint', 'speed-index', 'interactive'],
},
};
9 changes: 9 additions & 0 deletions .github/lighthouse/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ci": {
"collect": {
"settings": {
"configPath": ".github/lighthouse/lighthouse-config.js"
}
}
}
}
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,47 @@ jobs:
});
}
});
lighthouse:
name: Lighthouse CI
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
ref: main

- uses: actions/checkout@v3

- name: Setup Node 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: yarn --frozen-lockfile

- name: Generate docs URL
id: docsURL
uses: actions/github-script@v6
with:
script: |
const { buildPreviewURLComment } = await import('${{ github.workspace }}/tasks/build-preview-urls-comment.js');
const body = buildPreviewURLComment(process.env.GITHUB_HEAD_REF);
const urlRegex = /(https?:\/\/[^\s]+)/g;
const docsURL = body.match(urlRegex)?.[0];
core.setOutput('docsURL', docsURL);
- name: Lighthouse CI Action
id: lighthouse
uses: treosh/lighthouse-ci-action@v11
with:
urls: |
${{ steps.docsURL.outputs.docsURL }}
configPath: '.github/lighthouse/lighthouserc.json'
uploadArtifacts: true
temporaryPublicStorage: true
compare-firefox:
name: Compare performance to latest release on Firefox

Expand Down

0 comments on commit 80d2228

Please sign in to comment.