Skip to content

Commit

Permalink
Add new workflow with automatic GHC matrix generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cptrodolfox committed Mar 13, 2024
1 parent 0311a30 commit 86eba78
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
generate-ghc-matrix:
name: "Generate GHC matrix from .cabal file"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Extract the tested-with GHC versions
id: set-matrix
uses: kleidukos/[email protected]
with:
cabal-file: cassava-megaparsec.cabal
ubuntu: true
version: 0.1.6.0

build:
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
needs: generate-ghc-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(needs.generate-ghc-matrix.outputs.matrix) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Haskell tools
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 'latest'
cabal-update: true
- name: Configure the build
run: |
cabal configure --enable-tests --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 }}-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build all --only-dependencies
- name: Save cached dependencies
uses: actions/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}
- name: Build
run: cabal build all
- name: Run tests
run: cabal test all
env:
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}

0 comments on commit 86eba78

Please sign in to comment.