From c00f3fb0904a48150dcedd065f5a4c93559949dd Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 25 Jan 2025 11:01:23 +0530 Subject: [PATCH 1/2] chore: Add a command to execute visual test --- .github/workflows/e2e.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c5bbc6e627..70d3bfa94c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -7,6 +7,9 @@ on: - master - release/** pull_request: + issue_comment: + types: + - created merge_group: concurrency: ${{ github.workflow }}-${{ github.ref }} @@ -28,6 +31,9 @@ env: ) || github.event.before }} + # Check if this is a new comment with '/visual-test' + RUN_VISUAL_TEST: >- + ${{ github.event_name == 'issue_comment' && github.event.action == 'created' && contains(github.event.comment.body, '/visual-test') && github.event.issue.pull_request != null }} jobs: cache: runs-on: ubuntu-latest @@ -127,16 +133,17 @@ jobs: # e.g. if this action was run from a fork record: ${{ secrets.CYPRESS_RECORD_KEY != '' }} env: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - VITEST_COVERAGE: true + # 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 || '' }} + ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || '' }} CYPRESS_COMMIT: ${{ github.sha }} - ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} - ARGOS_PARALLEL: true - ARGOS_PARALLEL_TOTAL: ${{ strategy.job-total }} - ARGOS_PARALLEL_INDEX: ${{ matrix.containers }} + CYPRESS_RECORD_KEY: ${{ env.RUN_VISUAL_TEST == 'true' && secrets.CYPRESS_RECORD_KEY || ''}} SPLIT: ${{ strategy.job-total }} SPLIT_INDEX: ${{ strategy.job-index }} SPLIT_FILE: 'cypress/timings.json' + VITEST_COVERAGE: true - name: Upload Coverage to Codecov uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 From edc1ae1e0cb753b4d600e856ca56bf374d891300 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 25 Jan 2025 11:23:30 +0530 Subject: [PATCH 2/2] chore: Update default values --- .github/workflows/e2e.yml | 4 ++-- cypress.config.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 70d3bfa94c..6afc7549ed 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -136,8 +136,8 @@ jobs: # 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 || '' }} - ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || '' }} + ARGOS_PARALLEL_TOTAL: ${{ env.RUN_VISUAL_TEST == 'true' && strategy.job-total || 1 }} + ARGOS_PARALLEL_INDEX: ${{ env.RUN_VISUAL_TEST == 'true' && matrix.containers || 1 }} 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 b0257b9b2b..253e4b7ccc 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.CI && !!process.env.ARGOS_TOKEN; if (config.env.useArgos) { registerArgosTask(on, config, {