Refactor IOSimPOR #433
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Haskell CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
merge_group: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
ghc: ["8.10.7", "9.2.8", "9.4.4", "9.6.2"] | |
cabal: ["3.8.1.0"] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
defaults: | |
run: | |
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }} | |
steps: | |
- name: "WIN: Setup MSYS2 and libraries" | |
if: runner.os == 'Windows' | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
install: >- | |
base-devel | |
autoconf-wrapper | |
autoconf | |
automake | |
libtool | |
make | |
git | |
mingw-w64-x86_64-jq | |
- name: Set cache version | |
run: echo "CACHE_VERSION=pu4Aevoo_v1" >> $GITHUB_ENV | |
- name: "LINUX: Setup Haskell" | |
uses: haskell/actions/setup@v2 | |
if: runner.os != 'Windows' | |
id: setup-haskell | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: ${{ matrix.cabal }} | |
- name: "WIN: Setup Haskell" | |
id: win-setup-haskell | |
if: runner.os == 'Windows' | |
run: | | |
# see https://gitlab.haskell.org/haskell/ghcup-hs/-/blob/master/scripts/bootstrap/bootstrap-haskell | |
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | \ | |
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \ | |
BOOTSTRAP_HASKELL_ADJUST_CABAL_CONFIG=1 \ | |
BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 \ | |
BOOTSTRAP_HASKELL_GHC_VERSION="${{ matrix.ghc }}" \ | |
BOOTSTRAP_HASKELL_CABAL_VERSION="${{ matrix.cabal }}" \ | |
sh | |
# MSYS2 doesn't inherit $GITHUB_PATH so this is needed | |
cat <(echo "source /c/ghcup/env") ~/.bashrc > ~/.bashrc.new | |
mv ~/.bashrc.new ~/.bashrc | |
source ~/.bashrc | |
# There is an issue with crt libraries, fixed by prepending the ghc | |
# mingw32 libraries directory to every other library directory. | |
echo "# Original cabal config extra-lib-dirs" | |
grep extra-lib-dirs /c/cabal/config | |
sed -i 's/C:\\msys64\\mingw64\\lib/C:\\ghcup\\ghc\\${{matrix.ghc}}\\mingw\\x86_64-w64-mingw32\\lib, C:\\msys64\\mingw64\\lib/g' /c/cabal/config | |
echo "# Modified cabal config extra-lib-dirs" | |
grep extra-lib-dirs /c/cabal/config | |
ghc --version | |
cabal --version | |
echo "cabal-store=$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
- 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@v3 | |
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@v3 | |
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: Build documentation [haddock] | |
run: cabal haddock all | |
- name: io-sim [test] | |
run: cabal run io-sim:test | |
- name: si-timers [test] | |
run: cabal run si-timers:test | |
- name: strict-mvar [test] | |
run: cabal run strict-mvar:test | |
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.8 | |
cabal-version: 3.8.1.0 | |
- name: "Setup cabal bin path" | |
run: | | |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH | |
- uses: actions/cache@v3 | |
name: "Cache cabal store" | |
with: | |
path: ${{ steps.setup-haskell.outputs.cabal-store }} | |
key: cache-dependencies-${{ env.CACHE_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@v3 | |
- name: "Run `stylish-haskell`" | |
run: | | |
./scripts/check-stylish.sh | |
git diff --exit-code |