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: Noir subrepo. #3369

Merged
merged 50 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
778f6c7
git subrepo clone [email protected]:noir-lang/noir
charlielye Nov 20, 2023
b5307cc
Build noir.
charlielye Nov 20, 2023
ebda6cd
Arm support.
charlielye Nov 21, 2023
7892094
[ci rebuild noir-x86_64] [ci rebuild noir-arm64]
charlielye Nov 21, 2023
4777acb
[ci rebuild noir]
charlielye Nov 21, 2023
ac89576
[ci rebuild noir]
charlielye Nov 21, 2023
637b4f6
[ci rebuild noir]
charlielye Nov 21, 2023
0cbeb36
[ci rebuild noir]
charlielye Nov 21, 2023
6754f48
[ci rebuild noir]
charlielye Nov 21, 2023
73c5397
[ci rebuild noir]
charlielye Nov 21, 2023
675d2f5
[ci rebuild noir]
charlielye Nov 21, 2023
306ff3a
git subrepo pull (merge) noir
charlielye Nov 22, 2023
631f45b
[ci rebuild noir]
charlielye Nov 22, 2023
ee47b09
Noir deploy
charlielye Nov 22, 2023
1661475
git subrepo commit (merge) noir
charlielye Nov 22, 2023
74d9048
Move to machine class to get docker
charlielye Nov 22, 2023
c13e89d
[ci rebuild noir]
charlielye Nov 22, 2023
b09c67c
Alpine release build of noir.
charlielye Nov 22, 2023
61999e7
Remove all the ARCH hacks from build system. Simplify deploy_dockerhub.
charlielye Nov 22, 2023
1ab0800
Remove unused save log stuff.
charlielye Nov 22, 2023
601068e
Fixes. Can trigger dry deploy via cci.
charlielye Nov 22, 2023
6d60019
Try again. Now there is workflow distinction for deploy, but we early…
charlielye Nov 22, 2023
fb85b60
fix
charlielye Nov 22, 2023
a5113c5
fix
charlielye Nov 22, 2023
8989ca1
fix
charlielye Nov 22, 2023
edefa32
fix
charlielye Nov 22, 2023
92379d6
fix
charlielye Nov 22, 2023
7f54df4
fix
charlielye Nov 22, 2023
1fa8c83
fix
charlielye Nov 22, 2023
843123e
Fix version number.
charlielye Nov 22, 2023
18a2f8b
fix
charlielye Nov 22, 2023
8e281e5
fix
charlielye Nov 22, 2023
449cceb
fix
charlielye Nov 22, 2023
3fbc2f0
fix
charlielye Nov 23, 2023
358bcec
fix
charlielye Nov 23, 2023
fa8a10d
fix
charlielye Nov 23, 2023
27f53ab
Remove the VERSION files and sanity check test in setup-env.
charlielye Nov 23, 2023
cecc803
fix
charlielye Nov 23, 2023
bdbbb96
fix
charlielye Nov 23, 2023
1eb9dba
fix
charlielye Nov 23, 2023
a77703a
fix
charlielye Nov 23, 2023
b61a161
[ci dry-deploy]
charlielye Nov 23, 2023
edad1fc
[ci dry-deploy]
charlielye Nov 23, 2023
1777aab
Merge remote-tracking branch 'origin/master' into cl/noir-subrepo
charlielye Nov 23, 2023
ac19f40
Merge branch 'master' into cl/noir-subrepo
charlielye Nov 23, 2023
ca4ffa5
fix
charlielye Nov 23, 2023
b563913
[ci dry-deploy]
charlielye Nov 23, 2023
8e4867b
fix [ci dry-deploy]
charlielye Nov 23, 2023
96566b1
fix [ci dry-deploy]
charlielye Nov 23, 2023
2e6135b
Address review comments. [ci rebuild]
charlielye Nov 23, 2023
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
375 changes: 105 additions & 270 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
aztec3-packages
aztec
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

1 change: 0 additions & 1 deletion barretenberg/VERSION

This file was deleted.

14 changes: 0 additions & 14 deletions build-system/remote/32core.json

This file was deleted.

14 changes: 0 additions & 14 deletions build-system/remote/64core.json

This file was deleted.

8 changes: 8 additions & 0 deletions build-system/remote/bootstrap_build_instance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common awscli docker-ce
sudo usermod -aG docker ${USER}
mkdir .aws
echo "Add build-instance credentials to ~/.aws/credentials
41 changes: 17 additions & 24 deletions build-system/scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@
# usage: ./build <repository>
# example: ./build aztec-connect-cpp-x86_64-linux-clang
# output image:
# 278380418400.dkr.ecr.us-east-2.amazonaws.com/aztec-connect-cpp-x86_64-linux-clang:cache-deadbeefcafebabe1337c0d3
# 278380418400.dkr.ecr.us-east-2.amazonaws.com/aztec-connect-cpp-x86_64-linux-clang:cache-deadbeefcafebabe1337c0d3-x86_64
#
# In more detail:
# - Init all submodules required to build this project.
# - Log into cache ECR, and ensures repository exists.
# - Checks if current project needs to be rebuilt, if not, retag previous image with current commit hash and early out.
# - Validate any terraform that may exist.
# - Pull down dependent images that we do not control (e.g. alpine etc).
# - For images we do control, pull the image we've built (or retagged) as part of this build.
# - For each "named stage" (usually intermittent builders before creating final image), pull previous to prime the cache, build and push the results.
# - Pull previous project image to use it as a layer cache if it exists.
# - Perform the build of the image itself. With the cache primed we should only have to rebuild the necessary layers.
# - Push the image tagged with the commit hash to the cache.
# - For images built previously in pipeline, pull the image we've built.
# - Perform the build of the image itself.
# - Push the image tagged with the content hash to the cache.

[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -euo pipefail

REPOSITORY=$1
FORCE_BUILD=${2:-"false"}
ARCH=${3:-""}
DOCKERFILE=$(query_manifest dockerfile $REPOSITORY)
PROJECT_DIR=$(query_manifest projectDir $REPOSITORY)
BUILD_DIR=$(query_manifest buildDir $REPOSITORY)
Expand All @@ -36,7 +30,6 @@ echo "Repository: $REPOSITORY"
echo "Working directory: $PWD"
echo "Dockerfile: $DOCKERFILE"
echo "Build directory: $BUILD_DIR"
echo "Arch: $ARCH"

# Fetch images with retries
function fetch_image() {
Expand Down Expand Up @@ -67,7 +60,8 @@ echo "Content hash: $CONTENT_HASH"
cd $BUILD_DIR

# If we have previously successful commit, we can early out if nothing relevant has changed since.
if [[ $FORCE_BUILD == 'false' ]] && check_rebuild cache-"$CONTENT_HASH" $REPOSITORY; then
IMAGE_COMMIT_TAG=$(calculate_image_tag $REPOSITORY)
if check_rebuild $IMAGE_COMMIT_TAG $REPOSITORY; then
echo "No rebuild necessary."
exit 0
fi
Expand All @@ -94,15 +88,17 @@ fi

# For each dependency, pull in the latest image and give it correct tag.
for PARENT_REPO in $(query_manifest dependencies $REPOSITORY); do
PARENT_CONTENT_HASH=$(calculate_content_hash $PARENT_REPO)
# There must be a parent image to continue.
if [ -z "$PARENT_CONTENT_HASH" ]; then
echo "No parent image found for $PARENT_REPO"
exit 1
PARENT_IMAGE_URI=$(calculate_image_uri $PARENT_REPO)
echo "Pulling dependency $PARENT_IMAGE_URI..."
if ! fetch_image $PARENT_IMAGE_URI; then
# This is a *bit* of a hack maybe. Some of our arm images can be built from x86 dependents.
# e.g. node projects are architecture independent.
# This may not hold true if we start introducing npm modules that are backed by native code.
# But for now, to avoid building some projects twice, we can fallback onto x86 variant.
PARENT_IMAGE_URI=$(calculate_image_uri $PARENT_REPO x86_64)
echo "Falling back onto x86 build. Pulling dependency $PARENT_IMAGE_URI..."
fetch_image $PARENT_IMAGE_URI
fi
PARENT_IMAGE_URI=$ECR_URL/$PARENT_REPO:cache-$PARENT_CONTENT_HASH
echo "Pulling dependency $PARENT_REPO..."
fetch_image $PARENT_IMAGE_URI
# Tag it to look like an official release as that's what we use in Dockerfiles.
TAG=$ECR_DEPLOY_URL/$PARENT_REPO
docker tag $PARENT_IMAGE_URI $TAG
Expand All @@ -112,10 +108,7 @@ COMMIT_TAG_VERSION=$(extract_tag_version $REPOSITORY false)
echo "Commit tag version: $COMMIT_TAG_VERSION"

# Build the actual image and give it a commit tag.
IMAGE_COMMIT_URI=$ECR_URL/$REPOSITORY:cache-$CONTENT_HASH
if [[ -n "$ARCH" ]]; then
IMAGE_COMMIT_URI=$IMAGE_COMMIT_URI-$ARCH
fi
IMAGE_COMMIT_URI=$(calculate_image_uri $REPOSITORY)
echo "Building image: $IMAGE_COMMIT_URI"
docker build -t $IMAGE_COMMIT_URI -f $DOCKERFILE --build-arg COMMIT_TAG=$COMMIT_TAG_VERSION --build-arg ARG_CONTENT_HASH=$CONTENT_HASH .
echo "Pushing image: $IMAGE_COMMIT_URI"
Expand Down
9 changes: 9 additions & 0 deletions build-system/scripts/calculate_image_tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

REPOSITORY=$1
ARCH=${2:-$(uname -m)}
[ "$ARCH" == "aarch64" ] && ARCH=arm64
CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
echo "cache-$CONTENT_HASH-$ARCH"
4 changes: 3 additions & 1 deletion build-system/scripts/calculate_image_uri
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
set -eu

REPOSITORY=$1
ARCH=${2:-$(uname -m)}
[ "$ARCH" == "aarch64" ] && ARCH=arm64
CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
echo "$ECR_URL/$REPOSITORY:cache-$CONTENT_HASH"
echo "$ECR_URL/$REPOSITORY:cache-$CONTENT_HASH-$ARCH"
18 changes: 0 additions & 18 deletions build-system/scripts/check_npm_version

This file was deleted.

12 changes: 8 additions & 4 deletions build-system/scripts/cond_run_compose
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ REPOSITORY=$1
COMPOSE_FILE=$2
shift 2

CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
BASE_TAG=cache-$CONTENT_HASH
BASE_TAG=$(calculate_image_tag $REPOSITORY)
SUCCESS_TAG=$BASE_TAG-$JOB_NAME

echo "Content hash: $CONTENT_HASH"
echo "Success tag: $SUCCESS_TAG"

if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
# Login to pull our ecr images with docker.
Expand All @@ -27,7 +26,12 @@ if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
cd $(query_manifest projectDir $REPOSITORY)

export $@
docker-compose -f $COMPOSE_FILE up --exit-code-from $REPOSITORY --force-recreate
if docker compose > /dev/null 2>&1; then
CMD="docker compose"
else
CMD="docker-compose"
fi
$CMD -f $COMPOSE_FILE up --exit-code-from $REPOSITORY --force-recreate

upload_logs_to_s3 log

Expand Down
5 changes: 2 additions & 3 deletions build-system/scripts/cond_run_container
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ set -eu
REPOSITORY=$1
shift

CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
BASE_TAG=cache-$CONTENT_HASH
BASE_TAG=$(calculate_image_tag $REPOSITORY)
SUCCESS_TAG=$BASE_TAG-$JOB_NAME

echo "Content hash: $CONTENT_HASH"
echo "Success tag: $SUCCESS_TAG"

if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
IMAGE_URI=$(calculate_image_uri $REPOSITORY)
Expand Down
5 changes: 2 additions & 3 deletions build-system/scripts/cond_run_script
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ set -eu
REPOSITORY=$1
shift

CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
BASE_TAG=cache-$CONTENT_HASH
BASE_TAG=$(calculate_image_tag $REPOSITORY)
SUCCESS_TAG=$BASE_TAG-$JOB_NAME

echo "Content hash: $CONTENT_HASH"
echo "Success tag: $SUCCESS_TAG"

if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
init_submodules $REPOSITORY
Expand Down
5 changes: 3 additions & 2 deletions build-system/scripts/cond_spot_run_build
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu
set -euo pipefail

REPOSITORY=$1
CPUS=$2
ARCH=${3:-}

cond_spot_run_script $REPOSITORY $CPUS build $REPOSITORY
cond_spot_run_script $REPOSITORY $CPUS:$ARCH build $REPOSITORY $ARCH | add_timestamps
10 changes: 6 additions & 4 deletions build-system/scripts/cond_spot_run_script
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ REPOSITORY=$1
CPUS=$2
shift 2

CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
BASE_TAG=cache-$CONTENT_HASH
# If the CPUS have a specific architecture assigned, we need to use that to build the success tag.
ARR=(${CPUS//:/ })
ARCH=${ARR[1]:-x86_64}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to keep this long term, will not block this pr

BASE_TAG=$(calculate_image_tag $REPOSITORY $ARCH)
SUCCESS_TAG=$BASE_TAG

if [ -n "${TAG_POSTFIX:-}" ]; then
SUCCESS_TAG=$BASE_TAG-$TAG_POSTFIX
fi

echo "Content hash: $CONTENT_HASH"
echo "Success tag: $SUCCESS_TAG"

if ! check_rebuild $SUCCESS_TAG $REPOSITORY; then
init_submodules $REPOSITORY
spot_run_script $CONTENT_HASH $CPUS $@
spot_run_script $SUCCESS_TAG $CPUS $@
retry tag_remote_image $REPOSITORY $BASE_TAG $SUCCESS_TAG
fi
2 changes: 1 addition & 1 deletion build-system/scripts/cond_spot_run_test
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ SCRIPT=$(query_manifest relativeProjectDir $REPOSITORY)/$SCRIPT

# Specify a TAG_POSTFIX as the JOB_NAME
mkdir -p /tmp/test-logs
export TAG_POSTFIX=$JOB_NAME
export TAG_POSTFIX=$JOB_NAME
cond_spot_run_script $REPOSITORY $CPUS $SCRIPT $@ | tee "/tmp/test-logs/$JOB_NAME.log"
58 changes: 0 additions & 58 deletions build-system/scripts/create_dockerhub_manifest

This file was deleted.

23 changes: 9 additions & 14 deletions build-system/scripts/create_ecr_manifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,20 @@ set -eu
REPOSITORY=$1
ARCH_LIST=$2

# Ensure ECR repository exists.
retry ensure_repo $REPOSITORY $ECR_REGION refresh_lifecycle
ecr_login

IMAGE_URI=$(calculate_image_uri $REPOSITORY)
echo "Image URI: $IMAGE_URI"
CONTENT_HASH=$(calculate_content_hash $REPOSITORY)
MULTIARCH_IMAGE_URI=$ECR_URL/$REPOSITORY:cache-$CONTENT_HASH

echo "Creating manifest list..."
echo "Multi-arch Image URI: $MULTIARCH_IMAGE_URI"

export DOCKER_CLI_EXPERIMENTAL=enabled

OLD_IFS=$IFS
IFS=','
for A in $ARCH_LIST
do
ARCH_IMAGE=$IMAGE_URI-$A
echo "Adding image $ARCH_IMAGE to manifest list."
retry docker manifest create $IMAGE_URI --amend $ARCH_IMAGE
for A in $ARCH_LIST; do
IMAGE_URI=$(calculate_image_uri $REPOSITORY $A)
echo "Adding image $IMAGE_URI to manifest list $MULTIARCH_IMAGE_URI..."
docker manifest create $MULTIARCH_IMAGE_URI --amend $IMAGE_URI
done
IFS=$OLD_IFS
unset OLD_IFS

retry docker manifest push --purge $IMAGE_URI
retry docker manifest push --purge $MULTIARCH_IMAGE_URI
2 changes: 1 addition & 1 deletion build-system/scripts/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if check_rebuild cache-$CONTENT_HASH-$DEPLOY_TAG-deployed $REPOSITORY; then
exit 0
fi

deploy_terraform $REPOSITORY ./terraform/$VERSION_TAG "$TO_TAINT"
deploy_terraform $REPOSITORY ./terraform/$DEPLOY_ENV "$TO_TAINT"

# Restart services.
for SERVICE in $SERVICES; do
Expand Down
Loading