Skip to content

Commit

Permalink
Test cabal-cache-native
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabedini committed Nov 6, 2024
1 parent 9c48b91 commit 3377082
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,42 +111,9 @@ jobs:
- name: Build dry run
run: cabal build all --enable-tests --dry-run --minimize-conflict-set

# From the install plan we generate a dependency list.
- name: Record dependencies
id: record-deps
run: |
# The tests call out to msys2 commands. We generally do not want to mix toolchains, so
# we are very deliberate about only adding msys64 to the path where absolutely necessary.
${{ (runner.os == 'Windows' && '$env:PATH=("C:\msys64\mingw64\bin;{0}" -f $env:PATH)') || '' }}
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
# From the dependency list we restore the cached dependencies.
# We use the hash of `dependencies.txt` as part of the cache key because that will be stable
# until the `index-state` values in the `cabal.project` file changes.
- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}

# Now we install the dependencies. If the cache was found and restored in the previous step,
# this should be a no-op, but if the cache key was not found we need to build stuff so we can
# cache it for the next step.
- name: Install dependencies
run: cabal build all --enable-tests --only-dependencies -j --ghc-option=-j4

# Always store the cabal cache.
# This may fail (benign failure) if the cache key is already populated.
- name: Cache Cabal store
uses: actions/cache/save@v4
- uses: andreabedini/cabal-cache-native@main
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-newstyle
key: cache-${{ env.CABAL_CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
store-path: ${{ steps.setup-haskell.outputs.cabal-store }}

# Now we build.
- name: Build [testing]
Expand Down

0 comments on commit 3377082

Please sign in to comment.