Build cabal project #263
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build cabal project | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: | |
- synchronize | |
- opened | |
- reopened | |
merge_group: | |
push: | |
branches: | |
- master | |
schedule: | |
# Run once per day (at UTC 18:00) to maintain cache: | |
- cron: 0 18 * * * | |
env: | |
target: 'reactive-banana' | |
jobs: | |
build: | |
name: ${{ matrix.os }}-ghc-${{ matrix.ghc }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.allow-failure }} | |
strategy: | |
matrix: | |
allow-failure: | |
- false | |
os: | |
- ubuntu-latest | |
cabal: | |
- '3.12' | |
ghc: | |
- '8.4' | |
- '8.6' | |
- '8.8' | |
- '8.10' | |
- '9.2' | |
- '9.4' | |
- '9.6' | |
- '9.8' | |
- '9.10' | |
include: | |
- allow-failure: true | |
os: ubuntu-latest | |
cabal: '3.12' | |
ghc: '9.12' | |
steps: | |
# Weird, the action runner fails with a 'missing -lnuma' error, but only on 8.4 | |
- name: Install libnuma-dev for ghc 8.4 | |
if: matrix.ghc == '8.4' | |
run: sudo apt-get install libnuma-dev | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Environment | |
uses: haskell-actions/setup@v2 | |
id: setup | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: ${{ matrix.cabal }} | |
- name: Cabal check | |
run: | | |
cd reactive-banana | |
cabal check | |
- name: Configure | |
run: | | |
cabal configure \ | |
--enable-tests \ | |
--enable-benchmarks \ | |
--enable-documentation \ | |
--test-show-details=direct \ | |
--write-ghc-environment-files=always | |
cabal build ${{ env.target }} --dry-run | |
# The last step generates dist-newstyle/cache/plan.json for the cache key. | |
# For a description of how the Caching works, see | |
# https://github.com/haskell-actions/setup?tab=readme-ov-file#model-cabal-workflow-with-caching | |
- name: Dependencies (Restore from cache) | |
uses: actions/cache/restore@v4 | |
id: cache | |
env: | |
key: ${{ matrix.os }}-ghc-${{ matrix.ghc }} | |
hash: ${{ hashFiles('**/plan.json') }} | |
with: | |
key: ${{ env.key }}-${{ env.hash }} | |
restore-keys: ${{ env.key }}- | |
path: ${{ steps.setup.outputs.cabal-store }} | |
- name: Dependencies (Install) | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: cabal build ${{ env.target }} --only-dependencies | |
# Cache dependencies already here, | |
# so that we do not have to rebuild them should the subsequent steps fail. | |
- name: Dependencies (Save cache) | |
uses: actions/cache/save@v4 | |
# If we had an exact cache hit, | |
# trying to save the cache would error because of key clash. | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ steps.cache.outputs.cache-primary-key }} | |
path: ${{ steps.setup.outputs.cabal-store }} | |
- name: Build | |
run: > | |
cabal build ${{ env.target }} | |
--enable-tests | |
--enable-benchmarks | |
- name: Test | |
run: > | |
cabal test ${{ env.target }} |