Skip to content

Commit

Permalink
fix(ci): add restore/save cache for onchain
Browse files Browse the repository at this point in the history
  • Loading branch information
tgunnoe committed Nov 14, 2024
1 parent b26b777 commit 77cfd3c
Showing 1 changed file with 48 additions and 15 deletions.
63 changes: 48 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
id-token: write
contents: read
runs-on: [ self-hosted, Linux ]
env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2024-11-14"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -25,29 +28,59 @@ jobs:
- name: Add signing key for nix
run: echo "${{ secrets.NIX_SIGNING_KEY }}" > "${{ runner.temp }}/nix-key"

# - name: Cache cabal directories
# uses: actions/cache@v4
# with:
# path: |
# ~/.local/state/cabal/store
# ~/.cabal/store
# onchain/dist-newstyle
# key: ${{ runner.os }}-${{ hashFiles('**/*.cabal', '**/cabal.project') }}
# restore-keys: ${{ runner.os }}-
- name: Record dependencies to be used as cache keys
id: record-deps
run: |
nix develop && cd onchain
cabal build all --enable-tests --dry-run --minimize-conflict-set
cat dist-newstyle/cache/plan.json \
| jq '.["install-plan"][].id' \
| sort \
| uniq \
| tee dependencies.txt
- name: Restore cache
uses: actions/cache/restore@v4
id: restore-cabal-cache
with:
path: |
~/.local/state/cabal/store
~/.cabal/store
onchain/dist-newstyle
key: ${{ runner.os }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('dependencies.txt') }}-${{ hashFiles('cabal.project*') }}

restore-keys: |
${{ runner.os }}-${{ env.CABAL_CACHE_VERSION }}-${{ hashFiles('dependencies.txt') }}
${{ runner.os }}-${{ env.CABAL_CACHE_VERSION }}-
- name: Build dependencies
id: build-dependencies
run: cabal build all --only-dependencies

- name: Save cache
uses: actions/cache/save@v4
id: save-cabal-cache
if: steps.build-dependencies.outcome == 'success' && steps.restore-cabal-cache.outputs.cache-hit != 'true'
with:
path: |
~/.local/state/cabal/store
~/.cabal/store
onchain/dist-newstyle
key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }}

- name: Lint sources
run: |
nix flake check
- name: Build onchain
run: |
cd onchain
nix develop --command "make"
make
- name: Build offchain
run: |
cd offchain
nix develop --command "make"
# - name: Build offchain
# run: |
# cd offchain
# nix develop --command "make"

- name: Acquire AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down

0 comments on commit 77cfd3c

Please sign in to comment.