Skip to content

Instantly share code, notes, and snippets.

@enyo
Last active Oct 14, 2021
Embed
What would you like to do?
jobs:
build:
# Everything from the last section
test:
# We depend on the build step for this.
needs: build
timeout-minutes: 15
runs-on: ubuntu-latest
# We need to use the cypress container here, that includes chrome and
# firefox.
container:
image: cypress/browsers:node14.17.0-chrome91-ff89
# This is necessary so Cypress can find Firefox.
options: --user 1001
# This whole block is really only for the Cypress dashboard. It enables
# parallel tests which only make sense if the dashboard is coordinating
# them.
#
# If you don't want to use the Cypress Dashboard, just delete the whole
# strategy section except the browser matrix.
#
# Read more about the parallelization here:
# https://docs.cypress.io/guides/guides/parallelization
strategy:
# When one test fails, DO NOT cancel the other containers, because this
# will kill Cypress processes leaving the Dashboard hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# Setting the different browsers we want to test. This is later used in
# the cypress action.
browser: [chrome, firefox]
# Run copies of the current job in parallel.
containers: [1, 2]
steps:
- uses: actions/checkout@v2
# Download the build from the previous step.
- uses: actions/download-artifact@v2
with:
name: build
path: build
# Run all cypress tests.
- name: Cypress run
uses: cypress-io/github-action@v2
with:
# Simply start a python http server that exposes the build/ dir
start: python3 -m http.server --directory build 3000
# Only start tests when the server is up and running.
wait-on: http://localhost:3000/
# A simple python http server should really never take longer
# than 10 seconds to start.
wait-on-timeout: 10
browser: ${{ matrix.browser }}
# All these options are for the Cypress Dashboard.
# Remove them if you don't want to use it.
record: true
parallel: true
group: 'UI - ${{ matrix.browser }}'
# Again, these environment variables are only necessary for the
# Cypress Dashboard.
env:
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment