Skip to content

Commit

Permalink
update build, CI scripts and supported GHCs
Browse files Browse the repository at this point in the history
  • Loading branch information
rudymatela committed Jul 6, 2023
1 parent 22a68c8 commit b05e5da
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 36 deletions.
57 changes: 32 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Builds and tests this Haskell project on "GitHub Actions"
#
# 2021 Rudy Matela
# 2021-2023 Rudy Matela
#
# some docs: https://github.com/haskell/actions/tree/main/setup
#
# The official haskell docker image: https://hub.docker.com/_/haskell
name: build
on: [push]
jobs:
Expand All @@ -11,75 +13,81 @@ jobs:
steps:

- name: Cache ~/.cabal/packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cabal/packages
key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}
key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('*.cabal') }}
restore-keys: v1-${{ runner.os }}-cabal-packages-

- name: Cache ~/.cabal and ~/.ghc
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cabal
!~/.cabal/packages
~/.ghc
key: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('hello.cabal') }}
key: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('*.cabal') }}
restore-keys: v1-${{ runner.os }}-cabal-ghc-latest-

- run: du -hd3 ~/.cabal ~/.ghc || true

- run: make --version

- run: haddock --version || sudo apt-get install ghc-haddock
- run: ghc --version
- run: cabal --version
- run: haddock --version
- run: ghc-pkg list

- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- run: git --version

- run: cabal update
- run: make install-dependencies

- run: make
- run: make test
- run: make haddock
# 2023-07: some projects were failing with missing base for GHC 9.6.
# Here we compile through cabal only provisionally.
# - run: make
# - run: make test
# - run: make haddock
- run: make test-sdist
- run: make test-via-cabal
#- run: make test-via-cabal
- run: cabal configure --enable-tests --enable-benchmarks --ghc-options="-O0"
- run: cabal build
- run: cabal test
- run: cabal haddock


test-with-ghc:
strategy:
matrix:
ghc:
- '9.4'
- '9.2'
- '9.0'
- '8.10'
- '8.8'
- '8.6'
- '8.4'
- '8.2'
- '8.0'
- '7.10'
- '7.8'
runs-on: ubuntu-latest
needs: build-and-test
container: haskell:${{ matrix.ghc }}
steps:
- name: Cache ~/.cabal/packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cabal/packages
key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}
key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('*.cabal') }}
restore-keys: v1-${{ runner.os }}-cabal-packages-

- name: Cache ~/.cabal and ~/.ghc
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cabal
!~/.cabal/packages
~/.ghc
key: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('hello.cabal') }}
key: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('*.cabal') }}
restore-keys: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-

- run: du -hd3 ~/.cabal ~/.ghc || true
Expand All @@ -94,9 +102,8 @@ jobs:
- run: ghc-pkg list

- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3

- run: cabal update
- run: make install-dependencies

- run: make
Expand All @@ -110,12 +117,12 @@ jobs:
needs: build-and-test
steps:
- name: Setup Haskell's GHC and Cabal as required by current Stackage LTS
uses: haskell/actions/setup@v1
uses: haskell/actions/setup@v2
with: # lts-19.19
ghc-version: '9.0.2'
cabal-version: '3.4'

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.stack
key: v1-${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
Expand All @@ -124,5 +131,5 @@ jobs:
- run: stack --version

- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- run: make test-via-stack
9 changes: 6 additions & 3 deletions mk/haskell.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Implicit rules for compiling Haskell code.
#
# Copyright (c) 2015-2021 Rudy Matela.
# Copyright (c) 2015-2023 Rudy Matela.
# Distributed under the 3-Clause BSD licence.
#
# You can optionally configure the "Configuration variables" below in your main
Expand All @@ -21,7 +21,7 @@ GHCFLAGS ?=
GHC ?= ghc
GHCCMD = $(GHC) -i$(GHCIMPORTDIRS) $(GHCFLAGS)
HADDOCK ?= haddock
CABAL_INSTALL = $(shell cabal --version | grep -q "version [0-2]\." && echo 'cabal install' || echo 'cabal v1-install')
CABAL_INSTALL = $(shell cabal --version | grep -q "version [0-2]\." && echo 'cabal install' || echo 'cabal install --lib')

# Hugs Parameters
HUGSIMPORTDIRS ?= "/usr/lib/hugs/packages/*"
Expand Down Expand Up @@ -90,7 +90,10 @@ depend:
find $(ALL_HSS) | ./mk/ghcdeps -i$(GHCIMPORTDIRS) $(GHCFLAGS) > $(DEPMK)

install-dependencies:
$(CABAL_INSTALL) $(INSTALL_DEPS)
if [ -n "$(INSTALL_DEPS)" ]; then \
cabal update && \
$(CABAL_INSTALL) $(INSTALL_DEPS); \
fi

# haddock rules
haddock: doc/index.html
Expand Down
9 changes: 3 additions & 6 deletions test-framework-leancheck.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ extra-source-files: .gitignore
, stack.yaml
, test/sdist
, .github/workflows/build.yml
tested-with: GHC==9.0
tested-with: GHC==9.4
, GHC==9.2
, GHC==9.0
, GHC==8.10
, GHC==8.8
, GHC==8.6
, GHC==8.4
, GHC==8.2
, GHC==8.0
, GHC==7.10
, GHC==7.8


source-repository head
Expand Down
8 changes: 6 additions & 2 deletions test/sdist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# test/sdist: tests the package generated by "cabal sdist".
#
# Copyright (c) 2015-2021 Rudy Matela.
# Copyright (c) 2015-2023 Rudy Matela.
# Distributed under the 3-Clause BSD licence.

set -xe
Expand All @@ -29,7 +29,11 @@ tar -tf $pkg | sort --ignore-case > $tmp/ls-cabal-i
tar -tf $pkg | sort --ignore-case --unique > $tmp/ls-cabal-iu
diff -rud $tmp/ls-cabal-i $tmp/ls-cabal-iu

if [ -d .git ]
# Check if we have a clone of the repo and git is available
# The check that we can run git ls-files is needed to avoid:
# fatal: detected dubious ownership in repository at '/__w/.../hello-haskell'
# on CI.
if [ -d .git ] && git --version && git ls-files >/dev/null
then
# Test if files included by cabal are the same as files tracked in git.
git ls-files | sort > $tmp/ls-git
Expand Down

0 comments on commit b05e5da

Please sign in to comment.