Skip to content

Commit

Permalink
fix: more content hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad committed Sep 3, 2023
1 parent 1543d96 commit 4338f9b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions build-system/scripts/remote_run_script
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 $@"
10 changes: 6 additions & 4 deletions build-system/scripts/spot_run_script
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/scripts/cond_run_script
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 7 additions & 8 deletions yarn-project/end-to-end/scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
docker-compose -f $COMPOSE_FILE up --exit-code-from end-to-end

0 comments on commit 4338f9b

Please sign in to comment.