Skip to content

Commit

Permalink
add lighthouse action
Browse files Browse the repository at this point in the history
  • Loading branch information
annarhughes committed Dec 5, 2023
1 parent 5454f0c commit d43b9c6
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/configs/lighthouse-desktop-rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ci:
collect:
settings:
emulatedFormFactor: desktop
74 changes: 74 additions & 0 deletions .github/workflows/lighthouse-performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lighthouse Performance

on:
pull_request:
branches: [develop, main]

jobs:
# vercel will deploy a preview branch and domain for this PR
# wait for new deployment to complete before running lighthouse
wait-for-vercel-deployment:
name: Wait for vercel deployment
runs-on: ubuntu-latest
outputs:
preview_url: ${{ steps.waitForVercelDeployment.outputs.url }}
steps:
- name: Wait for Vercel preview deployment to be ready
uses: patrickedqvist/[email protected]
id: waitForVercelDeployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
max_timeout: 1000
check_interval: 5

lighthouse-mobile:
runs-on: ubuntu-latest
needs: wait-for-vercel-deployment
steps:
- uses: actions/checkout@v3
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/activities
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/chat
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/grounding
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/notes
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/therapy
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/image-based-abuse-and-rebuilding-ourselves
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/dating-boundaries-and-relationships
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/recovering-from-toxic-and-abusive-relationships
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/image-based-abuse-and-rebuilding-ourselves/the-social-context-of-image-based-abuse-and-victim-blaming
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/dating-boundaries-and-relationships/emotional-boundaries
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/recovering-from-toxic-and-abusive-relationships/introduction-and-what-you-should-know
budgetPath: ./lighthouse_budget.json # test performance budgets
uploadArtifacts: true # save results as an action artifacts

lighthouse-desktop:
runs-on: ubuntu-latest
needs: wait-for-vercel-deployment
steps:
- uses: actions/checkout@v3
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/activities
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/chat
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/grounding
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/notes
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/therapy
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/image-based-abuse-and-rebuilding-ourselves
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/dating-boundaries-and-relationships
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/recovering-from-toxic-and-abusive-relationships
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/image-based-abuse-and-rebuilding-ourselves/the-social-context-of-image-based-abuse-and-victim-blaming
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/dating-boundaries-and-relationships/emotional-boundaries
${{ needs.wait-for-vercel-deployment.outputs.preview_url }}/courses/recovering-from-toxic-and-abusive-relationships/introduction-and-what-you-should-know
budgetPath: ./lighthouse_desktop_budget.json # test performance budgets
uploadArtifacts: true # save results as an action artifacts
configPath: '.github/configs/lighthouse-desktop-rc.yml' # set lighthouse config

45 changes: 45 additions & 0 deletions lighthouse_budget.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"path": "/*",
"resourceSizes": [
{
"resourceType": "document",
"budget": 18
},
{
"resourceType": "total",
"budget": 200
},
{
"resourceType": "script",
"budget": 150
}
],
"timings": [
{
"metric": "first-meaningful-paint",
"budget": 2000
},
{
"metric": "first-contentful-paint",
"budget": 1800
},
{
"metric": "largest-contentful-paint",
"budget": 10000
},
{
"metric": "interactive",
"budget": 4000
},
{
"metric": "total-blocking-time",
"budget": 2500
},
{
"metric": "speed-index",
"budget": 3000
}
]
}
]
45 changes: 45 additions & 0 deletions lighthouse_desktop_budget.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"path": "/*",
"resourceSizes": [
{
"resourceType": "document",
"budget": 18
},
{
"resourceType": "total",
"budget": 200
},
{
"resourceType": "script",
"budget": 150
}
],
"timings": [
{
"metric": "first-meaningful-paint",
"budget": 2000
},
{
"metric": "first-contentful-paint",
"budget": 600
},
{
"metric": "largest-contentful-paint",
"budget": 4000
},
{
"metric": "interactive",
"budget": 2000
},
{
"metric": "total-blocking-time",
"budget": 500
},
{
"metric": "speed-index",
"budget": 2000
}
]
}
]

0 comments on commit d43b9c6

Please sign in to comment.