Native GitHub Action cache for your cabal project
MIT License
This action caches the build dependencies of a Haskell project with per-package granularity. It works out of the box and it is really fast.
When building a Haskell project with cabal, cabal caches the project dependencies in a global cache called the "store". These are identified by a key that accurately represents their build configuration so they can be shared between projects.
Using @actions/cache to cache the entire store is not optimal because it would either cache the entirety of the store or nothing at all; which cabal does already at keeping track of what can be shared between builds and what can't.
The complexity of the example workflow from haskell-actions/setup is a testament to this issue.
To use this action you need to get cabal to create a build plan (i.e. the plan.json
file). This is typically achieved by passing the --dry-run
flag to the build command. Once plan.json
has been created, cabal-cache-native
will read from it the ids of the units to restore from cache. The action will look for plan.json
in ${project-path}/${plan-json}
.
jobs:
build:
steps:
- uses: haskell-actions/setup
id: setup
# ...
# This step is required to generate the build plan
- run: cabal build all --dry-run
- uses: andreabedini/cabal-cache-native
with:
# required
store-path: ${{ steps.setup.outputs.cabal-store }}
# optional, the path to the project
# project-path: .
# optional, you can also specify the exact location of plan.json
# plan-json: dist-newstyle/cache/plan.json
# optional, use this to separate caches or to start from scratch.
# cache-epoch: 0
# No need to check for cache hits, just build your project!
- run: cabal build all
You are welcome to use this under the MIT license included in the repository.