Skip to content

Commit

Permalink
rework CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rudymatela committed Feb 9, 2024
1 parent 8bb10a7 commit a554976
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 57 deletions.
140 changes: 91 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Builds and tests this Haskell project on "GitHub Actions"
#
# 2021-2023 Rudy Matela
# 2021-2024 Rudy Matela
#
# some docs: https://github.com/haskell/actions/tree/main/setup
# some docs: https://github.com/haskell-actions/setup
#
# The official haskell docker image: https://hub.docker.com/_/haskell
name: build
Expand All @@ -11,58 +11,66 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- run: git --version
- run: make --version
- run: ghc --version
- run: cabal --version

- name: Cache ~/.cabal/packages
- name: Check out repository
uses: actions/checkout@v3

# check out needs to happen before cache so that hashing works
- name: Cache hash
run: echo Cache hash = ${{ hashFiles('*.cabal') }}

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

- name: Cache ~/.cabal and ~/.ghc
- name: Cache installed cabal packages
uses: actions/cache@v3
with:
path: |
~/.cabal
!~/.cabal/packages
~/.config/cabal
~/.local/state/cabal
~/.ghc
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
restore-keys: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('*.cabal') }}
# restore with exact match has some versions of cabal have trouble updating

- 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@v3
# blank line
# blank line for alignment with matrix scripts

- run: git --version
- run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true

- run: ghc-pkg list
- run: make install-dependencies
- run: ghc-pkg list

- run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true

# 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
- run: make test
- run: make haddock
- run: make test-sdist
#- run: make test-via-cabal
- run: cabal configure --enable-tests --enable-benchmarks --ghc-options="-O0"
- run: cabal build
- run: cabal test
- run: cabal haddock
- run: make test-via-cabal


test-with-ghc:
strategy:
max-parallel: 6
matrix:
ghc:
- '9.8'
- '9.6'
- '9.4'
- '9.2'
- '9.0'
Expand All @@ -73,38 +81,51 @@ jobs:
needs: build-and-test
container: haskell:${{ matrix.ghc }}
steps:
- name: Cache ~/.cabal/packages
- run: git --version || true # git is missing in some images
- run: make --version || true # make is missing in some images
- run: ghc --version
- run: cabal --version

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

# check out needs to happen before cache so that hashing works
- name: Cache hash
run: echo Cache hash = ${{ hashFiles('*.cabal') }}

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

- name: Cache ~/.cabal and ~/.ghc
- name: Cache installed cabal packages
uses: actions/cache@v3
with:
path: |
~/.cabal
!~/.cabal/packages
~/.config/cabal
~/.local/state/cabal
~/.ghc
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
restore-keys: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('*.cabal') }}
# restore with exact match has some versions of cabal have trouble updating

- run: make --version || rm /etc/apt/sources.list.d/*.list # faster update
- run: make --version || apt-get update
- run: make --version || apt-get install make

- run: ghc --version
- run: cabal --version
- run: haddock --version
- run: ghc-pkg list

- name: Check out repository
uses: actions/checkout@v3
- run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true

- run: ghc-pkg list
- run: make install-dependencies
- run: ghc-pkg list

- run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true

- run: make
- run: make test
Expand All @@ -116,20 +137,41 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Setup Haskell's GHC and Cabal as required by current Stackage LTS
uses: haskell/actions/setup@v2
with: # lts-19.19
ghc-version: '9.0.2'
cabal-version: '3.4'
- name: Check out repository
uses: actions/checkout@v3

# check out needs to happen before cache so that hashing works
- name: Cache hash
run: echo Cache hash = ${{ hashFiles('stack.yaml') }}

- uses: actions/cache@v3
- name: Cache stack folder
uses: actions/cache@v3
with:
path: ~/.stack
key: v1-${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}
restore-keys: v1-${{ runner.os }}-stack-

- name: Cache ghcup folder
uses: actions/cache@v3
with:
path: |
~/.ghcup
/usr/local/.ghcup/bin
/usr/local/.ghcup/db
/usr/local/.ghcup/ghc/9.0.2
key: v1-${{ runner.os }}-ghcup-${{ hashFiles('stack.yaml') }}
restore-keys: v1-${{ runner.os }}-ghcup-

- name: Setup Haskell's GHC and Cabal as required by current Stackage LTS
uses: haskell-actions/setup@v2
with: # lts-19.19
ghc-version: '9.0.2'
cabal-version: '3.4'

- run: du -hd2 ~/.stack ~/.ghcup /usr/local/.ghcup || true

- run: stack --version

- name: Check out repository
uses: actions/checkout@v3
- run: make test-via-stack

- run: du -hd2 ~/.stack ~/.ghcup /usr/local/.ghcup || true
4 changes: 3 additions & 1 deletion leancheck-instances.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ extra-source-files: .gitignore
, test/diff/*.out
, test/diff/eg/*.out
, test/sdist
tested-with: GHC==9.4
tested-with: GHC==9.8
, GHC==9.6
, GHC==9.4
, GHC==9.2
, GHC==9.0
, GHC==8.10
Expand Down
2 changes: 1 addition & 1 deletion mk/ghcdeps
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# ghcdeps: generate Haskell make dependencies for compiling with GHC.
#
# Copyright (c) 2015-2021 Rudy Matela.
# Copyright (c) 2015-2024 Rudy Matela.
# Distributed under the 3-Clause BSD licence.
#
# From a list of files provided on standard input,
Expand Down
2 changes: 1 addition & 1 deletion mk/haddock-i
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# haddock-i: list haddock's -i parameters.
#
# Copyright (c) 2015-2021 Rudy Matela.
# Copyright (c) 2015-2024 Rudy Matela.
# Distributed under the 3-Clause BSD licence.
#
# $ haddock-i <package1> <package2> ... <packageN>
Expand Down
9 changes: 7 additions & 2 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-2023 Rudy Matela.
# Copyright (c) 2015-2024 Rudy Matela.
# Distributed under the 3-Clause BSD licence.
#
# You can optionally configure the "Configuration variables" below in your main
Expand Down Expand Up @@ -91,9 +91,14 @@ depend:

install-dependencies:
if [ -n "$(INSTALL_DEPS)" ]; then \
cd ~ && \
cabal update && \
$(CABAL_INSTALL) $(INSTALL_DEPS); \
$(CABAL_INSTALL) $(INSTALL_DEPS) || true; \
fi
# above, "|| true" is needed for cabal >= 3.10.2
# Before, cabal would successfully skip installation
# of already existing packages
# cd ~ is needed so cabal installs only dependencies

# haddock rules
haddock: doc/index.html
Expand Down
2 changes: 1 addition & 1 deletion mk/install-on
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# mk/install-on: install or updates the mk folder on a Haskell project
#
# Copyright (c) 2019-2021 Rudy Matela.
# Copyright (c) 2019-2024 Rudy Matela.
# Distributed under the 3-Clause BSD licence.
#
# usage: ./mk/install-on path/to/project
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ packages:
- .

extra-deps:
- leancheck-1.0.0
- leancheck-1.0.2
2 changes: 1 addition & 1 deletion 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-2023 Rudy Matela.
# Copyright (c) 2015-2024 Rudy Matela.
# Distributed under the 3-Clause BSD licence.

set -xe
Expand Down

0 comments on commit a554976

Please sign in to comment.