Using Cypress GH Action #995
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: make sure to use the same version of cypress-io/github-action | |
# in all jobs, otherwise the last version wins I believe | |
name: Using Cypress GH Action | |
on: [push, workflow_dispatch] | |
jobs: | |
single-run: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
timeout-minutes: 10 | |
with: | |
build: npm run build | |
start: npm start | |
parallel-runs: | |
name: Parallel 4x | |
runs-on: ubuntu-24.04 | |
strategy: | |
# when one test fails, DO NOT cancel the other | |
# containers, because this will kill Cypress processes | |
# leaving the Cypress Cloud dashboard hanging ... | |
# https://github.com/cypress-io/github-action/issues/48 | |
fail-fast: false | |
matrix: | |
# Run 4 copies of the current job in parallel. | |
# The name of the array (containers) and | |
# the actual items in the array (1, 2, 3, 4) do not matter. | |
# Based on the array, GitHub Actions will create | |
# 4 independently running parallel jobs | |
# (see https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs). | |
# Cypress Cloud load-balances the Cypress tests across the GitHub Actions jobs. | |
containers: [1, 2, 3, 4] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# because of "record" and "parallel" parameters | |
# these containers will load balance all found tests among themselves | |
- name: run tests | |
uses: cypress-io/github-action@v6 | |
timeout-minutes: 5 | |
with: | |
record: true | |
parallel: true | |
group: GH Action parallel | |
start: npm start | |
env: | |
# pass the Dashboard record key as an environment variable | |
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }} | |
parallel-runs-across-platforms: | |
name: every OS | |
strategy: | |
# when one test fails, DO NOT cancel the other | |
# containers, because this will kill Cypress processes | |
# leaving the Cypress Cloud dashboard hanging ... | |
# https://github.com/cypress-io/github-action/issues/48 | |
fail-fast: false | |
matrix: | |
# run 2 copies of the current job in parallel | |
# and they will load balance all specs | |
os: ['ubuntu-24.04', 'windows-latest', 'macos-latest'] | |
containers: [1, 2] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# because of "record" and "parallel" parameters | |
# these containers will load balance all found tests among themselves | |
- name: run tests | |
uses: cypress-io/github-action@v6 | |
timeout-minutes: 10 | |
with: | |
record: true | |
parallel: true | |
group: Parallel 2x on ${{ matrix.os }} | |
# on Mac and Linux we can use "npm start" | |
start: npm start | |
# but for this particular project on Windows we need a different start command | |
start-windows: npm run start | |
env: | |
# pass the Cypress Cloud (dashboard) record key as an environment variable | |
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }} |