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: CI to test aztec circuits with current commit of bberg #418

Merged
merged 20 commits into from
May 4, 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
2 changes: 1 addition & 1 deletion .circleci/cond_spot_run_build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ LAST_SUCCESSFUL_COMMIT=$(last_successful_commit $REPOSITORY)
echo "Last successful commit: $LAST_SUCCESSFUL_COMMIT"

if check_rebuild "$LAST_SUCCESSFUL_COMMIT" $REPOSITORY; then
spot_run_script $SPEC ../.circleci/remote_build/remote_build $REPOSITORY $@
spot_run_script $SPEC $BUILD_SYSTEM_PATH/remote_build/remote_build $REPOSITORY $@
else
echo "No rebuild necessary. Retagging..."
STAGES=$(cat $DOCKERFILE | sed -n -e 's/^FROM .* AS \(.*\)/\1/p')
Expand Down
13 changes: 13 additions & 0 deletions .circleci/cond_spot_run_test_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
REPOSITORY=$1
SCRIPT_PATH=$2
shift
shift

cd $(query_manifest projectDir $REPOSITORY)

mkdir -p /tmp/test-logs

set -o pipefail
cond_spot_run_script $REPOSITORY $JOB_NAME 32 $SCRIPT_PATH $@ | tee "/tmp/test-logs/$JOB_NAME.log"
69 changes: 68 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ benchmark_add_keys: &benchmark_add_keys
setup_env: &setup_env
run:
name: "Setup environment"
command: cd .circleci && ./setup_env "$CIRCLE_SHA1" "$CIRCLE_TAG" "$CIRCLE_JOB" "$CIRCLE_REPOSITORY_URL" "$CIRCLE_BRANCH"
command: |
cd .circleci && ./setup_env "$CIRCLE_SHA1" "$CIRCLE_TAG" "$CIRCLE_JOB" "$CIRCLE_REPOSITORY_URL" "$CIRCLE_BRANCH"

setup_aztec_commit: &setup_aztec_commit
run:
name: "Setup environment for Aztec Integration Testing"
command: |
# Load the aztec commit into env for use in integration tests
echo "export AZTEC_COMMIT=$(cat cpp/.aztec-packages-commit 2>/dev/null || echo master)" >> "$BASH_ENV"
source "$BASH_ENV"

# This step is used to save logs from various barretenberg test to the workspace so that they can be used later to parse benchmark values out of them
save_logs: &save_logs
Expand Down Expand Up @@ -235,6 +244,56 @@ jobs:
name: "Test"
command: store_test_benchmark_logs barretenberg-x86_64-linux-clang-assert

###################################
# Aztec integration tests
circuits-wasm-linux-clang-builder-runner:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build barretenberg-circuits-wasm-linux-clang-builder-runner 64

circuits-x86_64-linux-clang-builder-runner:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- run:
name: "Build"
command: cond_spot_run_build barretenberg-circuits-x86_64-linux-clang-builder-runner 64

circuits-wasm-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- *setup_aztec_commit
- run:
name: "Build"
command: cond_spot_run_test_script barretenberg-circuits-wasm-linux-clang-builder-runner ./scripts/run_aztec_circuits_tests "$AZTEC_COMMIT" 1 wasm scripts/a3-tests -*.skip*:*.circuit*

circuits-x86_64-tests:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
steps:
- *checkout
- *setup_env
- *setup_aztec_commit
- run:
name: "Build"
command: cond_spot_run_test_script barretenberg-circuits-x86_64-linux-clang-builder-runner ./scripts/run_aztec_circuits_tests "$AZTEC_COMMIT" 1 x86_64 scripts/a3-tests -*.skip*
# End Aztec integration tests
###################################

# Repeatable config for defining the workflow below.
bb_test: &bb_test
requires:
Expand Down Expand Up @@ -266,3 +325,11 @@ workflows:
branches:
only:
- master
- circuits-wasm-linux-clang-builder-runner
- circuits-x86_64-linux-clang-builder-runner
- circuits-wasm-tests:
requires:
- circuits-wasm-linux-clang-builder-runner
- circuits-x86_64-tests:
requires:
- circuits-x86_64-linux-clang-builder-runner
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,9 @@ Alternatively you can build separate test binaries, e.g. honk_tests or numeric_t
### VS Code configuration

A default configuration for VS Code is provided by the file [`barretenberg.code-workspace`](barretenberg.code-workspace). These settings can be overridden by placing configuration files in `.vscode/`.

### Integration tests with Aztec Circuits

CI will automatically run integration tests against Aztec's circuits which live [here](https://github.com/AztecProtocol/aztec-packages/tree/master/circuits). To change which Aztec branch or commit for CI to test against, modify [`.aztec-packages-commit`](./cpp/.aztec-packages-commit).

When working on a PR, you may want to point this file to a adifferent Aztec branch or commit, but then it should probably be pointed back to master before merging.
16 changes: 11 additions & 5 deletions build_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
"rebuildPatterns": ["^cpp/"],
"dependencies": []
},
"barretenberg.js": {
"buildDir": "js",
"dockerfile": "js/Dockerfile",
"rebuildPatterns": ["^js/"],
"dependencies": ["barretenberg-wasm-linux-clang"]
"barretenberg-circuits-x86_64-linux-clang-builder-runner": {
"buildDir": "cpp",
"dockerfile": "dockerfiles/Dockerfile.circuits-x86_64-linux-clang-builder-runner",
"rebuildPatterns": ["^cpp/"],
"dependencies": []
},
"barretenberg-circuits-wasm-linux-clang-builder-runner": {
"buildDir": "cpp",
"dockerfile": "dockerfiles/Dockerfile.circuits-wasm-linux-clang-builder-runner",
"rebuildPatterns": ["^cpp/"],
"dependencies": []
}
}
1 change: 1 addition & 0 deletions cpp/.aztec-packages-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
master
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:kinetic
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y bash build-essential git libssl-dev cmake ninja-build curl binaryen xz-utils curl

RUN curl https://wasmtime.dev/install.sh -sSf | bash /dev/stdin --version v3.0.1
WORKDIR /usr/src/barretenberg/cpp/src
RUN curl -s -L https://github.com/CraneStation/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz | tar zxfv -
WORKDIR /usr/src/barretenberg/cpp
COPY . .
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM alpine:3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
bash \
build-base \
clang15 \
openmp \
openmp-dev \
cmake \
ninja \
git \
curl \
perl

WORKDIR /usr/src/barretenberg/cpp

COPY . .
52 changes: 52 additions & 0 deletions cpp/scripts/run_aztec_circuits_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -e

# To be called from CI for testing with docker and AWS.
# Can't be called locally unless AWS credentials are set up.
#
# Call from config.yml
# Example:
# command: cond_spot_run_script circuits-wasm-linux-clang-assert 1 wasm scripts/a3-tests -*.skip*:*.circuit*

AZTEC_COMMIT=$1 # Aztec commit/branch to checkout (MANDATORY)
NUM_TRANSCRIPTS=$2 # integer (MANDATORY)
ARCH=$3 # x86_64 or wasm (MUST BE LOWERCASE) (MANDATORY) used in aztec's circuits `run_tests_local`
# TESTS=$4 (MANDATORY) used in aztec's circuits `run_tests_local` (test files rel to circuits/cpp)
# GTEST_FILTER=$5 (optional) used in aztec's circuits `run_tests_local`
# *** See `run_tests_local` for the args forwarded to that script
shift # arg1 (aztec commit) and arg2 (num transcripts) are not forwarded
shift # to aztec's circuits `run_tests_local`

$(aws ecr get-login --region us-east-2 --no-include-email) 2> /dev/null

IMAGE_URI=278380418400.dkr.ecr.us-east-2.amazonaws.com/barretenberg-circuits-${ARCH}-linux-clang-builder-runner:cache-$COMMIT_HASH
docker pull $IMAGE_URI

if [ "$ARCH" != "wasm" ]; then
# x86_64 / anything other than wasm
PRESET=default
CONFIGURE_OPTS="-DCMAKE_BUILD_TYPE=RelWithAssert -DCI=ON"
BUILD_DIR=build
else
PRESET=wasm
BUILD_DIR=build-wasm
fi

echo "*** Running Aztec circuits tests on commit: $AZTEC_COMMIT"
# run tests in docker
RUN_ARGS="$@" # helper var necessary for some reason to pass all args to docker run
docker run --rm -t $IMAGE_URI /bin/sh -c "\
set -e; \
cd /usr/src/; \
git clone https://github.com/AztecProtocol/aztec3-packages.git; \
cd /usr/src/aztec3-packages/circuits/cpp; \
git checkout $AZTEC_COMMIT; \
rm -rf /usr/src/aztec3-packages/circuits/cpp/barretenberg;
mv /usr/src/barretenberg .; \
cmake --preset $PRESET $CONFIGURE_OPTS; \
cmake --build --preset $PRESET; \
cd /usr/src/aztec3-packages/circuits/cpp/barretenberg/cpp/srs_db; \
./download_ignition.sh $NUM_TRANSCRIPTS; \
dbanks12 marked this conversation as resolved.
Show resolved Hide resolved
cd /usr/src/aztec3-packages/circuits/cpp; \
export PATH=\$PATH:~/.wasmtime/bin/; \
./scripts/run_tests_local $RUN_ARGS;"