GitHub Actions
Running cypress tests in parallel with GitHub Action and Currents dashboard

How to run cypress in parallel with GitHub Actions?

Currents dashboard allows running cypress tests in parallel using multiple containers within your GitHub Actions workflow.
By using GitHub Actions matrix execution strategy, you can create multiple containers that will run your cypress tests in parallel.
Each container will receive a unique set of tests to run, so that your cypress tests will run faster and you can receive faster feedback from your browser test suite.
Currents orchestrates the tests between multiple containers, applying intelligent optimizations to reduce overall runtime of your workflow, records screenshots and videos for later troubleshooting.
Cypress Tests Parallelization with Github Actions

How to setup GitHub Workflow to run Cypress Tests in parallel?

Please take a look at the example repository that showcases running cypress tests in parallel using GitHub Actions.
  • runs 3 containers with cypress tests in parallel
  • installs @currents/cli npm package as a separate step
  • uses Custom Test Command to run currents for recording test results and parallelization with Currents.dev
  • Note: set the projectId in cypress.json (you can obtain the project id from Currents.dev in Project Settings)
  • Note: use CLI arguments to customize your cypress runs, e.g.: currents run --parallel --record --key <your currents.dev key> --group groupA
  • Note: create an organization, get your record key on Currents.dev and set GH secret variable CURRENTS_RECORD_KEY
Here's an example of how the demo workflow appears in Currents dashboard
Running Cypress tests in parallel - Currents dashboard

How to setup Git commit data for Cypress when using GitHub Actions

Running Cypress tests using GitHub Actions can generate a confusing git information. For example, instead of last commit message (or pull request title), one can see something like:
1
Merge de7282540ac30ee4e32a0b1fede4f6391b4cc321 into fa58941d8a807b83ec5a3e5bfb83418ce12173c7
Copied!
Also, the branch name becomes refs/pull/12/merge instead of the expected branch name. Why is that happening?
That happens when your GitHub Actions workflow is being triggered by pull_request.
It changes the behaviour of @actions/checkout - it creates a new merge commit, which is created from merging the base to the head.
Specifically:
  • it performs git checkout to github.ref environment variable
  • it sets the git ref to refs/remotes/pull/##/merge
  • it sets the commit SHA to an arbitrary value that is different from the commit that triggered the workflow
In order to change the default behaviour and checkout the triggering commit, use the following @actions/checkout configuration
1
- uses: actions/[email protected]
2
with:
3
ref: ${{ github.event.pull_request.head.sha }}
Copied!
Read more about GitHub Actions and pull_request (by frontside.com).