Skip to content

Commit

Permalink
feat: NPM canary deployment (#2731)
Browse files Browse the repository at this point in the history
Fixes #2366

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
spypsy authored Oct 13, 2023
1 parent 5afdf91 commit 7d48ed3
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 117 deletions.
86 changes: 61 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,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 @@ -1034,6 +1043,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 @@ -1044,7 +1066,18 @@ jobs:
# Aztec.js and dependencies
- run:
name: "yarn-project"
command: yarn-project/deploy_npm.sh
command: yarn-project/deploy_npm.sh latest

deploy-dockerhub-canary:
machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
steps:
- *checkout
- *setup_env
- run:
name: "Deploy to dockerhub"
command: yarn-project/deploy_dockerhub.sh canary

deploy-ecr:
machine:
Expand All @@ -1068,15 +1101,6 @@ jobs:
name: "Deploy to dockerhub"
command: yarn-project/deploy_dockerhub.sh

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

build-deployment-canary:
machine:
image: ubuntu-2204:2023.07.2
Expand All @@ -1088,7 +1112,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 @@ -1099,7 +1123,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 @@ -1110,7 +1134,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 @@ -1408,12 +1432,12 @@ 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
Expand All @@ -1422,28 +1446,40 @@ workflows:
- 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

0 comments on commit 7d48ed3

Please sign in to comment.