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

chore: Add noir_wasm testing workflow #1921

Merged
merged 34 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3e9e46c
Edit workflow
jonybur Jul 13, 2023
1e906d4
Output built directory
jonybur Jul 13, 2023
39a8434
Fix noir_wasm copy
jonybur Jul 13, 2023
1d3d30e
Fix workflow
jonybur Jul 14, 2023
b71f94c
Add mkdir to workflow
jonybur Jul 14, 2023
e362da8
Merge branch 'master' of github.com:noir-lang/noir into jb/noir-testi…
jonybur Jul 24, 2023
7473ce7
Remove logs
jonybur Jul 24, 2023
5029bad
Merge branch 'master' into jb/noir-testing-workflow
TomAFrench Jul 28, 2023
4e0a050
chore: Ensure that CLI and wasm compilers are sync in `noir_wasm_test…
TomAFrench Aug 4, 2023
6c320e1
Update .github/workflows/wasm.yml
TomAFrench Aug 4, 2023
0d2d438
Merge branch 'master' into jb/noir-testing-workflow
TomAFrench Aug 4, 2023
e33058f
chore: run browser tests rather than nodejs tests
TomAFrench Aug 4, 2023
99ba717
chore: fix test command in CI
TomAFrench Aug 4, 2023
778b095
chore: bring noir-wasm-testing repo contents into wasm crate
TomAFrench Aug 4, 2023
8a545c6
chore: update compile command to handle not being at repo root
TomAFrench Aug 4, 2023
c31e681
chore: remove unnecessary checkout
TomAFrench Aug 4, 2023
f283748
chore: update location to look for nargo binary
TomAFrench Aug 4, 2023
bea37a1
chore: add missing $
TomAFrench Aug 4, 2023
978551d
chore: remove self-referential dependency
TomAFrench Aug 4, 2023
9552903
chore: switch to `noir-lang/noir-source-resolver` version which exists
TomAFrench Aug 4, 2023
d693242
chore: place downloaded wasm artifact in `crates/wasm` so it can reso…
TomAFrench Aug 4, 2023
f4a94a9
Revisions
jonybur Aug 7, 2023
cdc4ab1
Merge branch 'jb/noir-testing-workflow' of github.com:noir-lang/noir …
jonybur Aug 7, 2023
7eb2668
chore: fix CI workflow
TomAFrench Aug 7, 2023
1dd0d58
chore: remove usage of `matrix.target`
TomAFrench Aug 7, 2023
ed04d05
chore: fix path to binary
TomAFrench Aug 7, 2023
fc4571d
chore: remove unwanted printing when compiling noir program
TomAFrench Aug 7, 2023
62b5947
chore: update `Nargo.toml` to be compliant with new format
TomAFrench Aug 7, 2023
98ed3fd
chore: remove unnecessary checkout
TomAFrench Aug 7, 2023
b6eac52
chore: add todo to workflow
TomAFrench Aug 7, 2023
1b7eca9
Merge branch 'master' into jb/noir-testing-workflow
TomAFrench Aug 7, 2023
8d1758f
Update .github/workflows/wasm.yml
TomAFrench Aug 7, 2023
5bba829
Update crates/wasm/noir-script/src/main.nr
TomAFrench Aug 7, 2023
6ae95f4
Update crates/wasm/test/browser/index.test.ts
TomAFrench Aug 7, 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
15 changes: 15 additions & 0 deletions .github/Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[build]
# pre-build = [
# "dpkg --add-architecture $CROSS_DEB_ARCH",
# "apt-get update && apt-get install --assume-yes xz-utils pkgconfig build-essential cmake openssl libssl-dev libomp-dev libssl-dev:$CROSS_DEB_ARCH libomp-dev:$CROSS_DEB_ARCH",
# ]

[build.env]
passthrough = [
"HOME",
"RUST_BACKTRACE",
"BARRETENBERG_BIN_DIR"
]
volumes = [
"HOME",
]
178 changes: 172 additions & 6 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,193 @@
name: Wasm

on:
pull_request:
merge_group:
push:
branches:
- jb/noir-testing-workflow
- tom/noir-wasm-testing
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
name: Build Wasm
build-barretenberg:
runs-on: ubuntu-latest
steps:
- name: Checkout Noir repo
uses: actions/checkout@v3

- name: Checkout Build Nargo repo
uses: actions/checkout@v3
with:
repository: noir-lang/build-nargo
path: build-nargo
ref: ${{ inputs.build-nargo-ref || 'master' }}

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

- 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: |
echo "BB_REV is ${{ env.BB_REV }}"
nix build "github:AztecProtocol/barretenberg/${{ 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

build-nargo:
needs: [build-barretenberg]
runs-on: ubuntu-22.04
env:
CROSS_CONFIG: ${{ github.workspace }}/.github/Cross.toml
strategy:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-gnu]
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout Noir repo
uses: actions/checkout@v3

- name: Checkout Build Nargo repo
uses: actions/checkout@v3
with:
repository: noir-lang/build-nargo
path: build-nargo
ref: ${{ inputs.build-nargo-ref || 'master' }}

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: libbarretenberg-wasm32
path: ${{ github.workspace }}/libbarretenberg-wasm32

- name: Setup toolchain
uses: dtolnay/[email protected]
with:
targets: ${{ matrix.target }}

- name: Build Nargo
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
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved

- name: Package artifacts
run: |
mkdir dist
cp ./target/${{ matrix.target }}/release/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-${{ matrix.target }}.tar.gz

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nargo
path: ./dist/*
retention-days: 3

build-wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup Nix
uses: cachix/install-nix-action@v22
- uses: cachix/install-nix-action@v20
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
with:
nix_path: nixpkgs=channel:nixos-22.11
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build wasm package
run: |
nix build -L .#wasm

- name: Dereference symlink
run: echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: noir_wasm
path: ${{ env.UPLOAD_PATH }}
retention-days: 3

test:
needs: [build-wasm, build-nargo]
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout noir-wasm-testing
uses: actions/checkout@v3
with:
repository: noir-lang/noir-wasm-testing

- name: Download wasm package artifact
uses: actions/download-artifact@v3
with:
name: noir_wasm
path: ./@noir-lang_noir_wasm

- name: Inject built wasm into noir-wasm-testing
run: |
jq '.dependencies["@noir-lang/noir_wasm"] = "file:./@noir-lang_noir_wasm"' ./package.json > ./package.json.tmp
mv ./package.json.tmp ./package.json

- name: Download nargo binary
uses: actions/download-artifact@v3
with:
name: nargo
path: ./nargo

- name: Install dependencies and Run noir-wasm-testing program
run: |
nargo_binary=$(find $(pwd) -name "nargo" -type f)
echo "nargo binary found at $nargo_binary."
ls -l $nargo_binary
echo "Attempting to make nargo binary executable:"
chmod +x $nargo_binary || echo "chmod failed with exit code $?"
echo "File permissions after chmod:"
ls -l $nargo_binary
echo "Library dependencies of nargo binary:"
ldd $nargo_binary
if [ -x "$nargo_binary" ]; then
$nargo_binary -p "${{ github.workspace }}/src/noir-script" compile noir-wasm-testing
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
else
echo "nargo binary NOT found or is not executable."
exit 1
fi

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test