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