Skip to content

fix(cache): Cache hitting for Cabal build #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 14, 2025
16 changes: 9 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

name: CI

on:
pull_request:
on:
pull_request:
branches:
- main
push:
Expand All @@ -20,7 +20,7 @@ concurrency:
jobs:
generate-matrix:
name: "Generate matrix from cabal"
outputs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
Expand All @@ -46,21 +46,23 @@ jobs:
id: setup
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 'latest'
cabal-version: "latest"
cabal-update: true
- name: Configure the build
run: |
cabal configure --enable-tests --disable-documentation
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run

- name: Restore cached dependencies
uses: actions/cache/restore@v4
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-
key: v1-${{ env.key }}-plan-${{ hashFiles('**/dist-newstyle/cache/plan.json') }}
restore-keys: v1-ghc-deps-${{ env.key }}-

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies
Expand Down