Reputation: 48536
Recently I was lured from Travis CI to GitHub actions for my Julia project by the ease of configuration and out-of-the box success with all of the example Actions I found, and thought I'd try the same with my Haskell project. But none of the example Haskell Actions I found function at all, most failing with security or gcc
compiler flag errors, even for exactly the same commands that work in Travis CI.
Are there examples of functioning Haskell GitHub Actions? I suspect I'm just not looking in the right place for the latest working examples.
Upvotes: 5
Views: 315
Reputation: 48536
Ultimately, after a lot of trial and error, I ended up with roughly this, which works perfectly:
name: Tests
on:
pull_request:
push:
branches: [hackage, develop]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
ghc: ['8.8.3', '8.10.5']
cabal: ['2.4.1.0', '3.0.0.0']
os: [ubuntu-latest]
resolver: [lts-3.22 , lts-17, lts-18, lts]
exclude:
# GHC 8.8+ only works with cabal v3+
- ghc: 8.8.3
cabal: 2.4.1.0
name: ${{ matrix.resolver }} (${{ matrix.ghc }}/${{ matrix.cabal }})
steps:
- name: Check out
uses: actions/checkout@v2
- name: Setup Haskell
uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
enable-stack: true
- name: Versions
run: |
stack --version
cabal --version
ghc --version
- name: Initalize stack for LTS
run: |
stack update
stack init --resolver ${{ matrix.resolver }} --force
- name: Build package dependencies
run: |
stack --resolver ${{ matrix.resolver }} build --no-run-tests --no-run-benchmarks --only-dependencies
- name: Build package
run: |
stack --resolver ${{ matrix.resolver }} build --no-run-tests --no-run-benchmarks
- name: Build testing dependencies
run: |
stack --resolver ${{ matrix.resolver }} build --no-run-tests --no-run-benchmarks --test --bench
- name: Run tests
run: |
stack --resolver ${{ matrix.resolver }} build --test --no-run-benchmarks
- name: Package list
run: |
stack --resolver ${{ matrix.resolver }} exec ghc-pkg list || true
(Though I'm not sure the build steps are in quite the right order for what I intend, and have some questions about where caching should go.)
Upvotes: 3