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@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2025-02-14 13:56:31 +01:00
parent 098322cef8
commit 159a100b0d
No known key found for this signature in database
GPG key ID: DB99ADDDC5C0AF82
5 changed files with 32 additions and 13 deletions

View file

@ -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

View file

@ -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 }}

View file

@ -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",

View file

@ -100,7 +100,8 @@
],
"env": [
"CYPRESS_CONTAINER_ID"
]
],
"passThroughEnv": ["*"]
},
"@hedgedoc/backend#test:e2e:ci": {
"dependsOn": [

View file

@ -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