Skip to content

Use github-actions #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/cabal.project.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
documentation: True
tests: True
benchmarks: True

package io-classes
ghc-options: -Werror
flags: +asserts

package strict-stm
ghc-options: -Werror
flags: +asserts

package io-sim
ghc-options: -Werror
flags: +asserts
181 changes: 181 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Haskell CI

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ghc: ["8.10.7", "9.2.2"]
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" >> $GITHUB_ENV

- name: "LINUX: Setup Haskell"
uses: haskell/actions/setup@v1
if: runner.os != 'Windows'
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.6.2.0

- 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="3.6.2.0" \
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\\8.10.7\\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 "::set-output name=cabal-store::$(dirname $(cabal --help | tail -1 | tr -d ' '))\\store"

- uses: actions/checkout@v2

- name: "Configure cabal.project.local"
run: |
cat ./.github/workflows/cabal.project.local > ./cabal.project.local
cat ./cabal.project.local

- 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 "::set-output name=weeknum::$(/bin/date -u "+%W")"

- 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 io-sim
cabal build --only-dependencies io-classes

- name: Build projects [build]
run: cabal build all

- name: io-classes [test]
run: cabal run io-classes:test

- name: io-sim [test]
run: cabal run io-sim:test

stylish-haskell:
runs-on: ubuntu-22.04

steps:
- name: Set cache version
run: |
echo "CACHE_VERSION=hi5eTh3A" >> $GITHUB_ENV
echo "STYLISH_HASKELL_VERSION=0.13.0.0" >> $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@v1
id: setup-haskell
with:
ghc-version: 8.10.7
cabal-version: 3.6.2.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 }}

- uses: actions/cache@v3
name: "Cache `stylish-haskell`"
with:
path: ~/.cabal/bin/stylish-haskell
key: cabal-path-${{ env.STYLISH_HASKELL_VERSION }}

# Install stylish-haskell unless the right version is already available
# from the cache
- name: "Install `stylish-haskell`"
run: |
if [[ -x $(which stylish-haskell) && $(stylish-haskell --version) == "stylish-haskell ${{ env.STYLISH_HASKELL_VERSION }}" ]];
then
echo "Using cached `stylish-haskell`"
else
cabal install stylish-haskell-${{ env.STYLISH_HASKELL_VERSION }}
fi

- name: "`stylish-haskell` version"
run: |
which stylish-haskell
stylish-haskell --version

- uses: actions/checkout@v2

- name: "Run `stylish-haskell`"
run: |
./scripts/check-stylish.sh
git diff --exit-code
16 changes: 11 additions & 5 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ packages: ./io-sim
./strict-stm

package io-sim
tests: True
-- NOTE: to enable benchmarks, one needs to disable tests for --
-- `typed-protocols-examples`. This won't be a problem, once `io-sim` lands
-- in its own repository.
benchmarks: False
flags: +asserts

package io-classes
flags: +asserts

package strict-stm
flags: +asserts

source-repository-package
type: git
location: https://github.com/input-output-hk/typed-protocols
tag: b00ba45ed0c81284378ddea9a42c96e8ccb855e0
--sha256: 1qdp1wbvbmcs8z0c8phjz58w1zfwb1lkb0bjh7ksfy3hyrzcs07i
subdir:
typed-protocols
typed-protocols-cborg
typed-protocols-examples
70 changes: 0 additions & 70 deletions default.nix

This file was deleted.

1 change: 1 addition & 0 deletions io-classes/io-classes.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ maintainer:
category: Control
build-type: Simple
cabal-version: >=1.10
tested-with: GHC == 8.10.7, GHC == 9.2.2

source-repository head
type: git
Expand Down
4 changes: 2 additions & 2 deletions io-sim/bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Control.Monad.Class.MonadSay
import Control.Monad.Class.MonadThrow
import Control.Monad.Class.MonadTimer
import Control.Monad.IOSim
import Control.Tracer (Tracer (..), nullTracer)
import Control.Tracer (Tracer (..), emit, nullTracer)

import Criterion
import Criterion.Main
Expand Down Expand Up @@ -104,7 +104,7 @@ main = defaultMain
, bench "events" $
nf id ( selectTraceEventsSay
$ runSimTrace
$ prop_channel Nothing n (Tracer $ say . show))
$ prop_channel Nothing n (Tracer $ emit $ say . show))
]
, env (pure ()) $ \_ ->
bgroup "delays"
Expand Down
1 change: 1 addition & 0 deletions io-sim/io-sim.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ author: Duncan Coutts, Marcin Szamotulski, Alexander Vieth
maintainer:
category: Testing
build-type: Simple
tested-with: GHC == 8.10.7, GHC == 9.2.2

flag asserts
description: Enable assertions
Expand Down
11 changes: 0 additions & 11 deletions nix/check-nixfmt.nix

This file was deleted.

22 changes: 0 additions & 22 deletions nix/check-stylish.nix

This file was deleted.

Loading