From 159a100b0d087f5df1ec69bb528ac288ad20f193 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Fri, 14 Feb 2025 13:56:31 +0100 Subject: [PATCH] fix(ci): cache cypress binary correctly It seems cypress installs its own binary under a different path than the path where it later looks for it for running the tests. This change adds proper versioned caching for the binary to avoid re- downloads and configures the binary path accordingly. Signed-off-by: Erik Michelson --- .github/actions/setup-node/action.yml | 17 +++++++++++++++++ .github/workflows/e2e-tests.yml | 13 +++++++------ frontend/package.json | 2 +- turbo.json | 3 ++- yarn.lock | 10 +++++----- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml index ae3c68615..b90dd9c78 100644 --- a/.github/actions/setup-node/action.yml +++ b/.github/actions/setup-node/action.yml @@ -25,6 +25,21 @@ runs: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn + - name: Get cypress version + id: cypress-version + run: echo "cyver=$(jq -r '.devDependencies.cypress' package.json)" >> $GITHUB_OUTPUT + working-directory: frontend/ + shell: bash + + - name: Cache cypress binaries + uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + id: cypress-cache + with: + path: /home/runner/.cache/cypress + key: cypress-${{ runner.os }}-${{ steps.cypress-version.outputs.cyver }} + restore-keys: | + cypress-${{ runner.os }}-${{ steps.cypress-version.outputs.cyver }} + - name: Set up NodeJS uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 with: @@ -34,3 +49,5 @@ runs: run: yarn install --immutable working-directory: . shell: bash + env: + CYPRESS_CACHE_FOLDER: /home/runner/.cache/cypress diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a89303d86..5bacf2da0 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -156,17 +156,11 @@ jobs: if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork" needs: frontend-build runs-on: ubuntu-latest - container: - image: cypress/browsers:node-20.18.0-chrome-130.0.6723.69-1-ff-131.0.3-edge-130.0.2849.52-1@sha256:3dd9d85309ed42d4befeda0b80e15b93c5ede2d419b6fc93a341ffc7337e3505 - options: --shm-size=2g strategy: fail-fast: false matrix: containers: [ 1, 2, 3 ] steps: - - name: Install additional packages - run: apt-get update && apt-get install -y jq zstd screen curl - - name: Check out repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -177,6 +171,12 @@ jobs: with: NODEJS_VERSION: ${{ env.NODEJS_VERSION }} + - name: Show cypress info + run: yarn cypress info + working-directory: frontend/ + env: + CYPRESS_CACHE_FOLDER: /home/runner/.cache/cypress + - name: Download build uses: actions/download-artifact@v4 with: @@ -203,6 +203,7 @@ jobs: run: yarn test:e2e:ci --filter=@hedgedoc/frontend shell: bash env: + CYPRESS_CACHE_FOLDER: /home/runner/.cache/cypress CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} diff --git a/frontend/package.json b/frontend/package.json index 43bb4b79c..c7ede9520 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -142,7 +142,7 @@ "@typescript-eslint/eslint-plugin": "8.14.0", "@typescript-eslint/parser": "8.14.0", "csstype": "3.1.3", - "cypress": "13.15.2", + "cypress": "13.17.0", "cypress-commands": "3.0.0", "cypress-fill-command": "1.0.2", "dotenv-cli": "7.4.4", diff --git a/turbo.json b/turbo.json index 8f2e8eb1e..b11922ef2 100644 --- a/turbo.json +++ b/turbo.json @@ -100,7 +100,8 @@ ], "env": [ "CYPRESS_CONTAINER_ID" - ] + ], + "passThroughEnv": ["*"] }, "@hedgedoc/backend#test:e2e:ci": { "dependsOn": [ diff --git a/yarn.lock b/yarn.lock index 78432f6be..21f433533 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2720,7 +2720,7 @@ __metadata: copy-webpack-plugin: "npm:12.0.2" cross-env: "npm:7.0.3" csstype: "npm:3.1.3" - cypress: "npm:13.15.2" + cypress: "npm:13.17.0" cypress-commands: "npm:3.0.0" cypress-fill-command: "npm:1.0.2" d3-graphviz: "npm:5.6.0" @@ -8973,9 +8973,9 @@ __metadata: languageName: node linkType: hard -"cypress@npm:13.15.2": - version: 13.15.2 - resolution: "cypress@npm:13.15.2" +"cypress@npm:13.17.0": + version: 13.17.0 + resolution: "cypress@npm:13.17.0" dependencies: "@cypress/request": "npm:^3.0.6" "@cypress/xvfb": "npm:^1.2.4" @@ -9022,7 +9022,7 @@ __metadata: yauzl: "npm:^2.10.0" bin: cypress: bin/cypress - checksum: 10c0/07b1019a82941f3a5986d38dcd630a3ad08398dcd53c2e9bd316dad822b65fa7e4d9822be4e0cc8229747ac1b2bb4fc29747f0b509ff13b1853218a2ce2427aa + checksum: 10c0/159ce620e32d2785082aaa1f4f30f203dcec466df4a8e80dfa299035358772fd513c35820070ba8db52e2bf58078a372ff7009068e26967f993656e7da62e221 languageName: node linkType: hard