Skip to content

Instantly share code, notes, and snippets.

@skylock
Created September 26, 2019 13:07
Show Gist options
  • Save skylock/b006e495760e77e4ee7994b51c71a519 to your computer and use it in GitHub Desktop.
Save skylock/b006e495760e77e4ee7994b51c71a519 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
echo "Running Cypress e2e tests headlessly without copying files"
BUILD_ENV=dev
IMAGE_TAG=cypress/included:3.4.1
CYPRESS_ARGS="--spec cypress/integration/administration/dashboard*"
RECORD_ON="--group aws-tests --ci-build-id $CODEBUILD_BUILD_ID --record"
RECORD_OFF="--record false -c video=false"
CONFIG="-e configFile=$BUILD_ENV"
DOCKER_ENV_VARS="-e "INTF_USERNAME"="$INTF_USERNAME" -e "INTF_PASSWORD"="$INTF_PASSWORD" -e "CYPRESS_RECORD_KEY"="$CYPRESS_RECORD_KEY" -e "COMMIT_INFO_BRANCH"=$CODEBUILD_SOURCE_VERSION"
# explanation of the "docker run" command line arguments
#
# -it = interactive terminal
# -v $PWD:/e2e = map current folder to /e2e inside the container
# -w /e2e = set working directy to /e2e
# $@ = pass any arguments to this script to the Cypress command
# like "./cy-run.sh --record"
#
# Docker image "cypress/included:3.2.0" has its entrypoint
# set to "cypress run" by default
# docker run -it -v $PWD:/e2e -w /e2e cypress/included:3.4.1 $@
# Run test
# docker run -it --rm --privileged $DOCKER_ENV_VARS -v $PWD:/e2e -w /e2e $IMAGE_TAG cypress run $RECORD_OFF $CONFIG $CYPRESS_ARGS
# Run docker interactively
docker run -it --rm --privileged $DOCKER_ENV_VARS $CONFIG -v $PWD:/e2e -w /e2e --entrypoint '/bin/bash' $IMAGE_TAG
# if you need to restrict amount of memory or CPU power the
# container can use, see
# https://docs.docker.com/config/containers/resource_constraints/
# restrict total memory
# --memory=600m --memory-swap=600m
# restrict CPU share
# --cpus=0.3
# docker run -e "INTF_USERNAME"="$INTF_USERNAME" -e "INTF_PASSWORD"="$INTF_PASSWORD" -v $PWD:/e2e -w /e2e $IMAGE_TAG cypress run --record false -e configFile=dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment