diff --git a/.circleci/config.yml b/.circleci/config.yml index 9bf6b163fd7..1aa29858502 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -546,7 +546,7 @@ jobs: - *setup_env - run: name: "Test via adhoc script" - command: ./yarn-project/boxes/blank-react/run_tests + command: ./yarn-project/boxes/run_tests blank-react boxes-blank: machine: @@ -557,7 +557,7 @@ jobs: - *setup_env - run: name: "Test via adhoc script" - command: ./yarn-project/boxes/blank/run_tests + command: ./yarn-project/boxes/run_tests blank boxes-token: machine: @@ -568,7 +568,7 @@ jobs: - *setup_env - run: name: "Test via adhoc script" - command: ./yarn-project/boxes/token/run_tests + command: ./yarn-project/boxes/run_tests token canary: machine: diff --git a/yarn-project/boxes/blank-react/run_tests b/yarn-project/boxes/blank-react/run_tests deleted file mode 100755 index 86800b07a90..00000000000 --- a/yarn-project/boxes/blank-react/run_tests +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# This script is used to run an e2e test in CI (see .circleci/config.yml). -# It pulls images and runs docker-compose, which has the test as the entrypoint. -[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace -set -eu - -# Run in script path. -cd `dirname $0` - -export COMPOSE_FILE=${1:-docker-compose.yml} - -ecr_login -REPO=aztec-sandbox -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)-x86_64" -retry docker pull $(calculate_image_uri $REPO)-x86_64 -retry docker tag $(calculate_image_uri $REPO)-x86_64 aztecprotocol/$REPO:latest - -REPO=yarn-project -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)" -retry docker pull $(calculate_image_uri $REPO) -retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest - -docker-compose rm -f -docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-blank-react \ No newline at end of file diff --git a/yarn-project/boxes/blank/run_tests b/yarn-project/boxes/blank/run_tests deleted file mode 100755 index 5037c7617cb..00000000000 --- a/yarn-project/boxes/blank/run_tests +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# This script is used to run an e2e type test in CI (see .circleci/config.yml). -# It pulls images and runs docker-compose, which has the test as the entrypoint. -[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace -set -eu - -# Run in script path. -cd `dirname $0` - -export COMPOSE_FILE=${1:-docker-compose.yml} - -ecr_login - -REPO=aztec-sandbox -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)-x86_64" -retry docker pull $(calculate_image_uri $REPO)-x86_64 -retry docker tag $(calculate_image_uri $REPO)-x86_64 aztecprotocol/$REPO:latest - -REPO=yarn-project -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)" -retry docker pull $(calculate_image_uri $REPO) -retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest - -docker-compose rm -f -docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-blank diff --git a/yarn-project/boxes/run_tests b/yarn-project/boxes/run_tests new file mode 100755 index 00000000000..80ee1ed87e6 --- /dev/null +++ b/yarn-project/boxes/run_tests @@ -0,0 +1,63 @@ +#!/bin/bash +# This script is used to run an e2e type test in CI (see .circleci/config.yml). +# It pulls images and runs docker-compose, which has the test as the entrypoint. +[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace +set -eu + +# The box name is the name of the directory containing the docker-compose.yml file +# The current dir is assumed to be `yarn-project/boxes`, as this script `yarn-project/boxes/run_tests` +CURRENT_DIR=`dirname $0` +BOX_NAME=${1:-boxes-blank} + +cd $CURRENT_DIR/$BOX_NAME + +export COMPOSE_FILE=${2:-docker-compose.yml} + +ecr_login + +# There are two dependent docker images, sandbox and yarn-project +# We must pull their ecr images, then retag them in ci as local images for our docker compose to work. +SANDBOX=aztec-sandbox +YARN_PROJECT=yarn-project + +SANDBOX_IMAGE_URI=$(calculate_image_uri $SANDBOX) +YP_IMAGE_URI=$(calculate_image_uri $YARN_PROJECT) + +################### CHECK REBUILD ################### +# Before doing any work we check if we need to rebuild +# Each box is suffixed with the box name, such that rebuilding of each box is independent, if one fails we don't rebuild the others +ensure_repo $SANDBOX $ECR_REGION refresh_lifecycle +CONTENT_HASH=$(calculate_content_hash $SANDBOX) +BASE_TAG=cache-$CONTENT_HASH-$BOX_NAME # Append the box name to seperate the tag +SUCCESS_TAG=$BASE_TAG + +echo "Content hash: $CONTENT_HASH" +if check_rebuild $SUCCESS_TAG $SANDBOX; then + echo "No rebuild required." + retry tag_remote_image $SANDBOX $BASE_TAG $SUCCESS_TAG + exit 0 +fi + +################### PREAMBLE ################### + +# Pull images from ecr and retag for the docker compsoe +SANDBOX_IMAGE=$SANDBOX_IMAGE_URI-x86_64 +echo "pulling docker image for $SANDBOX $SANDBOX_IMAGE" +retry docker pull $SANDBOX_IMAGE +retry docker tag $SANDBOX_IMAGE aztecprotocol/$SANDBOX:latest + +echo "pulling docker image for $YARN_PROJECT $YP_IMAGE_URI" +retry docker pull $YP_IMAGE_URI +retry docker tag $YP_IMAGE_URI aztecprotocol/$YARN_PROJECT:latest + +################### RUN TESTS ################### + +docker-compose rm -f +docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-$BOX_NAME + +################### POST TEST ################### + +# Success - push a new tag for the commit hash with the box name appended +IMAGE_COMMIT_URI=$SANDBOX_IMAGE_URI-$BOX_NAME +retry docker tag $SANDBOX_IMAGE $IMAGE_COMMIT_URI +retry docker push $IMAGE_COMMIT_URI > /dev/null 2>&1 \ No newline at end of file diff --git a/yarn-project/boxes/token/run_tests b/yarn-project/boxes/token/run_tests deleted file mode 100755 index f4b797520e8..00000000000 --- a/yarn-project/boxes/token/run_tests +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# This script is used to run an e2e type test in CI (see .circleci/config.yml). -# It pulls images and runs docker-compose, which has the test as the entrypoint. -[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace -set -eu - -# Run in script path. -cd `dirname $0` - -export COMPOSE_FILE=${1:-docker-compose.yml} - -ecr_login -REPO=aztec-sandbox -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)-x86_64" -retry docker pull $(calculate_image_uri $REPO)-x86_64 -retry docker tag $(calculate_image_uri $REPO)-x86_64 aztecprotocol/$REPO:latest - -REPO=yarn-project -echo "pulling docker image for $REPO $(calculate_image_uri $REPO)" -retry docker pull $(calculate_image_uri $REPO) -retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest - -docker-compose rm -f -docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-token \ No newline at end of file