Skip to content

Build and test with cabal, not stack #2

Build and test with cabal, not stack

Build and test with cabal, not stack #2

Workflow file for this run

name: CI
on:
pull_request:
push:
branches: [ master ]
# Cancel any in-progress run on the same branch/PR when new commits arrive
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
cabal:
strategy:
fail-fast: false
matrix:
ghc: ['9.8','9.6','9.4','9.2','8.8']
# Base set of OSes
os: [ubuntu-latest, macos-13, windows-latest]
# Also build on Apple Silicon where supported (GHC >= 9.2)
include:
- os: macos-latest
ghc: '9.8'
- os: macos-latest
ghc: '9.6'
- os: macos-latest
ghc: '9.4'
- os: macos-latest
ghc: '9.2'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Haskell
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest
# Cache Cabal store + dist-newstyle (Unix)
- name: Cache Cabal (Unix)
if: runner.os != 'Windows'
uses: actions/cache@v3
with:
path: |
~/.cabal/store
dist-newstyle
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }}
restore-keys: |
${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-
# Cache Cabal store + dist-newstyle (Windows)
- name: Cache Cabal (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: |
C:\Users\runneradmin\AppData\Roaming\cabal\store
dist-newstyle
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }}
restore-keys: |
${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-
- name: cabal update
run: cabal update
- name: Build (deps)
run: cabal build --only-dependencies --enable-tests --enable-benchmarks -j
- name: Build
run: cabal build all --enable-tests --enable-benchmarks -j
- name: Test
run: cabal test all --test-show-details=direct
- name: Package checks
run: cabal check
- name: Make sdist
run: cabal sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.os }}-ghc-${{ matrix.ghc }}
path: dist-newstyle/sdist/*.tar.gz
if-no-files-found: error
# Build the produced sdist in a clean workspace to ensure the release tarball compiles
sdist-build:
needs: cabal
strategy:
fail-fast: false
matrix:
ghc: ['9.8','9.6','9.4','9.2','8.8']
runs-on: ubuntu-latest
steps:
- name: Setup Haskell
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: latest
- name: Download sdist (from Linux job)
uses: actions/download-artifact@v4
with:
name: sdist-ubuntu-latest-ghc-${{ matrix.ghc }}
path: sdist
- name: Build sdist in clean dir
shell: bash
run: |
set -euo pipefail
TARBALL="$(ls sdist/*.tar.gz | head -n1)"
tar -xzf "$TARBALL"
PKGDIR="$(tar -tzf "$TARBALL" | head -n1 | cut -d/ -f1)"
cd "$PKGDIR"
cabal update
cabal build all --enable-tests -j
cabal test all --test-show-details=direct