Skip to content

Commit

Permalink
chore(ci): add cache for Nix workflow (#1210)
Browse files Browse the repository at this point in the history
* chore(ci): Add cache for Nix workflow

* align lockfile with other projects

* Include both flake.lock and cargo.lock in hash
  • Loading branch information
phated authored Apr 24, 2023
1 parent cca45a4 commit ac87a80
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ jobs:
nix_path: nixpkgs=channel:nixos-22.11
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
- name: Run `nix flake check`
run: |
nix flake check
nix flake check -L
- name: Export cache from nix store
if: steps.nix-store-cache.outputs.cache-hit != 'true'
run: |
nix copy --to "file:///tmp/nix-cache?compression=zstd&parallel-compression=true" .#cargo-artifacts
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@

packages.default = noir;

# We expose the `cargo-artifacts` derivation so we can cache our cargo dependencies in CI
packages.cargo-artifacts = cargoArtifacts;

# TODO(#1197): Look into installable apps with Nix flakes
# apps.default = flake-utils.lib.mkApp { drv = nargo; };

Expand Down

0 comments on commit ac87a80

Please sign in to comment.