Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

fix: WASM provided by nix build of barretenberg #24

Merged
merged 20 commits into from
Apr 28, 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
1 change: 1 addition & 0 deletions .github/Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
passthrough = [
"HOME",
"RUST_BACKTRACE",
"BARRETENBERG_BIN_DIR"
]
volumes = [
"HOME",
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/nix-barretenberg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: libbarretenberg

on:
workflow_dispatch:
inputs:
noir-ref:
description: The noir reference to checkout
required: false
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
push:

jobs:
build-barretenberg:
runs-on: ubuntu-latest
steps:
- name: Checkout Noir repo
uses: actions/checkout@v3
with:
repository: noir-lang/noir
path: noir
ref: ${{ inputs.noir-ref || 'master' }}

- name: Collect locked barretenberg rev
run: |
echo "BB_REV=$(jq -r .nodes.barretenberg.locked.rev ./noir/flake.lock)" >> $GITHUB_ENV

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-22.11
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- uses: cachix/cachix-action@v12
with:
name: barretenberg
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

# Upload does not work with symlinks, using this workaround:
# https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032
- name: Build barretenberg as libbarretenberg-wasm32
run: |
nix build "git+https://github.com/AztecProtocol/barretenberg?rev=${{ env.BB_REV }}#wasm32"
echo "ARTIFACT_UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: libbarretenberg-wasm32
path: ${{ env.ARTIFACT_UPLOAD_PATH }}
retention-days: 3
26 changes: 16 additions & 10 deletions .github/workflows/publish-apple-darwin-wasm.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: build-apple-darwin

on:
workflow_dispatch:
inputs:
noir-ref:
description: The noir reference to checkout
required: false
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
push:
workflow_run:
phated marked this conversation as resolved.
Show resolved Hide resolved
workflows:
- libbarretenberg
types:
- completed

jobs:
build-apple-darwin:
Expand Down Expand Up @@ -45,13 +42,23 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# We use an unofficial download plugin to support cross-workflow downloads
# Ref https://github.com/actions/download-artifact/issues/172
- name: Download artifact
phated marked this conversation as resolved.
Show resolved Hide resolved
uses: dawidd6/action-download-artifact@v2
phated marked this conversation as resolved.
Show resolved Hide resolved
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success

- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.66.0
with:
targets: ${{ matrix.target }}

- name: Build environment and Compile
working-directory: noir
env:
BARRETENBERG_BIN_DIR: ${{ github.workspace }}/libbarretenberg-wasm32/bin
run: |
cargo build --package nargo_cli --release --target ${{ matrix.target }} --no-default-features --features plonk_bn254_wasm

Expand All @@ -73,7 +80,6 @@ jobs:
if: matrix.target == 'x86_64-apple-darwin'
run: |
cp ./noir/target/${{ matrix.target }}/release/nargo ~/.cargo/bin/

npm install
npm test

Expand All @@ -91,7 +97,7 @@ jobs:
# If we're performing a nightly build and it fails acceptance tests then raise an issue.
- name: Alert on nightly build failure
uses: JasonEtco/create-an-issue@v2
if: ${{ failure() && github.event_name == 'schedule' }}
if: ${{ failure() && github.event_name == 'schedule' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: ${{ github.workflow }}
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/publish-linux.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: build-linux

on:
workflow_dispatch:
inputs:
noir-ref:
description: The noir reference to checkout
required: false
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
push:
workflow_run:
workflows:
- libbarretenberg
types:
- completed

env:
CROSS_CONFIG: ${{ github.workspace }}/.github/Cross.toml
Expand Down Expand Up @@ -48,13 +45,24 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# We use an unofficial download plugin to support cross-workflow downloads
# Ref https://github.com/actions/download-artifact/issues/172
- name: Download artifact
id: libbarretenberg-download
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success

- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.66.0
with:
targets: ${{ matrix.target }}

- name: Build Nargo
working-directory: noir
env:
BARRETENBERG_BIN_DIR: ${{ github.workspace }}/libbarretenberg-wasm32/bin
run: |
cargo install cross --force --git https://github.com/cross-rs/cross
cross build --package nargo_cli --release --target=${{ matrix.target }} --no-default-features --features plonk_bn254_wasm
Expand Down Expand Up @@ -90,7 +98,7 @@ jobs:
asset_name: nargo-${{ matrix.target }}.tar.gz
overwrite: true
tag: ${{ inputs.noir-ref || 'nightly' }} # This will fail if noir-ref is not a tag (e.g. testing a branch)

# If we're performing a nightly build and it fails acceptance tests then raise an issue.
- name: Alert on nightly build failure
uses: JasonEtco/create-an-issue@v2
Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/publish-x86_64-pc-windows-wasm.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# such target does not exist, name choosen for convention only
name: build-x86_64-pc-windows-wasm
# <arch>-<vendor>-<os>-<env>

on:
workflow_dispatch:
inputs:
noir-ref:
description: The noir reference to checkout
required: false
schedule:
- cron: "0 2 * * *" # run at 2 AM UTC
push:
workflow_run:
workflows:
- libbarretenberg
types:
- completed

jobs:
build-x86_64-pc-windows-msvc:
Expand Down Expand Up @@ -40,13 +36,23 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# We use an unofficial download plugin to support cross-workflow downloads
# Ref https://github.com/actions/download-artifact/issues/172
- name: Download artifact
phated marked this conversation as resolved.
Show resolved Hide resolved
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success

- name: Setup toolchain
uses: dtolnay/rust-toolchain@1.66.0
with:
targets: ${{ matrix.target }}

- name: Build environment and Compile
working-directory: noir
env:
BARRETENBERG_BIN_DIR: ${{ github.workspace }}/libbarretenberg-wasm32/bin
run: |
cargo build --package nargo_cli --release --target ${{ matrix.target }} --no-default-features --features plonk_bn254_wasm

Expand Down Expand Up @@ -82,7 +88,7 @@ jobs:
asset_name: nargo-${{ matrix.target }}.zip
overwrite: true
tag: ${{ inputs.noir-ref || 'nightly' }} # This will fail if noir-ref is not a tag (e.g. testing a branch)

# If we're performing a nightly build and it fails acceptance tests then raise an issue.
- name: Alert on nightly build failure
uses: JasonEtco/create-an-issue@v2
Expand Down