Created
August 3, 2020 17:39
-
-
Save alfredlucero/5e8966c98f26835d520e4369c16dd277 to your computer and use it in GitHub Desktop.
Cypress Tips/Tricks - Cypress Trigger Pipeline Buildkite Steps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Whether we plan to use this in a separate pipeline for scheduled Cypress test runs or for triggering tests in a separate Cypress pipeline | |
# all we have to do is change up the environment variable values for things to work | |
steps: | |
- label: ':npm: :docker: Build Cypress Docker image' | |
command: | |
# Building Cypress Docker image with application/test code | |
# We need to tag latest and Buildkite version on the container | |
- docker-compose -f docker-compose.cypress.yml build cypress | |
- docker tag <private_docker_registry_path>:${VERSION} <private_docker_registry_path>:latest | |
# Pushing images to private registry with Buildkite versioning and latest tags | |
- docker push <private_docker_registry_path>:${VERSION} | |
- docker push <private_docker_registry_path>:latest | |
env: | |
# Adds unique version tag through Buildkite build ID so we can reference it in future steps | |
VERSION: '$BUILDKITE_BUILD_ID' | |
- wait | |
- label: ':cypress: :chromium: Run Cypress tests' | |
# Screenshots/videos will be accessible through the Artifacts tab in this build step | |
artifact_paths: | |
- './artifacts/**/*' | |
- './artifacts/*' | |
# Monitor the Dashboard Service's recommendations for number of machines to use to optimize | |
# P1 test runs | |
parallelism: $PARALLELISM | |
command: | |
# Pull the specific Buildkite version of the image in case multiple jobs are run at the same time | |
# and latest is overwritten | |
- docker pull <private_docker_registry_path>:${VERSION} | |
# Run Cypress tests and they will be recorded through the Dashboard Service; the exit code from the Cypress tests will be outputted for success or failure build | |
- docker-compose -f docker-compose.cypress.yml up --abort-on-container-exit --exit-code-from cypress | |
env: | |
VERSION: '$BUILDKITE_BUILD_ID' | |
# These values were set from our runCypress.sh -> triggerCypress.yml steps in our main CICD pipeline or directly in a Cypress pipeline's environment variable settings | |
CYPRESS_SPECS: '$CYPRESS_SPECS' | |
CYPRESS_TEST_ENV: '$CYPRESS_TEST_ENV' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment