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 committed by Mr. DrogDrog
parent c7f318e525
commit 15f6e12bee
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@v4.2.2 # 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 }}