Announcing haskell-stack-cache
haskell-stack-cache
is a script for use in CI to cache and
restore build artifacts for stack
-based Haskell projects. It is
storage-agnostic via use of rclone
under the hood.
After configuring a CI runner, usage is simple. To cache a project’s
build artifacts, use the -c
option:
haskell-stack-cache -c
To restore a project’s build artifacts, use the -r
option:
haskell-stack-cache -r
You must tell the script the path to your stack.yaml
project file
via the STACK_YAML
environment variable. This is the script’s only
required environment variable, though additional variables are
available to customize the script’s behavior.
The script is “bring-your-own-storage”, so you must choose a storage backend for your build artifacts. While this is less convenient compared to walled garden platforms that provide storage, the upside is that you have complete control over your cached data. By using your own storage, you’re not subject to any proprietary eviction rules and storage quotas unless the backend you choose imposes their own.
The primary goal of haskell-stack-cache
is to enable caching of
stack
-based Haskell projects in CI on platforms other than GitHub. It
was built with SourceHut in mind, but there is nothing specific to the
SourceHut build process in the code. The script could theoretically be
used on any CI platform that allows running bash
scripts.
For more info, including a build manifest you can copy-paste into your SourceHut projects, please see the homepage.