Skip to content

Commit

Permalink
Added caching of nix store, fixes #14.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwbush committed Sep 16, 2024
1 parent c6a97ec commit 056940d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 💾 Cache Nix store
uses: actions/[email protected]
id: nix-cache
with:
path: /tmp/nixcache
key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }}
restore-keys: ${{ runner.os }}-nix-
- name: 🛠️ Install Nix
uses: cachix/install-nix-action@v21
with:
Expand All @@ -29,16 +36,29 @@ jobs:
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
substituters = ${{ env.SUBSTITUTERS }}
experimental-features = nix-command flakes
- name: 💾➤ Import Nix store cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: "nix-store --import < /tmp/nixcache"
- name: 🏗️ Build specification
run: |
nix build --show-trace --accept-flake-config .#leiosSpec
- name: ➤💾 Export Nix store cache
if: "steps.nix-cache.outputs.cache-hit != 'true'"
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"

compile:
name: Build libraries
runs-on: ubuntu-22.04
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 💾 Cache Nix store
uses: actions/[email protected]
id: nix-cache
with:
path: /tmp/nixcache
key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }}
restore-keys: ${{ runner.os }}-nix-
- name: 🛠️ Install Nix
uses: cachix/install-nix-action@v21
with:
Expand All @@ -49,12 +69,18 @@ jobs:
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
substituters = ${{ env.SUBSTITUTERS }}
experimental-features = nix-command flakes
- name: 💾➤ Import Nix store cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: "nix-store --import < /tmp/nixcache"
- name: 🏗️ Build `exe:leios`
run: |
nix build --show-trace --accept-flake-config .#leios
- name: 🏗️ Build `exe:ouroboros-net-vis`
run: |
nix build --show-trace --accept-flake-config .#ouroboros-net-vis
- name: ➤💾 Export Nix store cache
if: "steps.nix-cache.outputs.cache-hit != 'true'"
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"

tests:
if: true
Expand All @@ -63,6 +89,13 @@ jobs:
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v4
- name: 💾 Cache Nix store
uses: actions/[email protected]
id: nix-cache
with:
path: /tmp/nixcache
key: ${{ runner.os }}-nix-${{ hashFiles('flake.lock') }}
restore-keys: ${{ runner.os }}-nix-
- name: 🛠️ Install Nix
uses: cachix/install-nix-action@v21
with:
Expand All @@ -73,9 +106,15 @@ jobs:
trusted-public-keys = ${{ env.TRUSTED_PUBLIC_KEYS }}
substituters = ${{ env.SUBSTITUTERS }}
experimental-features = nix-command flakes
- name: 💾➤ Import Nix store cache
if: "steps.nix-cache.outputs.cache-hit == 'true'"
run: "nix-store --import < /tmp/nixcache"
- name: 🔬 Test with `leios-sim-test`
run: |
nix run --accept-flake-config .#leios-sim-test
- name: ➤💾 Export Nix store cache
if: "steps.nix-cache.outputs.cache-hit != 'true'"
run: "nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nixcache"

build-docusaurus:
runs-on: ubuntu-22.04
Expand Down

0 comments on commit 056940d

Please sign in to comment.