Skip to content

Commit

Permalink
Merge pull request #306 from mazipan/mazipan-lh-cli
Browse files Browse the repository at this point in the history
feat: try lh ci to replace Netlify Plugin
  • Loading branch information
zainfathoni authored Jul 25, 2021
2 parents 7ee29d4 + d5b75b9 commit e53993b
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 9 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Lighthouse CI

on:
push:
branches: [main]
pull_request:
types: [labeled]

jobs:
lhci:
name: Run Lighthouse CI
runs-on: ubuntu-latest

if: ${{ !contains(github.event.pull_request.labels.*.names, 'need-perf-check') }}

steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: "14"

- name: Wait for the Netlify Preview
uses: jakepartusch/wait-for-netlify-action@v1
id: netlify
with:
site_name: 'wargabantuwarga'

- name: "Lighthouse CI assertion"
id: lhci
shell: bash
run: |
yarn global add @lhci/[email protected]
echo -e "\n"
echo "Start collecting LH report..."
lhci collect --url=${{ steps.netlify.outputs.url }} -n=1
echo -e "\n"
echo "Start asserting LH score..."
lhci assert --config=./lighthouserc.js
echo -e "\n"
echo "Start uploading the report..."
lhci upload --target "temporary-public-storage" --githubAppToken "$LHCI_GITHUB_APP_TOKEN" --githubToken "$GITHUB_TOKEN"
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions lighthouserc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
ci: {
assert: {
// preset: "lighthouse:no-pwa",
/* Note
// Read more assertions on:
// https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md#assert
*/
assertions: {
"categories:performance": ["error", { minScore: 0.5 }],
"categories:accessibility": ["error", { minScore: 0.9 }],
"categories:seo": ["warn", { minScore: 0.7 }],

// Core Web Vitals
"cumulative-layout-shift": ["warn", { minScore: 0.5 }],
"largest-contentful-paint": ["warn", { minScore: 0.25 }],
"total-blocking-time": ["warn", { minScore: 0.1 }],

// disable assertion
canonical: "off",
"crawlable-anchors": "off",
"csp-xss": "off",
interactive: "off",
"is-crawlable": "off",
"legacy-javascript": "off",
"mainthread-work-breakdown": "off",
"max-potential-fid": "off",
"no-vulnerable-libraries": "off",
"uses-rel-preload": "off",
"uses-rel-preconnect": "off",
"unused-css-rules": "off",
"unused-javascript": "off",
"tap-targets": ["warn", { minScore: 0.3 }],
"dom-size": ["warn", { minScore: 0.5 }],
},
},
},
};
18 changes: 9 additions & 9 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
command = "yarn netlify-export"
publish = "out"

[[plugins]]
package = "@netlify/plugin-lighthouse"
# [[plugins]]
# package = "@netlify/plugin-lighthouse"

[plugins.inputs.thresholds]
# [plugins.inputs.thresholds]
# TEMPORARY - bump back up to 0.72 once we get Netlify CMS running.
performance = 0.57
accessibility = 0.95
# performance = 0.57
# accessibility = 1
# TEMPORARY - bump back up to 0.93 once we get Netlify CMS running.
best-practices = 0.87
# best-practices = 0.87
# TEMPORARY - bump back up to 0.9 once we get Netlify CMS running.
seo = 0.83
# seo = 0.83

[plugins.inputs.audits]
output_path = "lighthouse.html"
# [plugins.inputs.audits]
# output_path = "lighthouse.html"

[[plugins]]
package = "@netlify/plugin-nextjs"
Expand Down

0 comments on commit e53993b

Please sign in to comment.