Skip to content

Haskell CI

Haskell CI #176

Workflow file for this run

name: Haskell CI
on:
pull_request:
merge_group:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["8.10", "9.2", "9.4", "9.6", "9.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
env:
CABAL_VERSION: "3.12.1.0"
defaults:
run:
shell: "bash"
steps:
- name: Set cache version
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV
- name: Install LLVM (macOS)
if: runner.os == 'macOS' && matrix.ghc == '8.10'
run: |
brew install llvm@13
echo "LLVM_CONFIG=$(brew --prefix llvm@13)/bin/llvm-config" >> $GITHUB_ENV
echo "$(brew --prefix llvm@13)/bin" >> $GITHUB_PATH
- name: Verify LLVM installation
if: runner.os == 'macOS' && matrix.ghc == '8.10'
run: |
llvm-config --version
opt --version
- name: Print environment variables
if: runner.os == 'macOS' && matrix.ghc == '8.10'
run: |
echo "PATH = $PATH"
echo "LLVM_CONFIG = $LLVM_CONFIG"
- name: "Setup Haskell"
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ env.CABAL_VERSION }}
- uses: actions/checkout@v4
- name: "Configure cabal.project.local"
run: |
cat ./.github/workflows/cabal.project.local > ./cabal.project.local
cat ./cabal.project.local
- name: "Cabal update"
run: cabal update
- name: Record dependencies
id: record-deps
run: |
cabal build all --dry-run
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
echo "weeknum=$(/bin/date -u "+%W")" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: "Cache cabal store"
with:
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
key: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
restore-keys: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- uses: actions/cache@v4
name: "Cache `dist-newstyle`"
with:
path: |
dist-newstyle
!dist-newstyle/**/.git
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
- name: Build dependencies
run: cabal build --only-dependencies all
- name: Build projects [build]
run: cabal build all
- name: typed-protocols-examples [test]
run: cabal run typed-protocols-examples:test
# - name: typed-protocols-doc [test]
# run: cabal test typed-protocols-doc
stylish-haskell:
runs-on: ubuntu-22.04
env:
STYLISH_HASKELL_VERSION: "0.14.4.0"
steps:
- name: Set cache version
run: |
echo "CACHE_VERSION=hi5eTh3A" >> $GITHUB_ENV
- name: "Install build environment (apt-get)"
run: |
sudo apt-get update
sudo apt-get -y install fd-find
- name: "Setup Haskell"
uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: 9.2.5
cabal-version: 3.8.1.0
- name: "Setup cabal bin path"
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- uses: actions/cache@v4
name: "Cache `stylish-haskell`"
with:
path: ~/.cabal/bin/stylish-haskell
key: cabal-path-${{ env.STYLISH_HASKELL_VERSION }}
- name: Download stylish-haskell
run: |
version="${{ env.STYLISH_HASKELL_VERSION }}"
curl -sL \
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
| tar -C "/tmp" -xz
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> $GITHUB_ENV
- name: "`stylish-haskell` version"
run: |
which stylish-haskell
stylish-haskell --version
- uses: actions/checkout@v4
- name: "Run `stylish-haskell`"
run: |
./scripts/check-stylish.sh
git diff --exit-code