Skip to content

Commit

Permalink
test: share e2e code with canary (#2299)
Browse files Browse the repository at this point in the history
Fixes #2054 
Refactoring so that CLI & Browser e2e tests share code from `end-to-end`
  • Loading branch information
spypsy authored Sep 16, 2023
1 parent de8240f commit 21224de
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 833 deletions.
50 changes: 38 additions & 12 deletions build_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,83 @@
},
"bb.js": {
"buildDir": "barretenberg/ts",
"dependencies": ["barretenberg-wasm-linux-clang"]
"dependencies": [
"barretenberg-wasm-linux-clang"
]
},
"barretenberg-acir-tests-bb": {
"buildDir": "barretenberg/acir_tests",
"dockerfile": "Dockerfile.bb",
"dependencies": ["barretenberg-x86_64-linux-clang-assert"]
"dependencies": [
"barretenberg-x86_64-linux-clang-assert"
]
},
"barretenberg-acir-tests-bb.js": {
"buildDir": "barretenberg/acir_tests",
"dockerfile": "Dockerfile.bb.js",
"dependencies": ["bb.js"]
"dependencies": [
"bb.js"
]
},
"circuits-wasm-linux-clang": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.wasm-linux-clang",
"rebuildPatterns": ".rebuild_patterns",
"dependencies": ["barretenberg-wasm-linux-clang"]
"dependencies": [
"barretenberg-wasm-linux-clang"
]
},
"circuits-wasm-linux-clang-assert": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.wasm-linux-clang-assert",
"rebuildPatterns": ".rebuild_patterns",
"dependencies": ["barretenberg-wasm-linux-clang"]
"dependencies": [
"barretenberg-wasm-linux-clang"
]
},
"circuits-x86_64-linux-clang-tidy": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-tidy",
"rebuildPatterns": ".rebuild_patterns",
"dependencies": ["barretenberg-x86_64-linux-clang"]
"dependencies": [
"barretenberg-x86_64-linux-clang"
]
},
"circuits-x86_64-linux-clang": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang",
"rebuildPatterns": ".rebuild_patterns",
"dependencies": ["barretenberg-x86_64-linux-clang"]
"dependencies": [
"barretenberg-x86_64-linux-clang"
]
},
"circuits-x86_64-linux-clang-assert": {
"buildDir": "circuits/cpp",
"dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-assert",
"rebuildPatterns": ".rebuild_patterns",
"dependencies": ["barretenberg-x86_64-linux-clang"]
"dependencies": [
"barretenberg-x86_64-linux-clang"
]
},
"docs": {
"buildDir": ".",
"dockerfile": "docs/Dockerfile",
"rebuildPatterns": ["^docs/", "^.*.cpp$", "^.*.ts$"]
"rebuildPatterns": [
"^docs/",
"^.*.cpp$",
"^.*.ts$"
]
},
"l1-contracts": {
"buildDir": "l1-contracts"
},
"l1-artifacts": {
"buildDir": "yarn-project",
"projectDir": "yarn-project/l1-artifacts",
"rebuildPatterns": ["^l1-contracts/", "^yarn-project/l1-artifacts/"],
"rebuildPatterns": [
"^l1-contracts/",
"^yarn-project/l1-artifacts/"
],
"dependencies": []
},
"yarn-project-base": {
Expand All @@ -94,7 +117,10 @@
"^yarn-project/yarn-project-base/",
"^yarn-project/yarn.lock"
],
"dependencies": ["circuits-wasm-linux-clang", "l1-contracts"]
"dependencies": [
"circuits-wasm-linux-clang",
"l1-contracts"
]
},
"acir-simulator": {
"buildDir": "yarn-project",
Expand Down Expand Up @@ -212,4 +238,4 @@
"buildDir": "yarn-project",
"projectDir": "yarn-project/world-state"
}
}
}
2 changes: 1 addition & 1 deletion circuits/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@
"inherits": "wasm"
}
]
}
}
27 changes: 20 additions & 7 deletions yarn-project/canary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
FROM node:18-alpine
FROM 278380418400.dkr.ecr.us-east-2.amazonaws.com/yarn-project-base AS builder

RUN apk update && apk add --no-cache udev ttf-freefont chromium curl jq bash
ENV CHROME_BIN="/usr/bin/chromium-browser" PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"

ARG COMMIT_TAG=""
ARG COMMIT_TAG="0.7.5"

COPY . .

# Setup & Build end-to-end package
WORKDIR /usr/src/yarn-project/end-to-end

# Extract canary @aztec dependencies
RUN ../canary/scripts/extract_packages.sh ../canary/package.json > ./target_pkgs.txt
# Update end-to-end dependencies with target version
RUN ./scripts/setup_canary.sh $COMMIT_TAG ./target_pkgs.txt
RUN rm ./target_pkgs.txt
RUN yarn && yarn build

#Build canary
WORKDIR /usr/src/
COPY ./canary .
# Build canary package
WORKDIR /usr/src/yarn-project/canary
RUN ./scripts/update_packages.sh $COMMIT_TAG
RUN yarn && yarn build

RUN cp node_modules/@aztec/aztec.js/dest/main.js src/web/
RUN cp node_modules/@aztec/circuits.js/resources/aztec3-circuits.wasm src/web/
# Copy web artifacts for browser test
RUN cp ./node_modules/@aztec/aztec.js/dest/main.js src/web/
RUN cp ./node_modules/@aztec/circuits.js/resources/aztec3-circuits.wasm src/web/

ENTRYPOINT ["yarn", "test"]
4 changes: 1 addition & 3 deletions yarn-project/canary/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"@aztec/aztec.js": "workspace:^",
"@aztec/cli": "workspace:^",
"@aztec/foundation": "workspace:^",
"@aztec/end-to-end": "workspace:^",
"@aztec/l1-artifacts": "workspace:^",
"@aztec/noir-contracts": "workspace:^",
"@jest/globals": "^29.5.0",
Expand All @@ -33,8 +33,6 @@
"jest": "^29.5.0",
"koa": "^2.14.2",
"koa-static": "^5.0.0",
"puppeteer": "^21.1.0",
"string-argv": "^0.3.2",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.4.0",
Expand Down
11 changes: 11 additions & 0 deletions yarn-project/canary/scripts/extract_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

FILE=$1

# Capture the output of the jq command in a Bash array
mapfile -t TARGET_PKGS < <(jq -r '.dependencies | keys[] | select(startswith("@aztec/") and . != "@aztec/end-to-end")' $FILE)

# Loop through the array and print each element on a new line
for pkg in "${TARGET_PKGS[@]}"; do
echo "$pkg"
done
10 changes: 5 additions & 5 deletions yarn-project/canary/scripts/update_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ set -eu

COMMIT_TAG=$1

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

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

echo "Updating Aztec dependencies to version $VERSION"

TMP=$(mktemp)
for PKG in $(jq --raw-output ".dependencies | keys[] | select(contains(\"@aztec/\"))" package.json); do
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
done

Expand Down
Loading

0 comments on commit 21224de

Please sign in to comment.