From 9217da1f31d5a9b55b98946d405e1d5ee4cb1e72 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 19:36:07 -0600 Subject: [PATCH 1/7] Collect lighthouse CI on each frontend change --- .github/.lighthouserc.yml | 8 ++++++++ .github/workflows/ci_cd.yml | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/.lighthouserc.yml diff --git a/.github/.lighthouserc.yml b/.github/.lighthouserc.yml new file mode 100644 index 00000000000..5f9b690f762 --- /dev/null +++ b/.github/.lighthouserc.yml @@ -0,0 +1,8 @@ +ci: + collect: + url: + - http://127.0.0.1:8443/ + startServerCommand: "just p frontend start" + startServerReadyPattern: "Listening on http" + upload: + target: "temporary-public-storage" diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 6b091745e8e..3c220047068 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1014,6 +1014,33 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: ${{ steps.help-body.outputs.help_body }} + lighthouse-ci: + name: Collect Lighthouse CI results + runs-on: ubuntu-latest + # add back after testing + # needs: + # - nuxt-build + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup CI env + uses: ./.github/actions/setup-env + with: + setup_python: false + install_recipe: node-install + + - name: Run build + run: just frontend/run build + env: + DEPLOYMENT_ENV: production + + - name: Run Lighthouse CI + # Lighthouse CI runs the webserver for us, as configured in lighthouserc + run: | + pnpm --package=@lhci/cli dlx lhci autorun --config .github/.lighthouserc.yml + ################# # Documentation # ################# From 2782e15d4756e3e47ec9992c8f00b73774b4ef89 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 19:40:47 -0600 Subject: [PATCH 2/7] Fix substitution in recipe --- justfile | 1 + 1 file changed, 1 insertion(+) diff --git a/justfile b/justfile index 037ef385ab9..22a44214172 100644 --- a/justfile +++ b/justfile @@ -350,6 +350,7 @@ f: # alias for `pnpm --filter {package} run {script}` [positional-arguments] p package script *args: + #!/usr/bin/env bash pnpm --filter {{ package }} run {{ script }} "${@:3}" # Run eslint with --fix and default file selection enabled; used to enable easy file overriding whilst retaining the defaults when running --all-files From 7c5527de515573009e8c4e5cd2b9124f74af88d8 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 19:45:04 -0600 Subject: [PATCH 3/7] Add the token to the environment --- .github/workflows/ci_cd.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 3c220047068..4785fa19f8d 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1038,6 +1038,8 @@ jobs: - name: Run Lighthouse CI # Lighthouse CI runs the webserver for us, as configured in lighthouserc + env: + LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} run: | pnpm --package=@lhci/cli dlx lhci autorun --config .github/.lighthouserc.yml From 32de0dd61accaa5034a63245d4eac73f7c86d039 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 19:45:39 -0600 Subject: [PATCH 4/7] Only run if nuxt-build finished successfully --- .github/workflows/ci_cd.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 4785fa19f8d..5afe849d756 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1017,9 +1017,8 @@ jobs: lighthouse-ci: name: Collect Lighthouse CI results runs-on: ubuntu-latest - # add back after testing - # needs: - # - nuxt-build + needs: + - nuxt-build steps: - name: Checkout repository From 81b4b260482b8a35437d573fb66ae8b1232691c1 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 21:08:53 -0600 Subject: [PATCH 5/7] Upload LHCI artifacts --- .github/.lighthouserc.yml | 6 +++++- .github/workflows/ci_cd.yml | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/.lighthouserc.yml b/.github/.lighthouserc.yml index 5f9b690f762..461076cd837 100644 --- a/.github/.lighthouserc.yml +++ b/.github/.lighthouserc.yml @@ -5,4 +5,8 @@ ci: startServerCommand: "just p frontend start" startServerReadyPattern: "Listening on http" upload: - target: "temporary-public-storage" + # temporary target until either temporary-public-storage is back + # (https://github.com/GoogleChrome/lighthouse-ci/issues/1072) + # or we spin up our own Openverse lhci server + target: "filesystem" + outputDir: "/tmp/lhci" diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 5afe849d756..aa1af3e8ec4 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1037,11 +1037,15 @@ jobs: - name: Run Lighthouse CI # Lighthouse CI runs the webserver for us, as configured in lighthouserc - env: - LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} run: | pnpm --package=@lhci/cli dlx lhci autorun --config .github/.lighthouserc.yml + - name: Upload Lighthouse CI run artifacts + uses: actions/upload-artifact@v4 + with: + name: lhci + path: /tmp/lhci/ + ################# # Documentation # ################# From 494d524ac6bbe18b7d7ecc08fe60f5f66060fb18 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 21:40:54 -0600 Subject: [PATCH 6/7] Report lighthouse results in action --- .github/.lighthouserc.yml | 1 - .github/workflows/ci_cd.yml | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/.lighthouserc.yml b/.github/.lighthouserc.yml index 461076cd837..5a4b315c8de 100644 --- a/.github/.lighthouserc.yml +++ b/.github/.lighthouserc.yml @@ -9,4 +9,3 @@ ci: # (https://github.com/GoogleChrome/lighthouse-ci/issues/1072) # or we spin up our own Openverse lhci server target: "filesystem" - outputDir: "/tmp/lhci" diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index aa1af3e8ec4..40eecf85d1b 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1036,15 +1036,17 @@ jobs: DEPLOYMENT_ENV: production - name: Run Lighthouse CI + id: lhci-autorun # Lighthouse CI runs the webserver for us, as configured in lighthouserc run: | pnpm --package=@lhci/cli dlx lhci autorun --config .github/.lighthouserc.yml - - name: Upload Lighthouse CI run artifacts - uses: actions/upload-artifact@v4 + - name: Display Report + if: always() + uses: jackywithawhitedog/lighthouse-viewer-action@v2 with: - name: lhci - path: /tmp/lhci/ + resultsPath: .lighthouseci + lighthouseOutcome: ${{ steps.lhci-autorun.outcome }} ################# # Documentation # From 6471d9e5a1044724daaa1c060bab9d6d5739fdc6 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 21:50:05 -0600 Subject: [PATCH 7/7] Build and run with node_env production --- .github/workflows/ci_cd.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 40eecf85d1b..883492f4da8 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -1034,10 +1034,13 @@ jobs: run: just frontend/run build env: DEPLOYMENT_ENV: production + NODE_ENV: production - name: Run Lighthouse CI id: lhci-autorun # Lighthouse CI runs the webserver for us, as configured in lighthouserc + env: + NODE_ENV: production run: | pnpm --package=@lhci/cli dlx lhci autorun --config .github/.lighthouserc.yml