From ada42b892c0dc993eae560bc770e702c6f46528c Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 14 Feb 2025 21:41:53 +0530 Subject: [PATCH 1/5] Ignore huehive --- .github/lychee.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/lychee.toml b/.github/lychee.toml index 288ab054a..5070c3d50 100644 --- a/.github/lychee.toml +++ b/.github/lychee.toml @@ -47,7 +47,10 @@ exclude = [ "https://(www.)?drupal.org", # Swimm returns 404, eventhough the link is valid -"https://docs.swimm.io" +"https://docs.swimm.io", + +# Timeout +"https://huehive.co" ] # Exclude all private IPs from checking. From c5843bee239c04cce98e1d59897b50fec31c9507 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 15 Feb 2025 20:07:41 +0530 Subject: [PATCH 2/5] chore: Update argos token We have added a check in e2e, to ensure events in forks will not trigger the visual tests. This will not protect against malicious users, but there is no other way to support PRs from forks. A proposal has been sent to Argos team to add a secure approach for public repos, fingers crossed. --- .github/workflows/e2e.yml | 2 +- cypress.config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7aa73a5db..b4f75a817 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -29,7 +29,7 @@ env: github.event.before }} RUN_VISUAL_TEST: >- - ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} + ${{ github.repository == 'mermaid-js/mermaid' && (github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/')) }} jobs: cache: runs-on: ubuntu-latest diff --git a/cypress.config.ts b/cypress.config.ts index 253e4b7cc..d6f83fb20 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -27,7 +27,7 @@ export default eyesPlugin( if (config.env.useArgos) { registerArgosTask(on, config, { - token: 'fc3a35cf5200db928d65b2047861582d9444032b', + token: 'argos_cde7ec66b3c53730a7bbe4059a517f4a76', }); } else { addMatchImageSnapshotPlugin(on, config); From 3b92f979e3b5807edac37e0134d95bcd8998a0e8 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 15 Feb 2025 20:28:55 +0530 Subject: [PATCH 3/5] chore: Add tokenless auth to argos --- .github/workflows/e2e.yml | 3 +++ cypress.config.ts | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b4f75a817..e035ac710 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -134,6 +134,9 @@ jobs: ARGOS_PARALLEL: ${{ env.RUN_VISUAL_TEST == 'true' }} ARGOS_PARALLEL_TOTAL: ${{ env.RUN_VISUAL_TEST == 'true' && strategy.job-total || 1 }} ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || 1 }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_JOB: ${{ github.job }} + GITHUB_RUN_ID: ${{ github.run_id }} CYPRESS_COMMIT: ${{ github.sha }} CYPRESS_RECORD_KEY: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.CYPRESS_RECORD_KEY || ''}} SPLIT: ${{ strategy.job-total }} diff --git a/cypress.config.ts b/cypress.config.ts index d6f83fb20..247a21881 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -5,6 +5,14 @@ import { defineConfig } from 'cypress'; import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin'; import cypressSplit from 'cypress-split'; +const encodeArgosToken = (options: { + owner: string; + repository: string; + jobId: string; + runId: string; +}) => `tokenless-github-${Buffer.from(JSON.stringify(options), 'utf8').toString('base64')}`; +// cspell:ignore tokenless + export default eyesPlugin( defineConfig({ projectId: 'n2sma2', @@ -26,8 +34,22 @@ export default eyesPlugin( config.env.useArgos = !!process.env.CI && !!process.env.ARGOS_TOKEN; if (config.env.useArgos) { + if (!process.env.GITHUB_REPOSITORY) { + throw new Error('GITHUB_REPOSITORY is not set'); + } + if (!process.env.GITHUB_JOB) { + throw new Error('GITHUB_JOB is not set'); + } + if (!process.env.GITHUB_RUN_ID) { + throw new Error('GITHUB_RUN_ID is not set'); + } registerArgosTask(on, config, { - token: 'argos_cde7ec66b3c53730a7bbe4059a517f4a76', + token: encodeArgosToken({ + owner: process.env.GITHUB_REPOSITORY.split('/')[0], + repository: process.env.GITHUB_REPOSITORY.split('/')[1], + jobId: process.env.GITHUB_JOB, + runId: process.env.GITHUB_RUN_ID, + }), }); } else { addMatchImageSnapshotPlugin(on, config); From 57805dafa4c86717c422e3f08402a3fac4ccad5e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 15 Feb 2025 20:51:56 +0530 Subject: [PATCH 4/5] chore: Use argos tokenless auth --- .github/workflows/e2e.yml | 5 ----- cypress.config.ts | 28 ++-------------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e035ac710..1c0c6bbe0 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -129,14 +129,9 @@ jobs: # e.g. if this action was run from a fork record: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.CYPRESS_RECORD_KEY != '' }} env: - # Only set Argos environment variables if the visual test comment trigger is present - ARGOS_TOKEN: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.ARGOS_TOKEN || '' }} ARGOS_PARALLEL: ${{ env.RUN_VISUAL_TEST == 'true' }} ARGOS_PARALLEL_TOTAL: ${{ env.RUN_VISUAL_TEST == 'true' && strategy.job-total || 1 }} ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || 1 }} - GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_JOB: ${{ github.job }} - GITHUB_RUN_ID: ${{ github.run_id }} CYPRESS_COMMIT: ${{ github.sha }} CYPRESS_RECORD_KEY: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.CYPRESS_RECORD_KEY || ''}} SPLIT: ${{ strategy.job-total }} diff --git a/cypress.config.ts b/cypress.config.ts index 247a21881..2adb52817 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -5,14 +5,6 @@ import { defineConfig } from 'cypress'; import { addMatchImageSnapshotPlugin } from 'cypress-image-snapshot/plugin'; import cypressSplit from 'cypress-split'; -const encodeArgosToken = (options: { - owner: string; - repository: string; - jobId: string; - runId: string; -}) => `tokenless-github-${Buffer.from(JSON.stringify(options), 'utf8').toString('base64')}`; -// cspell:ignore tokenless - export default eyesPlugin( defineConfig({ projectId: 'n2sma2', @@ -31,26 +23,10 @@ export default eyesPlugin( }); // copy any needed variables from process.env to config.env config.env.useAppli = process.env.USE_APPLI ? true : false; - config.env.useArgos = !!process.env.CI && !!process.env.ARGOS_TOKEN; + config.env.useArgos = !!process.env.CI; if (config.env.useArgos) { - if (!process.env.GITHUB_REPOSITORY) { - throw new Error('GITHUB_REPOSITORY is not set'); - } - if (!process.env.GITHUB_JOB) { - throw new Error('GITHUB_JOB is not set'); - } - if (!process.env.GITHUB_RUN_ID) { - throw new Error('GITHUB_RUN_ID is not set'); - } - registerArgosTask(on, config, { - token: encodeArgosToken({ - owner: process.env.GITHUB_REPOSITORY.split('/')[0], - repository: process.env.GITHUB_REPOSITORY.split('/')[1], - jobId: process.env.GITHUB_JOB, - runId: process.env.GITHUB_RUN_ID, - }), - }); + registerArgosTask(on, config); } else { addMatchImageSnapshotPlugin(on, config); } From f6592235a23a3bc588d5d558ace2ae4a8fe93378 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 15 Feb 2025 21:05:47 +0530 Subject: [PATCH 5/5] chore: Use RUN_VISUAL_TEST in cypress config --- cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.ts b/cypress.config.ts index 2adb52817..d077ba915 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -23,7 +23,7 @@ export default eyesPlugin( }); // copy any needed variables from process.env to config.env config.env.useAppli = process.env.USE_APPLI ? true : false; - config.env.useArgos = !!process.env.CI; + config.env.useArgos = process.env.RUN_VISUAL_TEST === 'true'; if (config.env.useArgos) { registerArgosTask(on, config);