Skip to content

Haskell CI

Haskell CI #560

Workflow file for this run

name: Haskell CI
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "15 12 * * *"
jobs:
enumerate:
name: Generate Build Matrix Dynamically
runs-on: ubuntu-latest
outputs:
configs: ${{ steps.enumerate.outputs.configs }}
steps:
- uses: actions/checkout@v3
- name: Enumerate Configs
id: enumerate
run: |
set -euxo pipefail
find ci-configs -type f -name 'ghc-*.config' \
| sort -h | jq -ncR '[inputs | {ghc: match("ghc-(.+)\\.config$", .) | .captures[0].string | select(.), plan: .}]' | tee configs.json
echo "configs=$(cat configs.json)" >> "${GITHUB_OUTPUT}"
cabal-check:
name: Cabal Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: haskell-actions/setup@v2
with:
cabal-version: 3.10.2.0
enable-stack: false
- run: cabal check
build:
needs: [enumerate]
continue-on-error: true
strategy:
fail-fast: false
matrix:
include: ${{fromJSON(needs.enumerate.outputs.configs)}}
runs-on: ubuntu-latest
name: Haskell GHC ${{ matrix.ghc }} Build
env:
CABAL: cabal --project-file=${{matrix.plan}}
steps:
- uses: actions/checkout@v3
- uses: haskell-actions/setup@v2
with:
ghc-version: ${{matrix.ghc}}
cabal-version: 3.10.2.0
enable-stack: false
- name: Restore Cache ~/.cabal/store
uses: actions/cache/restore@v3
env:
cache-name: cache-cabal-store
with:
path: ~/.cabal/store
key: build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}
restore-keys: |
build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-
- name: Cache dist-newstyle
uses: actions/cache@v3
env:
cache-name: cache-dist-newstyle
with:
path: dist-newstyle
key: build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}-${{ hashFiles('**/*.hs') }}
restore-keys: |
build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}-
build-${{ runner.os }}-${{ env.cache-name }}-${{matrix.ghc}}-
- name: Configure and Update
run: |
${CABAL} v2-configure --enable-tests --enable-benchmarks
${CABAL} v2-update
- name: Build Dependencies
run: |
${CABAL} v2-build all --only-dependencies
- name: Save Cache ~/.cabal/store
uses: actions/cache/save@v3
env:
cache-name: cache-cabal-store
with:
path: ~/.cabal/store
key: build-${{ runner.os }}-${{env.cache-name}}-${{matrix.ghc}}-${{ hashFiles('**/*.cabal', '${{matrix.plan}}') }}
- name: Build
run: |
${CABAL} v2-build all
- name: Collect binaries
run: ./scripts/collect-artifacts.sh artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: binaries-${{matrix.ghc}}-${{runner.os}}
path: artifacts.tar.zst
retention-days: 3
test:
needs: [enumerate, build]
strategy:
fail-fast: false
matrix:
include: ${{fromJSON(needs.enumerate.outputs.configs)}}
runs-on: ubuntu-latest
name: Haskell GHC ${{ matrix.ghc }} Test
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
id: download
with:
name: binaries-${{matrix.ghc}}-${{runner.os}}
- name: Extract and Run All Tests
run: |
set -euxo pipefail
DL_PATH=${{steps.download.outputs.download-path}}
unzstd "${DL_PATH}/artifacts.tar.zst"
tar xvf "${DL_PATH}/artifacts.tar"
set +x
find artifacts/tests -type f | while read -r TEST; do
echo "Executing: ${TEST}"
"${TEST}"
done
find artifacts/exes -type f | while read -r TEST; do
echo "Executing: ${TEST}"
"${TEST}"
done