Skip to content

Overhaul CI

Overhaul CI #166

Workflow file for this run

name: CI
# Trigger the workflow on push or pull request, but only for the main branch
on:
pull_request:
branches: [ "master" ]
push:
branches: [ "master" ]
jobs:
tested-with-matrix:
name: "Generate matrix from cabal"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Extract the tested GHC versions
id: set-matrix
uses: kleidukos/get-tested@v0.1.9.1
with:
cabal-file: mtl.cabal
ubuntu-version: "latest"
macos-version: "latest"
version: 0.1.9.1
lts-matrix:
runs-on: ubuntu-latest
outputs:
lts_versions: ${{ steps.lts-matrix.outputs.matrix }}
steps:
- name: Generate output
id: set-matrix
run: |
: "${STACK_TEST_NUM:=4}"
set -euo pipefail
# the input is something like this:
# {"lts":"lts-24.36", "lts-0":"lts-0.7", "lts-1":"lts-1.15", "nightly":"nightly-2026-04-10"}
# and we want the last n LTS, sorted and deduplicated without nightlies:
# lts-0.7 lts-1.15 lts-24.36
lts_versions=$(curl -s https://www.stackage.org/download/snapshots.json | jq -c -r --arg n "$STACK_TEST_NUM" '
[.[] | select(startswith("nightly") | not)]
| unique
| sort_by(split("-")[1] | split("."))
| .[-(($n | tonumber)):]
')
echo "${lts_versions}"
echo matrix="${lts_versions}" >> "$GITHUB_OUTPUT"
shell: bash
env:
STACK_TEST_NUM: ${{ vars.STACK_TEST_NUM }}
cabal:
name: "GHC ${{ matrix.ghc }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
needs: ["tested-with-matrix"]
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
ghc: ${{ fromJSON(needs.tested-with-matrix.outputs.matrix) }}
exclude:
- os: macos-latest
ghc: '8.10' # ghc-8.10 does not support ARM
fail-fast: false
steps:
- name: Checkout base repo
uses: actions/checkout@v4
- name: Set up Haskell
id: setup-haskell
uses: haskell/ghcup-setup@v1
with:
ghc: ${{ matrix.ghc }}
cabal: 'latest'
stack: 'latest'
stack-hook: true
- name: Prepare build dir
run: |
cabal sdist -z -o .
cabal get mtl-*.tar.gz
rm -f cabal.project
- name: Build
run: |
cd mtl-*/
cabal build --ghc-options='-Werror' all
- uses: actions/upload-artifact@v7
with:
path: mtl-*/dist-newstyle/cache/plan.json
archive: false
# - name: Test
# run: |
# cabal --enable-tests --test-show-details=direct all
- name: Haddock
run: |
cd mtl-*/
cabal haddock all
- name: Cabal check
run: |
cd mtl-*/
cabal check
stack:
name: "LTS ${{ matrix.lts }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
needs: ["lts-matrix"]
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
lts: ${{ fromJSON(needs.lts-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout base repo
uses: actions/checkout@v4
- name: Set up Haskell
id: setup-haskell
uses: haskell/ghcup-setup@v1
with:
stack: 'latest'
stack-hook: false
- name: Build
run: |
# just in case
rm -f stack.yaml stack.yaml.lock
# create stack.yaml
stack init --resolver=${{ matrix.lts }}
# build
stack build
mhs:
runs-on: ubuntu-latest
steps:
- name: checkout mhs repo
uses: actions/checkout@v4
with:
repository: augustss/MicroHs
ref: v0.14.15.0
path: mhs
- name: make and install mhs
run: |
cd mhs
make minstall
- name: checkout transformers repo
uses: actions/checkout@v4
with:
repository: augustss/transformers
path: transformers
- name: compile and install transformers package
run: |
PATH="$HOME/.mcabal/bin:$PATH"
cd transformers
mcabal install
- name: checkout mtl repo
uses: actions/checkout@v4
with:
path: mtl
- name: compile and install mtl package
run: |
PATH="$HOME/.mcabal/bin:$PATH"
cd mtl
mcabal install