From 4338f9b9a6e0765f2935403fb25cb8352cb71a42 Mon Sep 17 00:00:00 2001 From: ludamad Date: Sun, 3 Sep 2023 11:47:08 -0400 Subject: [PATCH] fix: more content hash --- build-system/scripts/remote_run_script | 8 ++++---- build-system/scripts/spot_run_script | 10 ++++++---- yarn-project/end-to-end/scripts/cond_run_script | 6 +++--- yarn-project/end-to-end/scripts/run_tests | 15 +++++++-------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/build-system/scripts/remote_run_script b/build-system/scripts/remote_run_script index f393e2649da..7971e10f05f 100755 --- a/build-system/scripts/remote_run_script +++ b/build-system/scripts/remote_run_script @@ -2,9 +2,9 @@ set -e IP=$1 -FULL_PATH=$2 -shift -shift +CONTENT_HASH=$2 +FULL_PATH=$3 +shift 3 SSH_CONFIG_PATH=${SSH_CONFIG_PATH:-$BUILD_SYSTEM_PATH/remote/ssh_config} DIR_NAME=$(dirname $FULL_PATH) @@ -14,4 +14,4 @@ SCRIPT_NAME=$(basename $FULL_PATH) scp -F $SSH_CONFIG_PATH $DIR_NAME/* $IP:. # Run script on remote instance. -ssh -A -F $SSH_CONFIG_PATH $IP "COMMIT_HASH=$COMMIT_HASH COMMIT_TAG=$COMMIT_TAG JOB_NAME=$JOB_NAME GIT_REPOSITORY_URL=$GIT_REPOSITORY_URL DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD ECR_DEPLOY_URL=$ECR_DEPLOY_URL ECR_URL=$ECR_URL ./$SCRIPT_NAME $@" +ssh -A -F $SSH_CONFIG_PATH $IP "CONTENT_HASH=$CONTENT_HASH COMMIT_HASH=$COMMIT_HASH COMMIT_TAG=$COMMIT_TAG JOB_NAME=$JOB_NAME GIT_REPOSITORY_URL=$GIT_REPOSITORY_URL DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD ECR_DEPLOY_URL=$ECR_DEPLOY_URL ECR_URL=$ECR_URL ./$SCRIPT_NAME $@" diff --git a/build-system/scripts/spot_run_script b/build-system/scripts/spot_run_script index 1f3ee311fed..9e35ac53996 100755 --- a/build-system/scripts/spot_run_script +++ b/build-system/scripts/spot_run_script @@ -4,10 +4,12 @@ # 2... ARGS: Arguments to pass to remote_run_script. set -e +CONTENT_HASH=$(calculate_content_hash $REPOSITORY) + # On any sort of exit (error or not), kill spot request so it doesn't count against quota. function on_exit { - if [ -f "sir-$COMMIT_HASH:$JOB_NAME.txt" ]; then - SIR=$(cat sir-$COMMIT_HASH:$JOB_NAME.txt) + if [ -f "sir-$CONTENT_HASH:$JOB_NAME.txt" ]; then + SIR=$(cat sir-$CONTENT_HASH:$JOB_NAME.txt) echo "Cancelling spot instance request $SIR (silently)" aws ec2 cancel-spot-instance-requests --spot-instance-request-ids $SIR >/dev/null 2>&1 || true fi @@ -18,11 +20,11 @@ SPEC=$1 shift # Get spot instance. -IP=$(request_spot $COMMIT_HASH:$JOB_NAME $SPEC) +IP=$(request_spot $CONTENT_HASH:$JOB_NAME $SPEC) # Run script remotely on spot instance, capturing success or failure. set +e -remote_run_script $IP $@ +remote_run_script $IP $CONTENT_HASH $@ CODE=$? # Shutdown spot. diff --git a/yarn-project/end-to-end/scripts/cond_run_script b/yarn-project/end-to-end/scripts/cond_run_script index c1eae55ff32..a833fa1efa8 100755 --- a/yarn-project/end-to-end/scripts/cond_run_script +++ b/yarn-project/end-to-end/scripts/cond_run_script @@ -25,10 +25,10 @@ shift CONTENT_HASH=$(calculate_content_hash $REPOSITORY) -echo "Last successful commit for $SUCCESS_TAG: $CONTENT_HASH" +echo "Content: $CONTENT_HASH" echo "Script to run is $SCRIPT_TO_RUN $@" -if ! check_rebuild cache-$COMMIT_HASH-$SUCCESS_TAG $REPOSITORY; then +if ! check_rebuild cache-$CONTENT_HASH-$SUCCESS_TAG $REPOSITORY; then "$SCRIPT_TO_RUN" "$@" - tag_remote_image $REPOSITORY cache-$COMMIT_HASH cache-$COMMIT_HASH-$SUCCESS_TAG + tag_remote_image $REPOSITORY cache-$CONTENT_HASH cache-$CONTENT_HASH-$SUCCESS_TAG fi diff --git a/yarn-project/end-to-end/scripts/run_tests b/yarn-project/end-to-end/scripts/run_tests index ad3f295edf4..da2f161501d 100755 --- a/yarn-project/end-to-end/scripts/run_tests +++ b/yarn-project/end-to-end/scripts/run_tests @@ -6,14 +6,13 @@ set -e export TEST=$1 export COMPOSE_FILE=${2:-docker-compose.yml} -if [ -n "$COMMIT_HASH" ]; then - $(aws ecr get-login --region us-east-2 --no-include-email) 2> /dev/null +CONTENT_HASH=$(calculate_content_hash $REPO) +$(aws ecr get-login --region us-east-2 --no-include-email) 2> /dev/null - for REPO in aztec.js end-to-end aztec-sandbox; do - docker pull 278380418400.dkr.ecr.us-east-2.amazonaws.com/$REPO:cache-$COMMIT_HASH - docker tag 278380418400.dkr.ecr.us-east-2.amazonaws.com/$REPO:cache-$COMMIT_HASH aztecprotocol/$REPO:latest - done -fi +for REPO in aztec.js end-to-end aztec-sandbox; do + docker pull 278380418400.dkr.ecr.us-east-2.amazonaws.com/$REPO:cache-$CONTENT_HASH + docker tag 278380418400.dkr.ecr.us-east-2.amazonaws.com/$REPO:cache-$CONTENT_HASH aztecprotocol/$REPO:latest +done docker-compose rm -f -docker-compose -f $COMPOSE_FILE up --exit-code-from end-to-end \ No newline at end of file +docker-compose -f $COMPOSE_FILE up --exit-code-from end-to-end