Skip to content

Commit

Permalink
feat: add lhci to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaireQianEpam committed Jan 15, 2024
1 parent 69a2e3d commit 6697348
Show file tree
Hide file tree
Showing 7 changed files with 2,848 additions and 118 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on: [push]
jobs:
lhci:
name: Lighthouse
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: npm install, build
run: |
npm install
npm run build
- name: run Lighthouse CI
run: |
npm install -g @lhci/cli@0.13.x
npm install -g puppeteer
lhci autorun
13 changes: 0 additions & 13 deletions .github/workflows/learn-github-actions.yml

This file was deleted.

44 changes: 44 additions & 0 deletions lighthouserc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module.exports = {
ci: {
collect: {
numberOfRuns: 3, //lighthouse run times to return html
startServerCommand: "npm run dev", //start a server
url: ["http://localhost:5173/"],
settings: {
onlyCategories: [
"performance",
"accessibility",
"best-practices",
"seo",
],
},
skipAudits: ["redirects-http", "uses-http2"],
puppeteerScript: "./puppeteer-script.cjs",
},
assert: {
//fail the build based on the audit results
// preset: "lighthouse:recommended", // 包含的东西太多
assertions: {
"categories:performance": [
"error",
{ minScore: 0.9, aggregationMethod: "median" },
], //定义不同的数据等级
"categories:accessibility": [
"error",
{ minScore: 0.9, aggregationMethod: "pessimistic" },
],
"categories:best-practices": [
"error",
{ minScore: 0.9, aggregationMethod: "pessimistic" },
],
"categories:seo": [
"error",
{ minScore: 0.9, aggregationMethod: "pessimistic" },
],
},
},
upload: {
target: "temporary-public-storage", //什么意思?
},
},
};
Loading

0 comments on commit 6697348

Please sign in to comment.