forked from AztecProtocol/aztec-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
executable file
·63 lines (48 loc) · 2.33 KB
/
run_tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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