Skip to content

ci: fix cache key

ci: fix cache key #13

Workflow file for this run

---
name: stack-build
on:
push:
branches: main
pull_request:
branches: main
permissions:
contents: read
jobs:
build:
name: lts-${{ matrix.stack.lts }} / ghc-${{ matrix.stack.ghc }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu]
stack:
- lts: &default-lts 21.25
ghc: &default-ghc 9.4.8
- lts: 22.44
ghc: 9.6.7
- lts: 23.28
ghc: 9.8.4
include:
- os: windows
stack:
lts: *default-lts
ghc: *default-ghc
- os: macos
stack:
lts: *default-lts
ghc: *default-ghc
steps:
- uses: actions/checkout@v3
- name: Set up Stack LTS ${{ matrix.stack-lts }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.stack.ghc }}
enable-stack: true
stack-setup-ghc: true
stack-no-global: true
- name: Configure the build
run: |
echo "with key: ${{ runner.os }}-lts-${{ matrix.stack.lts }}"
stack config set resolver lts-${{ matrix.stack.lts }}
stack build --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.
- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-lts-${{ matrix.stack.lts }}
with:
path: ${{ steps.setup.outputs.stack-root }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-
- name: Install dependencies
run: stack build --only-dependencies
# Cache dependencies already here, so that we do not have to rebuild them
# should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# Caches are immutable, trying to save with the same key would error.
if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
with:
path: ${{ steps.setup.outputs.stack-root }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build
run: stack build
- name: Run tests
run: stack test
- name: Check cabal file
run: stack check
continue-on-error: true
- name: Build documentation
run: stack haddock
...