Skip to content

Commit

Permalink
feat: Aztec CI files in Noir (#3430)
Browse files Browse the repository at this point in the history
This is a dual-list commit in both Noir and aztec repo. In this PR,
Aztec gets the code to make a mirror, and the mirror action pushes to
our `aztec` branch in Noir. The `aztec` branch features this as the
first commit, to then be pushed one by one from master as Noir changes
come in.

---------

Co-authored-by: ludamad <[email protected]>
  • Loading branch information
2 people authored and AztecBot committed Nov 28, 2023
1 parent 90a6304 commit 6743afc
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Dockerfile*
.dockerignore

packages
**/package.tgz
**/target
**/node_modules
**/outputs

# Source resolver
compiler/source-resolver/lib
compiler/source-resolver/lib-node

# Noir.js
tooling/noir_js/lib

# Wasm build artifacts
compiler/wasm/nodejs
compiler/wasm/web
tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
tooling/noir_js/lib

**/package.tgz
packages

# docs autogen build
/docs/docs/noir_js/reference/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM rust:alpine3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
build-base \
bash
WORKDIR /usr/src/noir
COPY . .
RUN ./scripts/bootstrap_native.sh

# When running the container, mount the current working directory to /project.
FROM alpine:3.17
COPY --from=0 /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
WORKDIR /project
ENTRYPOINT ["/usr/src/noir/target/release/nargo"]
19 changes: 19 additions & 0 deletions Dockerfile.packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:alpine3.17
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
build-base \
pkgconfig \
openssl-dev \
npm \
yarn \
bash \
jq
WORKDIR /usr/src/noir
COPY . .
RUN ./scripts/bootstrap_packages.sh

FROM scratch
COPY --from=0 /usr/src/noir/packages /usr/src/noir/packages
# For some unknown reason, on alpine only, we need this to exist.
COPY --from=0 /usr/src/noir/node_modules/@noir-lang /usr/src/noir/node_modules/@noir-lang
2 changes: 1 addition & 1 deletion acvm-repo/acvm_js/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export CARGO_TARGET_DIR=$self_path/target
rm -rf $self_path/outputs >/dev/null 2>&1
rm -rf $self_path/result >/dev/null 2>&1

if [ -v out ]; then
if [ -n "$out" ]; then
echo "Will install package to $out (defined outside installPhase.sh script)"
else
export out="$self_path/outputs/out"
Expand Down
19 changes: 19 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eu

cd $(dirname "$0")

CMD=${1:-}

if [ -n "$CMD" ]; then
if [ "$CMD" = "clean" ]; then
git clean -fdx
exit 0
else
echo "Unknown command: $CMD"
exit 1
fi
fi

./scripts/bootstrap_native.sh
./scripts/bootstrap_packages.sh
2 changes: 1 addition & 1 deletion compiler/wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export CARGO_TARGET_DIR=$self_path/target
rm -rf $self_path/outputs >/dev/null 2>&1
rm -rf $self_path/result >/dev/null 2>&1

if [ -v out ]; then
if [ -n "$out" ]; then
echo "Will install package to $out (defined outside installPhase.sh script)"
else
export out="$self_path/outputs/out"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test": "yarn workspaces foreach run test",
"test:integration": "yarn workspace integration-tests test",
"clean:workspaces": "yarn workspaces foreach --exclude @noir-lang/root run clean",
"clean:root": "rm -rf ./result ./target",
"clean:root": "rm -rf ./result ./target ./packages",
"clean": "yarn clean:workspaces && yarn clean:root",
"lint": "yarn workspaces foreach --verbose run lint",
"install:acvm_js": "yarn workspace @noir-lang/acvm_js run install:from:nix",
Expand Down
14 changes: 14 additions & 0 deletions scripts/bootstrap_native.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

# If this project has been subrepod into another project, set build data manually.
if [ -f ".gitrepo" ]; then
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
export GIT_COMMIT=$(awk '/commit =/ {print $3}' .gitrepo)
fi

# Build native.
cargo build --features="noirc_frontend/aztec" --release
32 changes: 32 additions & 0 deletions scripts/bootstrap_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

./scripts/install_wasm-bindgen.sh

# If this project has been subrepod into another project, set build data manually.
if [ -f ".gitrepo" ]; then
export SOURCE_DATE_EPOCH=$(date +%s)
export GIT_DIRTY=false
export GIT_COMMIT=$(awk '/commit =/ {print $3}' .gitrepo)
fi

export cargoExtraArgs="--features noirc_frontend/aztec"

yarn
yarn build

# We create a folder called packages, that contains each package as it would be published to npm, named correctly.
# These can be useful for testing, or portaling into other projects.
yarn workspaces foreach pack

rm -rf packages && mkdir -p packages
tar zxfv acvm-repo/acvm_js/package.tgz -C packages && mv packages/package packages/acvm_js
tar zxfv compiler/source-resolver/package.tgz -C packages && mv packages/package packages/source-resolver
tar zxfv compiler/wasm/package.tgz -C packages && mv packages/package packages/noir_wasm
tar zxfv tooling/noir_codegen/package.tgz -C packages && mv packages/package packages/noir_codegen
tar zxfv tooling/noir_js/package.tgz -C packages && mv packages/package packages/noir_js
tar zxfv tooling/noir_js_backend_barretenberg/package.tgz -C packages && mv packages/package packages/backend_barretenberg
tar zxfv tooling/noir_js_types/package.tgz -C packages && mv packages/package packages/types
tar zxfv tooling/noirc_abi_wasm/package.tgz -C packages && mv packages/package packages/noirc_abi
10 changes: 10 additions & 0 deletions scripts/install_wasm-bindgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -eu

cd $(dirname "$0")/..

# Install wasm-bindgen-cli.
if [ "$(wasm-bindgen --version | cut -d' ' -f2)" != "0.2.86" ]; then
echo "Building wasm-bindgen..."
RUSTFLAGS="-Ctarget-feature=-crt-static" cargo install -f wasm-bindgen-cli --version 0.2.86
fi
2 changes: 1 addition & 1 deletion tooling/noirc_abi_wasm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export CARGO_TARGET_DIR=$self_path/target
rm -rf $self_path/outputs >/dev/null 2>&1
rm -rf $self_path/result >/dev/null 2>&1

if [ -v out ]; then
if [ -n "$out" ]; then
echo "Will install package to $out (defined outside installPhase.sh script)"
else
export out="$self_path/outputs/out"
Expand Down

0 comments on commit 6743afc

Please sign in to comment.