Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NPM canary deployment #2731

Merged
merged 8 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 60 additions & 24 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,15 @@ jobs:
name: "Noop"
command: echo Noop

canary-end:
docker:
- image: cimg/base:2023.09
resource_class: small
steps:
- run:
name: "Noop"
command: echo Noop

bench-summary:
machine:
image: ubuntu-2204:2023.07.2
Expand All @@ -1012,6 +1021,19 @@ jobs:
name: "Assemble benchmark summary from uploaded logs"
command: ./scripts/ci/assemble_e2e_benchmark.sh

deploy-npm-canary:
# Deploys next version under 'canary' dist tag.
machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
steps:
- *checkout
- *setup_env
# Aztec.js and dependencies
- run:
name: "yarn-project"
command: yarn-project/deploy_npm.sh canary

deploy-npm:
machine:
image: ubuntu-2204:2023.07.2
Expand All @@ -1022,9 +1044,9 @@ jobs:
# Aztec.js and dependencies
- run:
name: "yarn-project"
command: yarn-project/deploy_npm.sh
command: yarn-project/deploy_npm.sh latest

deploy-dockerhub:
deploy-dockerhub-canary:
machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
Expand All @@ -1033,16 +1055,18 @@ jobs:
- *setup_env
- run:
name: "Deploy to dockerhub"
command: yarn-project/deploy_dockerhub.sh
command: yarn-project/deploy_dockerhub.sh canary

deploy-end:
docker:
- image: cimg/base:2023.09
resource_class: small
deploy-dockerhub:
machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
steps:
- *checkout
- *setup_env
- run:
name: "Noop"
command: echo Noop
name: "Deploy to dockerhub"
command: yarn-project/deploy_dockerhub.sh

build-deployment-canary:
machine:
Expand All @@ -1055,7 +1079,7 @@ jobs:
name: "Build"
command: build canary true

run-deployment-canary-uniswap:
canary-uniswap-test:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
Expand All @@ -1066,7 +1090,7 @@ jobs:
name: "Test"
command: run_script canary ./scripts/run_tests ./src/uniswap_trade_on_l1_from_l2.test.ts canary ./scripts/docker-compose.yml

run-deployment-canary-browser:
canary-browser-test:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
Expand All @@ -1077,7 +1101,7 @@ jobs:
name: "Test"
command: run_script canary ./scripts/run_tests ./src/aztec_js_browser.test.ts canary ./scripts/docker-compose-browser.yml

run-deployment-canary-cli:
canary-cli-test:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
Expand Down Expand Up @@ -1365,38 +1389,50 @@ workflows:
- bench-process-history
<<: *defaults

# Deployment and Canary tests
- deploy-dockerhub:
# Deploy under canary tag
- deploy-npm-canary:
requires:
- e2e-end
<<: *deploy_defaults
- deploy-npm:
- deploy-dockerhub-canary:
requires:
- e2e-end
<<: *deploy_defaults

- deploy-end:
- build-deployment-canary:
requires:
- deploy-dockerhub
- deploy-npm
- deploy-npm-canary
- deploy-dockerhub-canary
<<: *deploy_defaults

- build-deployment-canary:
# Run canary tests
- canary-uniswap-test:
requires:
- deploy-end
- build-deployment-canary
<<: *deploy_defaults

- run-deployment-canary-uniswap:
- canary-browser-test:
requires:
- build-deployment-canary
<<: *deploy_defaults

- run-deployment-canary-browser:
- canary-cli-test:
requires:
- build-deployment-canary
<<: *deploy_defaults

- run-deployment-canary-cli:
- canary-end:
requires:
- build-deployment-canary
- canary-uniswap-test
- canary-browser-test
- canary-cli-test

# Production deployment
- deploy-dockerhub:
requires:
- canary-end
<<: *deploy_defaults
- deploy-npm:
requires:
- canary-end
<<: *deploy_defaults
15 changes: 8 additions & 7 deletions build-system/scripts/deploy_dockerhub
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fi

REPOSITORY=$1
ARCH=${2:-""}
DIST_TAG=${3:-"latest"}

echo "Repo: $REPOSITORY"
echo "Arch: $ARCH"
Expand All @@ -18,10 +19,10 @@ USERNAME="aztecprotocolci"

IMAGE_COMMIT_URI=$(calculate_image_uri $REPOSITORY)

IMAGE_LATEST_URI=$ACCOUNT/$REPOSITORY:latest
IMAGE_DIST_URI=$ACCOUNT/$REPOSITORY:$DIST_TAG
if [[ -n "$ARCH" ]]; then
IMAGE_COMMIT_URI=$IMAGE_COMMIT_URI-$ARCH
IMAGE_LATEST_URI=$IMAGE_LATEST_URI-$ARCH
IMAGE_DIST_URI=$IMAGE_DIST_URI-$ARCH
fi

COMMIT_TAG_VERSION=$(extract_tag_version $REPOSITORY true)
Expand Down Expand Up @@ -49,11 +50,11 @@ echo "Tagging $IMAGE_COMMIT_URI as $IMAGE_DEPLOY_URI"
# Tag with commit tag
docker_or_dryrun tag $IMAGE_COMMIT_URI $IMAGE_DEPLOY_URI

echo "Tagging $IMAGE_COMMIT_URI as $IMAGE_LATEST_URI"
# Tag with :latest
docker_or_dryrun tag $IMAGE_COMMIT_URI $IMAGE_LATEST_URI
echo "Tagging $IMAGE_COMMIT_URI as $IMAGE_DIST_URI"
# Tag with :$DIST_TAG (latest or canary)
docker_or_dryrun tag $IMAGE_COMMIT_URI $IMAGE_DIST_URI

# Push tagged image to dockerhub.
docker_or_dryrun push $IMAGE_DEPLOY_URI
# Push :latest image to dockerhub
docker_or_dryrun push $IMAGE_LATEST_URI
# Push :latest or :canary image to dockerhub
docker_or_dryrun push $IMAGE_DIST_URI
2 changes: 1 addition & 1 deletion yarn-project/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd "$(dirname "$0")"

if [ "$(uname)" = "Darwin" ]; then
# works around https://github.com/AztecProtocol/aztec3-packages/issues/158
echo "Note: not sourcing nvm on Mac, see github #158"
echo "Note: not sourcing nvm on Mac, see github #158"
else
\. ~/.nvm/nvm.sh
fi
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/canary/scripts/docker-compose-browser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- '8545:8545'

sandbox:
image: aztecprotocol/aztec-sandbox:latest
image: aztecprotocol/aztec-sandbox:canary
environment:
DEBUG: 'aztec:*'
ETHEREUM_HOST: http://fork:8545
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/canary/scripts/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- '8545:8545'

sandbox:
image: aztecprotocol/aztec-sandbox:latest
image: aztecprotocol/aztec-sandbox:canary
environment:
DEBUG: 'aztec:*'
ETHEREUM_HOST: http://fork:8545
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/canary/scripts/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export IMAGE=${2:-canary}
export COMPOSE_FILE=${3:-./scripts/docker-compose.yml}
:
# if test name ends with uniswap_trade_on_l1_from_l2.test.ts, use the forked mainnet
if [[ "$TEST" == *"uniswap_trade_on_l1_from_l2.test.ts" ]]; then
if [[ "$TEST" == *"uniswap_trade_on_l1_from_l2"* ]]; then
export FORK_URL=https://mainnet.infura.io/v3/9928b52099854248b3a096be07a6b23c
export FORK_BLOCK_NUMBER=17514288
fi
Expand Down
19 changes: 7 additions & 12 deletions yarn-project/canary/scripts/update_packages.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
#!/bin/bash
set -eu

COMMIT_TAG=$1
DIST_TAG=$1

if [ -z "$COMMIT_TAG" ]; then
echo "No commit tag provided."
if [ -z "$DIST_TAG" ]; then
echo "No dist tag provided."
exit 0
fi

VERSION=$(npx semver $COMMIT_TAG)
if [ -z "$VERSION" ]; then
echo "$COMMIT_TAG is not a semantic version."
exit 1
fi

echo "Updating Aztec dependencies to version $VERSION"
echo "Updating Aztec dependencies to tag $DIST_TAG"

TMP=$(mktemp)
for PKG in $(jq --raw-output ".dependencies | keys[] | select(contains(\"@aztec/\") and (. != \"@aztec/end-to-end\"))" package.json); do
jq --arg v $VERSION ".dependencies[\"$PKG\"] = \$v" package.json > $TMP && mv $TMP package.json
jq --arg v $DIST_TAG ".dependencies[\"$PKG\"] = \$v" package.json >$TMP && mv $TMP package.json
done

jq ".references = []" tsconfig.json > $TMP && mv $TMP tsconfig.json
jq ".references = []" tsconfig.json >$TMP && mv $TMP tsconfig.json
17 changes: 9 additions & 8 deletions yarn-project/deploy_dockerhub.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash

DIST_TAG=${1:-"latest"}

extract_repo yarn-project /usr/src project
PROJECT_ROOT=$(pwd)/project/src/

for REPOSITORY in "pxe" "aztec-sandbox"
do
echo "Deploying $REPOSITORY"
RELATIVE_PROJECT_DIR=$(query_manifest relativeProjectDir $REPOSITORY)
cd "$PROJECT_ROOT/$RELATIVE_PROJECT_DIR"
for REPOSITORY in "pxe" "aztec-sandbox"; do
echo "Deploying $REPOSITORY $TAG"
RELATIVE_PROJECT_DIR=$(query_manifest relativeProjectDir $REPOSITORY)
cd "$PROJECT_ROOT/$RELATIVE_PROJECT_DIR"

deploy_dockerhub $REPOSITORY x86_64
deploy_dockerhub $REPOSITORY arm64
create_dockerhub_manifest $REPOSITORY x86_64,arm64
deploy_dockerhub $REPOSITORY x86_64 $DIST_TAG
deploy_dockerhub $REPOSITORY arm64 $DIST_TAG
create_dockerhub_manifest $REPOSITORY x86_64,arm64 $DIST_TAG
done
Loading