From 595ea881ab99ab577cc68aac27ff78a2092fb660 Mon Sep 17 00:00:00 2001 From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:02:37 +0200 Subject: [PATCH] Move browser-related Cypress prep steps to a composite action (#34642) * Move browser-related Cypress prep steps to a composite action * Fix browser paths --- .github/actions/prepare-cypress/action.yml | 31 +++++++++++++ .../workflows/e2e-stress-test-flake-fix.yml | 12 +---- .github/workflows/e2e-tests.yml | 45 ++++++------------- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/.github/actions/prepare-cypress/action.yml b/.github/actions/prepare-cypress/action.yml index bad99010c45..4357a5005ab 100644 --- a/.github/actions/prepare-cypress/action.yml +++ b/.github/actions/prepare-cypress/action.yml @@ -1,7 +1,38 @@ name: Prepare cypress environment +description: Cypress preparation steps +inputs: + is-replay-browser: + description: Are we running E2E tests using Replay.io browser? + required: false +outputs: + chrome-path: + description: Custom Chrome install path + value: ${{ steps.setup-chrome.outputs.chrome-path }} + runs: using: "composite" steps: + # Browsers + - name: Install Chrome v111 + if: inputs.is-replay-browser != true + uses: browser-actions/setup-chrome@v1 + with: + # https://chromium.cypress.io/linux/stable/111.0.5563.146 + chrome-version: 1097615 + id: setup-chrome + - name: Chrome install feedback + if: inputs.is-replay-browser != true + run: | + echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }} + ${{ steps.setup-chrome.outputs.chrome-path }} --version + shell: bash + + - name: Install Replay.io browser + if: inputs.is-replay-browser == true + run: npx @replayio/cypress install + shell: bash + + # Cypress-specific - name: Check to see if dependencies should be cached if: ${{ contains(github.event.head_commit.message, '[ci nocache]') }} run: echo "Commit message includes [ci nocache]; dependencies will NOT be cached" diff --git a/.github/workflows/e2e-stress-test-flake-fix.yml b/.github/workflows/e2e-stress-test-flake-fix.yml index f2cae9f5742..a4a42e2709d 100644 --- a/.github/workflows/e2e-stress-test-flake-fix.yml +++ b/.github/workflows/e2e-stress-test-flake-fix.yml @@ -95,6 +95,7 @@ jobs: java-version: 11 distribution: "temurin" - name: Prepare Cypress environment + id: cypress-prep uses: ./.github/actions/prepare-cypress - name: Run Snowplow micro uses: ./.github/actions/run-snowplow-micro @@ -102,22 +103,13 @@ jobs: run: | jar xf target/uberjar/metabase.jar version.properties mv version.properties resources/ - - name: Install Chrome v111 - uses: browser-actions/setup-chrome@v1 - with: - # https://chromium.cypress.io/linux/stable/111.0.5563.146 - chrome-version: 1097615 - id: setup-chrome - - run: | - echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }} - ${{ steps.setup-chrome.outputs.chrome-path }} --version - name: Stress-test ${{ github.event.inputs.spec }} ${{ github.event.inputs.burn_in }} times run: | yarn run test-cypress-run \ --spec '${{ github.event.inputs.spec }}' \ --env burn=${{ github.event.inputs.burn_in }} \ --config-file e2e/support/cypress-stress-test.config.js - --browser ${{ steps.setup-chrome.outputs.chrome-path }} + --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: TERM: xterm - name: Upload Cypress Artifacts upon failure diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 4f1b6eb0403..bc58eddf9fd 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -165,6 +165,8 @@ jobs: # Example: you can get `CYPRESS_FOO` with `Cypress.env("FOO")` CYPRESS_ALL_FEATURES_TOKEN: ${{ secrets.ENTERPRISE_TOKEN }} CYPRESS_NO_FEATURES_TOKEN: ${{ secrets.E2E_STARTER_TOKEN }} + # Record runs using Deploysentinel except for the release branch + CYPRESS_DEPLOYSENTINEL_KEY: ${{ !(startsWith(github.event.pull_request.base.ref, 'release')) && secrets.CYPRESS_DEPLOYSENTINEL_KEY || '' }} MB_SNOWPLOW_AVAILABLE: true MB_SNOWPLOW_URL: "http://localhost:9090" # Snowplow micro ELECTRON_EXTRA_LAUNCH_ARGS: "--remote-debugging-port=40500" # deploysentinel @@ -243,19 +245,7 @@ jobs: jar xf target/uberjar/metabase.jar version.properties mv version.properties resources/ - - name: Install Chrome v111 - uses: browser-actions/setup-chrome@v1 - with: - # https://chromium.cypress.io/linux/stable/111.0.5563.146 - chrome-version: 1097615 - id: setup-chrome - - run: | - echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }} - ${{ steps.setup-chrome.outputs.chrome-path }} --version - - name: Record runs using Deploysentinel except for the release branch - if: ${{ github.ref == 'refs/heads/master' || !(startsWith(github.event.pull_request.base.ref, 'release')) }} - run: | - echo "CYPRESS_DEPLOYSENTINEL_KEY=${{ secrets.CYPRESS_DEPLOYSENTINEL_KEY }}" >> $GITHUB_ENV + - name: Prepare front-end environment uses: ./.github/actions/prepare-frontend - name: Prepare JDK ${{ matrix.java-version }} @@ -264,7 +254,10 @@ jobs: java-version: ${{ matrix.java-version }} distribution: "temurin" - name: Prepare Cypress environment + id: cypress-prep uses: ./.github/actions/prepare-cypress + with: + is-replay-browser: ${{ github.event_name == 'schedule' }} - name: Run Snowplow micro uses: ./.github/actions/run-snowplow-micro @@ -274,7 +267,7 @@ jobs: yarn run test-cypress-run \ --env grepTags=@OSS,grepOmitFiltered=true \ --spec './e2e/test/scenarios/**/*.cy.spec.js' \ - --browser ${{ steps.setup-chrome.outputs.chrome-path }} + --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: TERM: xterm @@ -284,7 +277,7 @@ jobs: yarn run test-cypress-run \ --env grepTags="@slow",grepOmitFiltered=true \ --spec './e2e/test/scenarios/**/*.cy.spec.js' \ - --browser ${{ steps.setup-chrome.outputs.chrome-path }} + --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: TERM: xterm @@ -294,7 +287,7 @@ jobs: yarn run test-cypress-run \ --env grepTags="-@slow+-@mongo --@quarantine",grepOmitFiltered=true \ --folder ${{ matrix.name }} \ - --browser ${{ steps.setup-chrome.outputs.chrome-path }} + --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: TERM: xterm @@ -312,7 +305,7 @@ jobs: yarn run test-cypress-run \ --env grepTags="@mongo --@quarantine",grepOmitFiltered=true \ --spec './e2e/test/scenarios/**/*.cy.spec.js' \ - --browser ${{ steps.setup-chrome.outputs.chrome-path }} + --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: CYPRESS_QA_DB_MONGO: true @@ -433,20 +426,7 @@ jobs: jar xf target/uberjar/metabase.jar version.properties mv version.properties resources/ - - name: Enable Percy recording on master only - if: github.ref == 'refs/heads/master' - run: | - echo "PERCY_TOKEN=${{ secrets.PERCY_TOKEN }}" >> $GITHUB_ENV - - name: Install Chrome v111 - uses: browser-actions/setup-chrome@v1 - with: - # https://chromium.cypress.io/linux/stable/111.0.5563.146 - chrome-version: 1097615 - id: setup-chrome - - run: | - echo Installed chromium version: ${{ steps.setup-chrome.outputs.chrome-version }} - ${{ steps.setup-chrome.outputs.chrome-path }} --version - name: Prepare front-end environment uses: ./.github/actions/prepare-frontend @@ -456,9 +436,10 @@ jobs: java-version: 11 distribution: 'temurin' - name: Prepare Cypress environment + id: cypress-prep uses: ./.github/actions/prepare-cypress - name: Percy Test - run: yarn run test-visual-run --browser ${{ steps.setup-chrome.outputs.chrome-path }} + run: yarn run test-visual-run --browser ${{ steps.cypress-prep.outputs.chrome-path }} env: - PERCY_TOKEN: ${{ env.PERCY_TOKEN }} + PERCY_TOKEN: ${{ github.ref == 'refs/heads/master' && secrets.PERCY_TOKEN || ''}} -- GitLab