Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tommm2 committed Mar 26, 2024
1 parent aa627fb commit 974a9c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 59 deletions.
58 changes: 10 additions & 48 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,17 @@
name: Lighthouse

name: CI
on: [push]

defaults:
run:
# This ensures that the working directory is the root of the repository
working-directory: ./

jobs:
lighthouse-ci:
name: Lighthouse Report
lighthouseci:
runs-on: ubuntu-latest

steps:
- name: Capture Vercel Preview
uses: patrickedqvist/wait-for-vercel-preview@dca4940010f36d2d44caa487087a09b57939b24a # v1.3.1
id: vercel_preview_url
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 300
check_interval: 10

- name: Audit Preview URL with Lighthouse
# Conduct the lighthouse audit
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@1b0e7c33270fbba31a18a0fbb1de7cc5256b6d39 # v11.4.0
with:
# Defines the settings and assertions to audit
configPath: './.lighthouserc.json'
# These URLS capture critical pages / site functionality.
urls: |
${{ steps.vercel_preview_url.outputs.url }}/
${{ steps.vercel_preview_url.outputs.url }}/blog
${{ steps.vercel_preview_url.outputs.url }}/projects
${{ steps.vercel_preview_url.outputs.url }}/about
uploadArtifacts: true # save results as a action artifacts
temporaryPublicStorage: true # upload lighthouse report to the temporary storage

- name: Format Lighthouse Score
# Transform the audit results into a single, friendlier output
id: format_lighthouse_score
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
node-version: 18
- run: npm install && npm install -g @lhci/cli@0.13.x
- run: pnpm run build
- run: lhci collect
- run: lhci upload
env:
# using env as input to our script
# see https://github.com/actions/github-script#use-env-as-input
LIGHTHOUSE_RESULT: ${{ steps.lighthouse_audit.outputs.manifest }}
LIGHTHOUSE_LINKS: ${{ steps.lighthouse_audit.outputs.links }}
VERCEL_PREVIEW_URL: ${{ steps.vercel_preview_url.outputs.url }}
with:
# Run as a separate file so we do not have to inline all of our formatting logic.
# See https://github.com/actions/github-script#run-a-separate-file for more info.
script: |
const { formatLighthouseResults } = await import('${{github.workspace}}/scripts/lighthouse/index.mjs')
await formatLighthouseResults({core})
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
26 changes: 15 additions & 11 deletions lighthouserc.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
{
"ci": {
"collect": {
"numberOfRuns": 1,
"settings": {
"preset": "desktop"
}
"startServerCommand": "npm run start",
"startServerReadyPattern": "ready on",
"url": [
"http://localhost:3000"
],
"numberOfRuns": 1,
"settings": {
"preset": "desktop"
}
},
"assert": {
"assertions": {
"categories:performance": ["warn", { "minScore": 0.9 }],
"categories:accessibility": ["warn", { "minScore": 0.9 }],
"categories:best-practices": ["warn", { "minScore": 0.9 }],
"categories:seo": ["warn", { "minScore": 0.9 }]
}
}
"preset": "lighthouse:recommended"
},
"upload": {
"target": "temporary-public-storage"
},
"server": {}
}
}

0 comments on commit 974a9c4

Please sign in to comment.