From 159a724804413a3c0a0085a9e1a83fb1e9534013 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:14:57 +0100 Subject: [PATCH 01/17] Add lighthouse ci action --- .github/workflows/lighthouse-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/lighthouse-ci.yml diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml new file mode 100644 index 00000000000..7532c1829c9 --- /dev/null +++ b/.github/workflows/lighthouse-ci.yml @@ -0,0 +1,15 @@ +name: Lighthouse CI +on: push +jobs: + lighthouse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Audit URLs using Lighthouse + uses: treosh/lighthouse-ci-action@v11 + with: + urls: | + https://ethereum.org/en/ + budgetPath: ./budget.json # test performance budgets + uploadArtifacts: true # save results as an action artifacts + temporaryPublicStorage: true # upload lighthouse report to the temporary storage From eb690d21d9c8bb88e6e082feae1f285d4f1df384 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:17:52 +0100 Subject: [PATCH 02/17] Remove budget and add multiple runs --- .github/workflows/lighthouse-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 7532c1829c9..53adf85f80b 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -8,8 +8,7 @@ jobs: - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v11 with: - urls: | - https://ethereum.org/en/ - budgetPath: ./budget.json # test performance budgets + urls: "https://ethereum.org/en/" + runs: 3 # run three times uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 403959e4906de8a98eb876b693d0729c93dc4276 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Thu, 25 Apr 2024 15:24:27 +0200 Subject: [PATCH 03/17] add more pages + use wait-for-netlify-action to integrate with the preview deploys --- .github/workflows/lighthouse-ci.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 53adf85f80b..0f523647cf6 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -1,14 +1,37 @@ name: Lighthouse CI -on: push + +on: + push: + branches: + - master + - staging + - performance/** + - testlighthouseci # tmp - just to test the workflow in the current branch + jobs: lighthouse: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 + - name: Wait for Netlify Deploy + uses: probablyup/wait-for-netlify-action@3.2.0 + id: waitForDeployment + with: + site_id: "e8f2e766-888b-4954-8500-1b647d84db99" + env: + NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} - name: Audit URLs using Lighthouse uses: treosh/lighthouse-ci-action@v11 with: - urls: "https://ethereum.org/en/" + urls: | + ${{ steps.netlify.outputs.url }}/en/ + ${{ steps.netlify.outputs.url }}/en/wallets/find-wallet/ + ${{ steps.netlify.outputs.url }}/en/staking/ + ${{ steps.netlify.outputs.url }}/en/whitepaper/ + ${{ steps.netlify.outputs.url }}/en/nft/ + ${{ steps.netlify.outputs.url }}/en/developers/docs/intro-to-ethereum/ + ${{ steps.netlify.outputs.url }}/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ runs: 3 # run three times uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 95f4a2c22c84a0060c0b2a249c96882b29670b0d Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:58:35 +0100 Subject: [PATCH 04/17] Test max timeout 90 minute timeout on preview deploy --- .github/workflows/lighthouse-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 0f523647cf6..36f74fb9625 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -19,6 +19,7 @@ jobs: id: waitForDeployment with: site_id: "e8f2e766-888b-4954-8500-1b647d84db99" + max_timeout: 5400 env: NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} - name: Audit URLs using Lighthouse From 4ec60d2cc9ccf68ea3c107121b59f1b348dc1296 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:28:34 +0100 Subject: [PATCH 05/17] Test sleeping before waiting for Netlify --- .github/workflows/lighthouse-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 36f74fb9625..94fccaaab14 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -13,7 +13,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Sleep for 45 minutes + run: sleep 2700 - name: Wait for Netlify Deploy uses: probablyup/wait-for-netlify-action@3.2.0 id: waitForDeployment From bdd9b7edd7f562e4f46d3ad39da713c3805bd49a Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:03:48 +0100 Subject: [PATCH 06/17] Fix typo --- .github/workflows/lighthouse-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 94fccaaab14..e5931ca1b44 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -13,6 +13,7 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Sleep for 45 minutes run: sleep 2700 - name: Wait for Netlify Deploy From 62c3ba1e9ca9d3fff8234a825859f6146ad25d54 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:59:58 +0100 Subject: [PATCH 07/17] Adjust sleep and timeout timing --- .github/workflows/lighthouse-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index e5931ca1b44..1408a0c9b15 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -14,14 +14,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Sleep for 45 minutes - run: sleep 2700 + - name: Sleep for 60 minutes + run: sleep 3600 - name: Wait for Netlify Deploy uses: probablyup/wait-for-netlify-action@3.2.0 id: waitForDeployment with: site_id: "e8f2e766-888b-4954-8500-1b647d84db99" - max_timeout: 5400 + max_timeout: 900 env: NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} - name: Audit URLs using Lighthouse From a1da1516edb0e1ce5afd28a78a7df57b36e7e2fd Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Fri, 26 Apr 2024 19:22:28 +0100 Subject: [PATCH 08/17] Update .github/workflows/lighthouse-ci.yml --- .github/workflows/lighthouse-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 1408a0c9b15..1af25497aff 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -28,13 +28,13 @@ jobs: uses: treosh/lighthouse-ci-action@v11 with: urls: | - ${{ steps.netlify.outputs.url }}/en/ - ${{ steps.netlify.outputs.url }}/en/wallets/find-wallet/ - ${{ steps.netlify.outputs.url }}/en/staking/ - ${{ steps.netlify.outputs.url }}/en/whitepaper/ - ${{ steps.netlify.outputs.url }}/en/nft/ - ${{ steps.netlify.outputs.url }}/en/developers/docs/intro-to-ethereum/ - ${{ steps.netlify.outputs.url }}/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ + ${{ steps.waitForDeployment.outputs.url }}/en/ + ${{ steps.waitForDeployment.outputs.url }}/en/wallets/find-wallet/ + ${{ steps.waitForDeployment.outputs.url }}/en/staking/ + ${{ steps.waitForDeployment.outputs.url }}/en/whitepaper/ + ${{ steps.waitForDeployment.outputs.url }}/en/nft/ + ${{ steps.waitForDeployment.outputs.url }}/en/developers/docs/intro-to-ethereum/ + ${{ steps.waitForDeployment.outputs.url }}/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ runs: 3 # run three times uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage From 33f1c56b8c642eeff004039ca76c191fa6643a9f Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Tue, 30 Apr 2024 13:46:43 +0200 Subject: [PATCH 09/17] add new steps to write a comment with the main scores --- .github/workflows/lighthouse-ci.yml | 50 ++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 1af25497aff..c5a87af6396 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -17,24 +17,58 @@ jobs: - name: Sleep for 60 minutes run: sleep 3600 - name: Wait for Netlify Deploy + id: netlify_deploy uses: probablyup/wait-for-netlify-action@3.2.0 - id: waitForDeployment with: site_id: "e8f2e766-888b-4954-8500-1b647d84db99" max_timeout: 900 env: NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} - name: Audit URLs using Lighthouse + id: lighthouse_audit uses: treosh/lighthouse-ci-action@v11 with: urls: | - ${{ steps.waitForDeployment.outputs.url }}/en/ - ${{ steps.waitForDeployment.outputs.url }}/en/wallets/find-wallet/ - ${{ steps.waitForDeployment.outputs.url }}/en/staking/ - ${{ steps.waitForDeployment.outputs.url }}/en/whitepaper/ - ${{ steps.waitForDeployment.outputs.url }}/en/nft/ - ${{ steps.waitForDeployment.outputs.url }}/en/developers/docs/intro-to-ethereum/ - ${{ steps.waitForDeployment.outputs.url }}/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ + ${{ steps.netlify_deploy.outputs.url }}/en/ + ${{ steps.netlify_deploy.outputs.url }}/en/wallets/find-wallet/ + ${{ steps.netlify_deploy.outputs.url }}/en/staking/ + ${{ steps.netlify_deploy.outputs.url }}/en/whitepaper/ + ${{ steps.netlify_deploy.outputs.url }}/en/nft/ + ${{ steps.netlify_deploy.outputs.url }}/en/developers/docs/intro-to-ethereum/ + ${{ steps.netlify_deploy.outputs.url }}/en/developers/tutorials/creating-a-wagmi-ui-for-your-contract/ runs: 3 # run three times uploadArtifacts: true # save results as an action artifacts temporaryPublicStorage: true # upload lighthouse report to the temporary storage + - name: Format lighthouse score + id: format_lighthouse_score + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary + const links = ${{ steps.lighthouse_audit.outputs.links }} + const formatResult = (res) => Math.round((res * 100)) + Object.keys(result).forEach(key => result[key] = formatResult(result[key])) + const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴' + const comment = [ + `⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`, + '| Category | Score |', + '| --- | --- |', + `| ${score(result.performance)} Performance | ${result.performance} |`, + `| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`, + `| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`, + `| ${score(result.seo)} SEO | ${result.seo} |`, + `| ${score(result.pwa)} PWA | ${result.pwa} |`, + ' ', + `*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*` + ].join('\n') + core.setOutput("comment", comment); + + - name: Add Lighthouse stats as comment + id: comment_to_pr + uses: marocchino/sticky-pull-request-comment@v2.0.0 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + number: ${{ github.event.pull_request.number }} + header: lighthouse + message: ${{ steps.format_lighthouse_score.outputs.comment }} From 686842144d83c32a8a1746c303bbff14489fc113 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Tue, 30 Apr 2024 15:36:58 +0200 Subject: [PATCH 10/17] find current PR associated with the push event --- .github/workflows/lighthouse-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index c5a87af6396..3771c03603a 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -63,12 +63,16 @@ jobs: `*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*` ].join('\n') core.setOutput("comment", comment); - + - name: Find current PR # Find the PR associated with this push, if there is one. + uses: jwalton/gh-find-current-pr@v1.3.3 + id: findPr + with: + state: open - name: Add Lighthouse stats as comment id: comment_to_pr uses: marocchino/sticky-pull-request-comment@v2.0.0 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - number: ${{ github.event.pull_request.number }} + number: ${{ steps.findPr.outputs.number }} header: lighthouse message: ${{ steps.format_lighthouse_score.outputs.comment }} From 8f26b0c654b54055048632e7382f866b13ae1fe5 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Tue, 30 Apr 2024 15:51:40 +0200 Subject: [PATCH 11/17] add write pr permissions --- .github/workflows/lighthouse-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 3771c03603a..c085dbf62f6 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -12,6 +12,9 @@ jobs: lighthouse: runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: - uses: actions/checkout@v4 - name: Sleep for 60 minutes From 2daa6dc2bd04130b3d5a12c10aea0a42b5560f8f Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Wed, 1 May 2024 09:38:53 +0100 Subject: [PATCH 12/17] Update lighthouse-ci.yml --- .github/workflows/lighthouse-ci.yml | 33 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index c085dbf62f6..a6b3785e24a 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -53,19 +53,26 @@ jobs: const formatResult = (res) => Math.round((res * 100)) Object.keys(result).forEach(key => result[key] = formatResult(result[key])) const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴' - const comment = [ - `⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`, - '| Category | Score |', - '| --- | --- |', - `| ${score(result.performance)} Performance | ${result.performance} |`, - `| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`, - `| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`, - `| ${score(result.seo)} SEO | ${result.seo} |`, - `| ${score(result.pwa)} PWA | ${result.pwa} |`, - ' ', - `*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*` - ].join('\n') - core.setOutput("comment", comment); + + let comment = [ + '| Page | Performance | Accessibility | Best practices | SEO | PWA |', + '| --- | --- | --- | --- | --- | --- |', + ] + + Object.values(links).forEach(link => { + comment.push( + `| [Link](${link}) | ${score(result.performance)} ${result.performance} | ${score(result.accessibility)} ${result.accessibility} | ${score(result['best-practices'])} ${result['best-practices']} | ${score(result.seo)} ${result.seo} | ${score(result.pwa)} ${result.pwa} |` + ) + }); + + comment.push( + ' ', + '*Lighthouse scores are calculated based on the latest audit results*' + ); + + // Join all parts of the comment into a single string + comment = comment.join('\n') + core.setOutput("comment", comment); - name: Find current PR # Find the PR associated with this push, if there is one. uses: jwalton/gh-find-current-pr@v1.3.3 id: findPr From da09fae7b221299a32c6eba32e113c48e119303d Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Wed, 1 May 2024 11:22:01 +0100 Subject: [PATCH 13/17] Update lighthouse-ci.yml --- .github/workflows/lighthouse-ci.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index a6b3785e24a..58f8b2d2c43 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -48,21 +48,29 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary - const links = ${{ steps.lighthouse_audit.outputs.links }} - const formatResult = (res) => Math.round((res * 100)) - Object.keys(result).forEach(key => result[key] = formatResult(result[key])) - const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴' - + const manifests = ${{ steps.lighthouse_audit.outputs.manifest }}; + const links = ${{ steps.lighthouse_audit.outputs.links }}; + const formatResult = (res) => Math.round((res * 100)); + + + console.log('Total manifests', manifests.length); + console.log('Total links', links.length); + console.log('Manifests:', JSON.stringify(manifests, null, 2)); + let comment = [ '| Page | Performance | Accessibility | Best practices | SEO | PWA |', '| --- | --- | --- | --- | --- | --- |', - ] + ]; - Object.values(links).forEach(link => { + // Assuming links and manifests are aligned in order + links.forEach((link, index) => { + const result = manifests[index].summary; + Object.keys(result).forEach(key => result[key] = formatResult(result[key])); + const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; + comment.push( `| [Link](${link}) | ${score(result.performance)} ${result.performance} | ${score(result.accessibility)} ${result.accessibility} | ${score(result['best-practices'])} ${result['best-practices']} | ${score(result.seo)} ${result.seo} | ${score(result.pwa)} ${result.pwa} |` - ) + ); }); comment.push( @@ -70,8 +78,7 @@ jobs: '*Lighthouse scores are calculated based on the latest audit results*' ); - // Join all parts of the comment into a single string - comment = comment.join('\n') + comment = comment.join('\n'); core.setOutput("comment", comment); - name: Find current PR # Find the PR associated with this push, if there is one. uses: jwalton/gh-find-current-pr@v1.3.3 From e2362445f7d88d39f4856189d4083056c750ccff Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Wed, 1 May 2024 11:37:43 +0100 Subject: [PATCH 14/17] account for async lighthouse --- .github/workflows/lighthouse-ci.yml | 44 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 58f8b2d2c43..b33484f51c6 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -51,33 +51,43 @@ jobs: const manifests = ${{ steps.lighthouse_audit.outputs.manifest }}; const links = ${{ steps.lighthouse_audit.outputs.links }}; const formatResult = (res) => Math.round((res * 100)); - - - console.log('Total manifests', manifests.length); - console.log('Total links', links.length); + + console.log('Total manifests:', manifests.length); + console.log('Total links:', links.length); console.log('Manifests:', JSON.stringify(manifests, null, 2)); - + let comment = [ '| Page | Performance | Accessibility | Best practices | SEO | PWA |', '| --- | --- | --- | --- | --- | --- |', ]; - - // Assuming links and manifests are aligned in order - links.forEach((link, index) => { - const result = manifests[index].summary; - Object.keys(result).forEach(key => result[key] = formatResult(result[key])); - const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; - - comment.push( - `| [Link](${link}) | ${score(result.performance)} ${result.performance} | ${score(result.accessibility)} ${result.accessibility} | ${score(result['best-practices'])} ${result['best-practices']} | ${score(result.seo)} ${result.seo} | ${score(result.pwa)} ${result.pwa} |` - ); + + links.forEach(link => { + const relevantManifests = manifests.filter(manifest => manifest.url === link); + const results = relevantManifests.map(manifest => manifest.summary); + const averagedResults = {}; + + if (results.length > 0) { + Object.keys(results[0]).forEach(key => { + averagedResults[key] = formatResult( + results.reduce((acc, cur) => acc + cur[key], 0) / results.length + ); + }); + + const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; + + comment.push( + `| [Link](${link}) | ${score(averagedResults.performance)} ${averagedResults.performance} | ${score(averagedResults.accessibility)} ${averagedResults.accessibility} | ${score(averagedResults['best-practices'])} ${averagedResults['best-practices']} | ${score(averagedResults.seo)} ${averagedResults.seo} | ${score(averagedResults.pwa)} ${averagedResults.pwa} |` + ); + } else { + console.error('No results found for URL:', link); + } }); - + comment.push( ' ', '*Lighthouse scores are calculated based on the latest audit results*' ); - + comment = comment.join('\n'); core.setOutput("comment", comment); - name: Find current PR # Find the PR associated with this push, if there is one. From f2d5882bb49c03306ac3cf747a14c1612c7f8e71 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Wed, 1 May 2024 13:00:41 +0100 Subject: [PATCH 15/17] treat links as an object not an array --- .github/workflows/lighthouse-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index b33484f51c6..98f6e4c2b26 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -53,15 +53,15 @@ jobs: const formatResult = (res) => Math.round((res * 100)); console.log('Total manifests:', manifests.length); - console.log('Total links:', links.length); console.log('Manifests:', JSON.stringify(manifests, null, 2)); + console.log('Links:', JSON.stringify(links, null, 2)); let comment = [ '| Page | Performance | Accessibility | Best practices | SEO | PWA |', '| --- | --- | --- | --- | --- | --- |', ]; - - links.forEach(link => { + + Object.values(links).forEach(link => { const relevantManifests = manifests.filter(manifest => manifest.url === link); const results = relevantManifests.map(manifest => manifest.summary); const averagedResults = {}; From ac6892cc459e8ecd4ebd4be78b93535775a1f7f3 Mon Sep 17 00:00:00 2001 From: Joshua <62268199+minimalsm@users.noreply.github.com> Date: Wed, 1 May 2024 15:03:45 +0100 Subject: [PATCH 16/17] use object key for links + table formatting --- .github/workflows/lighthouse-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index 98f6e4c2b26..d669d62382c 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -61,25 +61,26 @@ jobs: '| --- | --- | --- | --- | --- | --- |', ]; - Object.values(links).forEach(link => { - const relevantManifests = manifests.filter(manifest => manifest.url === link); + Object.entries(links).forEach(([pageUrl, reportUrl]) => { + const relevantManifests = manifests.filter(manifest => manifest.url === pageUrl); const results = relevantManifests.map(manifest => manifest.summary); const averagedResults = {}; - + if (results.length > 0) { Object.keys(results[0]).forEach(key => { averagedResults[key] = formatResult( results.reduce((acc, cur) => acc + cur[key], 0) / results.length ); }); - + const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'; - + const urlForTable = pageUrl.includes('/en/') ? pageUrl.substring(pageUrl.indexOf('/en/')) : pageUrl; + comment.push( - `| [Link](${link}) | ${score(averagedResults.performance)} ${averagedResults.performance} | ${score(averagedResults.accessibility)} ${averagedResults.accessibility} | ${score(averagedResults['best-practices'])} ${averagedResults['best-practices']} | ${score(averagedResults.seo)} ${averagedResults.seo} | ${score(averagedResults.pwa)} ${averagedResults.pwa} |` + `| [${urlForTable}](${reportUrl}) | ${score(averagedResults.performance)} ${averagedResults.performance} | ${score(averagedResults.accessibility)} ${averagedResults.accessibility} | ${score(averagedResults['best-practices'])} ${averagedResults['best-practices']} | ${score(averagedResults.seo)} ${averagedResults.seo} | ${score(averagedResults.pwa)} ${averagedResults.pwa} |` ); } else { - console.error('No results found for URL:', link); + console.error('No results found for URL:', pageUrl); } }); From ee4b63ed0b6db2cfbedeb9b686ed0b77f9c6cee6 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Wed, 1 May 2024 19:28:07 +0200 Subject: [PATCH 17/17] Update .github/workflows/lighthouse-ci.yml --- .github/workflows/lighthouse-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lighthouse-ci.yml b/.github/workflows/lighthouse-ci.yml index d669d62382c..a217347d9b6 100644 --- a/.github/workflows/lighthouse-ci.yml +++ b/.github/workflows/lighthouse-ci.yml @@ -6,7 +6,6 @@ on: - master - staging - performance/** - - testlighthouseci # tmp - just to test the workflow in the current branch jobs: lighthouse: