Github actions: Conditionally record test results to cypress.io while using on: deployment_status trigger #21321
-
We have a name: e2e-ci
on: deployment_status
jobs:
e2e:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v2
with:
record: true
env:
CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }}
CYPRESS_RECORD_KEY: [our key here] The action runs on Each time we check code in, a new deployment happens, and a new test run (if the deployment was successful). Here’s the issue: Recording the test results to cypress.io on every single deployment is a waste of resources since a lot of these dev deployments are for basic UI testing purposes. I want to upload the test results for the Unfortunately, I can’t use the I'm looking for recommendations for conditionally setting the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You have to have some scripting logic before the name: e2e-ci
on: deployment_status
jobs:
e2e:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
# some CI logic that gives you a result, assigned to a variavble named thatResult
- name: Cypress run
uses: cypress-io/github-action@v2
with:
record: $(thatResult)
env:
CYPRESS_BASE_URL: ${{ github.event.deployment_status.target_url }}
CYPRESS_RECORD_KEY: [our key here] Here is a more complex example where instead of boolean value, the environment is figured out with a script and passed to the config file. It should give some ideas. https://dev.to/muratkeremozcan/the-32-ways-of-selective-testing-with-cypress-a-unified-concise-approach-to-selective-testing-in-ci-and-local-machines-1c19 |
Beta Was this translation helpful? Give feedback.
You have to have some scripting logic before the
Cypress run
step, which gives you a boolean result. After that, you pass that result instead ofrecord: true