From d43b9c6adac30727464854a916dcd147c6cc7e28 Mon Sep 17 00:00:00 2001 From: annarhughes Date: Tue, 5 Dec 2023 10:48:15 +0000 Subject: [PATCH] add lighthouse action --- .github/configs/lighthouse-desktop-rc.yml | 4 ++ .github/workflows/lighthouse-performance.yml | 74 ++++++++++++++++++++ lighthouse_budget.json | 45 ++++++++++++ lighthouse_desktop_budget.json | 45 ++++++++++++ 4 files changed, 168 insertions(+) create mode 100644 .github/configs/lighthouse-desktop-rc.yml create mode 100644 .github/workflows/lighthouse-performance.yml create mode 100644 lighthouse_budget.json create mode 100644 lighthouse_desktop_budget.json diff --git a/.github/configs/lighthouse-desktop-rc.yml b/.github/configs/lighthouse-desktop-rc.yml new file mode 100644 index 00000000..855d1190 --- /dev/null +++ b/.github/configs/lighthouse-desktop-rc.yml @@ -0,0 +1,4 @@ +ci: + collect: + settings: + emulatedFormFactor: desktop diff --git a/.github/workflows/lighthouse-performance.yml b/.github/workflows/lighthouse-performance.yml new file mode 100644 index 00000000..c99320fb --- /dev/null +++ b/.github/workflows/lighthouse-performance.yml @@ -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/wait-for-vercel-preview@v1.3.1 + 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 + diff --git a/lighthouse_budget.json b/lighthouse_budget.json new file mode 100644 index 00000000..d0851cfa --- /dev/null +++ b/lighthouse_budget.json @@ -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 + } + ] + } +] diff --git a/lighthouse_desktop_budget.json b/lighthouse_desktop_budget.json new file mode 100644 index 00000000..149e9050 --- /dev/null +++ b/lighthouse_desktop_budget.json @@ -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 + } + ] + } +]