Skip to content

Commit

Permalink
chore: run check rebuild on boxes (#3000)
Browse files Browse the repository at this point in the history
Builds ontop of the run_tests script for the boxes such that:
1. They share one script
2. They are tagged at the end ( aztec-sandbox ecr suffixed with the box
name )
3. Only run if the sandbox has changed or if they have previously failed
  • Loading branch information
Maddiaa0 authored Oct 25, 2023
1 parent df389b5 commit c503d91
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 76 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
24 changes: 0 additions & 24 deletions yarn-project/boxes/blank-react/run_tests

This file was deleted.

25 changes: 0 additions & 25 deletions yarn-project/boxes/blank/run_tests

This file was deleted.

63 changes: 63 additions & 0 deletions yarn-project/boxes/run_tests
Original file line number Diff line number Diff line change
@@ -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
24 changes: 0 additions & 24 deletions yarn-project/boxes/token/run_tests

This file was deleted.

0 comments on commit c503d91

Please sign in to comment.