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(ci): use nix caching where possible in CI #3278

Closed
wants to merge 15 commits into from
17 changes: 8 additions & 9 deletions .github/workflows/auto-pr-rebuild-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,21 @@ jobs:
- name: Checkout Noir repo
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
- name: Setup Nix
uses: ./.github/actions/nix
with:
key: ${{ matrix.target }}
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build Nargo
run: cargo build --package nargo_cli --release
run: |
nix build -L .

- name: Package artifacts
run: |
mkdir dist
cp ./target/release/nargo ./dist/nargo
cp ./result/bin/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz

- name: Upload artifact
Expand Down
47 changes: 24 additions & 23 deletions .github/workflows/gates_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,25 @@ jobs:
- name: Checkout Noir repo
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
- name: Setup Nix
uses: ./.github/actions/nix
with:
key: ${{ matrix.target }}
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build Nargo
run: cargo build --package nargo_cli --release

- name: Package artifacts
run: |
mkdir dist
cp ./target/release/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz
nix build -L .

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

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nargo
path: ./dist/*
name: nargo-x86_64-unknown-linux-gnu
path: ${{ env.UPLOAD_PATH }}
retention-days: 3


Expand All @@ -51,22 +47,27 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Download nargo binary
uses: actions/download-artifact@v3
with:
name: nargo
path: ./nargo
name: nargo-x86_64-unknown-linux-gnu
path: ./nargo_bin

- name: Set nargo on PATH
run: |
nargo_binary="${{ github.workspace }}/nargo/nargo"
ls -l .

nargo_bin_dir="./nargo_bin"
nargo_binary="$nargo_bin_dir/nargo"
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
export PATH="$PATH:$(dirname $nargo_binary)"
nargo -V
ls -l $nargo_bin_dir

echo "$nargo_bin_dir" >> $GITHUB_PATH
export PATH="$PATH:$nargo_bin_dir"
echo $(which nargo)

nargo --version

- name: Generate gates report
working-directory: ./tooling/nargo_cli/tests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-es-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: ${{ vars.NIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Enable aztec features
if: ${{ inputs.npm-tag == 'aztec' }}
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: ${{ vars.NIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build wasm package
run: |
Expand All @@ -85,7 +85,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: ${{ vars.NIX_CACHE_NAME }}
cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build wasm package
run: |
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/test-abi_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,17 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
env:
CACHED_PATH: /tmp/nix-cache

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup Nix
uses: cachix/install-nix-action@v22
uses: ./.github/actions/nix
with:
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- uses: cachix/cachix-action@v12
with:
name: barretenberg
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build noirc_abi_wasm
run: |
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/test-acvm-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- uses: cachix/install-nix-action@v20
- name: Setup Nix
uses: ./.github/actions/nix
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 }}"
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build acvm-js
run: |
Expand Down
89 changes: 16 additions & 73 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@ jobs:
- name: Checkout Noir repo
uses: actions/checkout@v4

- name: Setup toolchain
uses: dtolnay/[email protected]

- uses: Swatinem/rust-cache@v2
- name: Setup Nix
uses: ./.github/actions/nix
with:
key: ${{ matrix.target }}
cache-on-failure: true
save-if: ${{ github.event_name != 'merge_group' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build Nargo
run: cargo build --package nargo_cli --release
run: |
nix build -L .

- name: Package artifacts
run: |
mkdir dist
cp ./target/release/nargo ./dist/nargo
cp ./result/bin/nargo ./dist/nargo
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz

- name: Upload artifact
Expand All @@ -45,40 +44,22 @@ jobs:

build-wasm:
runs-on: ubuntu-latest
env:
CACHED_PATH: /tmp/nix-cache

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- uses: cachix/cachix-action@v12
uses: ./.github/actions/nix
with:
name: barretenberg
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

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

- name: Export cache from nix store
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
run: |
nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd&parallel-compression=true" .#noir-wasm-cargo-artifacts

- uses: actions/cache/save@v3
# Don't create cache entries for the merge queue.
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
with:
path: ${{ env.CACHED_PATH }}
key: ${{ steps.cache.outputs.cache-primary-key }}

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

Expand All @@ -91,59 +72,24 @@ jobs:

build-noirc:
runs-on: ubuntu-latest
env:
CACHED_PATH: /tmp/nix-cache

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Setup Nix
uses: cachix/install-nix-action@v22
uses: ./.github/actions/nix
with:
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}

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

- name: Restore nix store cache
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ env.CACHED_PATH }}
key: ${{ runner.os }}-flake-abi-wasm-${{ hashFiles('*.lock') }}

# Based on https://github.com/marigold-dev/deku/blob/b5016f0cf4bf6ac48db9111b70dd7fb49b969dfd/.github/workflows/build.yml#L26
- name: Copy cache into nix store
if: steps.cache.outputs.cache-hit == 'true'
# We don't check the signature because we're the one that created the cache
run: |
for narinfo in ${{ env.CACHED_PATH }}/*.narinfo; do
path=$(head -n 1 "$narinfo" | awk '{print $2}')
nix copy --no-check-sigs --from "file://${{ env.CACHED_PATH }}" "$path"
done
github-token: ${{ secrets.GITHUB_TOKEN }}
nix-cache-name: barretenberg
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Build noirc_abi_wasm
run: |
nix build -L .#noirc_abi_wasm
cp -r ./result/noirc_abi_wasm/nodejs ./tooling/noirc_abi_wasm
cp -r ./result/noirc_abi_wasm/web ./tooling/noirc_abi_wasm

- name: Export cache from nix store
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
run: |
nix copy --to "file://${{ env.CACHED_PATH }}?compression=zstd&parallel-compression=true" .#noirc-abi-wasm-cargo-artifacts

- uses: actions/cache/save@v3
# Don't create cache entries for the merge queue.
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
with:
path: ${{ env.CACHED_PATH }}
key: ${{ steps.cache.outputs.cache-primary-key }}

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

Expand All @@ -157,8 +103,6 @@ jobs:
test-solidity-verifier:
runs-on: ubuntu-latest
needs: [build-wasm, build-nargo, build-noirc]
env:
CACHED_PATH: /tmp/nix-cache

steps:
- name: Checkout
Expand Down Expand Up @@ -188,7 +132,6 @@ jobs:
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
export PATH="$PATH:$(dirname $nargo_binary)"
nargo -V

- name: Install Yarn dependencies
uses: ./.github/actions/setup
Expand Down
Loading