diff --git a/.github/Cross.toml b/.github/Cross.toml index a0db9c5..72c7386 100644 --- a/.github/Cross.toml +++ b/.github/Cross.toml @@ -8,6 +8,7 @@ passthrough = [ "HOME", "RUST_BACKTRACE", + "BARRETENBERG_BIN_DIR" ] volumes = [ "HOME", diff --git a/.github/workflows/nix-barretenberg.yml b/.github/workflows/nix-barretenberg.yml new file mode 100644 index 0000000..a643131 --- /dev/null +++ b/.github/workflows/nix-barretenberg.yml @@ -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 diff --git a/.github/workflows/publish-apple-darwin-wasm.yml b/.github/workflows/publish-apple-darwin-wasm.yml index a2bb696..3151822 100644 --- a/.github/workflows/publish-apple-darwin-wasm.yml +++ b/.github/workflows/publish-apple-darwin-wasm.yml @@ -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: + workflows: + - libbarretenberg + types: + - completed jobs: build-apple-darwin: @@ -45,6 +42,14 @@ 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 + 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: @@ -52,6 +57,8 @@ jobs: - 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 @@ -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 @@ -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 }} diff --git a/.github/workflows/publish-linux.yml b/.github/workflows/publish-linux.yml index e3d9899..b6d4ff3 100644 --- a/.github/workflows/publish-linux.yml +++ b/.github/workflows/publish-linux.yml @@ -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 @@ -48,6 +45,15 @@ 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: @@ -55,6 +61,8 @@ jobs: - 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 @@ -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 diff --git a/.github/workflows/publish-x86_64-pc-windows-wasm.yml b/.github/workflows/publish-x86_64-pc-windows-wasm.yml index f35e665..54f8fcc 100644 --- a/.github/workflows/publish-x86_64-pc-windows-wasm.yml +++ b/.github/workflows/publish-x86_64-pc-windows-wasm.yml @@ -1,16 +1,12 @@ # such target does not exist, name choosen for convention only name: build-x86_64-pc-windows-wasm -# --- 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: @@ -40,6 +36,14 @@ 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 + 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: @@ -47,6 +51,8 @@ jobs: - 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 @@ -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