MatthewThomas.dev
MatthewThomas.dev

Reputation: 1045

Multiple Cypress run --record commands on Github Actions within the same workflow is only recording the first execution on Cypress Dashboard

I am building a continuous deployment pipeline that triggers when a change to the main branch is made (trunk-based), executing the common test, build and deploy stages through to production.

To achieve this, I am attempting to execute multiple cypress run commands in Github Actions from within the same workflow and to record the executions on Cypress dashboard, this is an attempt to test the application on multiple environments. However, only the first execution is being executed and recorded.

Here is the workflow YAML, with unrelated statements removed:

name: trunk-release
on:
  push:
    branches: [main]
jobs:
  test-local:
    name: test-local
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm ci
      - run: npm start & npx wait-on http://localhost:3000
      - run: npm run cy-test:local
  deploy-dev:
    needs: test-local
    name: deploy-dev
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm run cy-test:dev
  deploy-prod:
    needs: deploy-dev
    name: deploy-prod
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    env:
      CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
    steps:
      - uses: actions/checkout@v2
      - run: npm run cy-test:prod

And here are the scripts I'm running:

  "scripts": {
    "cy-test:local": "./node_modules/.bin/cypress run --record --parallel --tag 'local'",
    "cy-test:dev": "CYPRESS_BASE_URL=https://dev.mywebapp.com ./node_modules/.bin/cypress run --record --parallel --tag 'develop'",
    "cy-test:prod": "CYPRESS_BASE_URL=https://mywebapp.com ./node_modules/.bin/cypress run --record --parallel --tag 'production'",
  }

The default CYPRESS_BASE_URL is localhost.

npm run cy-test:local runs and records successfully, however, additional executions don't run tests or record to dashboard.

The Github Action logs for second and third executions are here, showing no tests being run:

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    7.3.0                                                                              │
  │ Browser:    Electron 89 (headless)                                                             │
  │ Specs:      6 found (listed tests)                                            │
  │ Params:     Tag: develop, Group: false, Parallel: true                                         │
  │ Run URL:    same URL as first run                             │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


tput: No value for $TERM and no -T specified
====================================================================================================

  (Run Finished)

Appreciate any help, Matt

Upvotes: 2

Views: 641

Answers (1)

MatthewThomas.dev
MatthewThomas.dev

Reputation: 1045

This was resolved by increasing the Run completion delay value.

Run completion delay

During parallelization mode or when grouping runs, Cypress will wait for a specified amount of time before completing the test run in case any more relevant work remains. This is to compensate for various scenarios where CI machines could be backed-up in a queue. This waiting period is called the run completion delay and it begins after the last known CI machine has completed This delay is 60 seconds by default, but is configurable within the Dashboard project settings page.

More information is available here

Upvotes: 1

Related Questions