Skip to content

Commit

Permalink
chore: utilize nix cache for wasm builds (#2813)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobyhallx authored Sep 25, 2023
1 parent 373325d commit 0490549
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 70 deletions.
28 changes: 5 additions & 23 deletions .github/workflows/abi_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,16 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v3

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

- name: Restore nix store cache
uses: actions/cache/restore@v3
id: cache
- uses: cachix/cachix-action@v12
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
name: barretenberg
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Build noirc_abi_wasm
run: |
Expand All @@ -55,13 +44,6 @@ jobs:
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 Down
23 changes: 4 additions & 19 deletions .github/workflows/acvm-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

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

- uses: cachix/cachix-action@v12
with:
name: barretenberg

- name: Restore nix store cache
id: nix-store-cache
uses: actions/cache@v3
with:
path: /tmp/nix-cache
key: ${{ runner.os }}-flake-${{ 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.nix-store-cache.outputs.cache-hit == 'true'
# We don't check the signature because we're the one that created the cache
run: |
for narinfo in /tmp/nix-cache/*.narinfo; do
path=$(head -n 1 "$narinfo" | awk '{print $2}')
nix copy --no-check-sigs --from "file:///tmp/nix-cache" "$path"
done
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Run `nix flake check`
working-directory: acvm-repo
Expand Down
32 changes: 4 additions & 28 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,18 @@ jobs:
- name: Setup Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-22.11
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Restore nix store cache
uses: actions/cache/restore@v3
id: cache
- uses: cachix/cachix-action@v12
with:
path: ${{ env.CACHED_PATH }}
key: ${{ runner.os }}-flake-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
name: barretenberg
authToken: "${{ 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 Down

0 comments on commit 0490549

Please sign in to comment.