Skip to content

Commit

Permalink
Update CI to use GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sheaf committed Apr 5, 2024
1 parent b661ea1 commit b73115c
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 41 deletions.
122 changes: 92 additions & 30 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,104 @@ on:

jobs:
build:
name: CI
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
args:
- "--resolver ghc-9.8.1"
- "--resolver ghc-9.6.3"
- "--resolver ghc-9.4.7"
- "--resolver ghc-9.2.8"
- "--resolver ghc-9.0.1"
- "--resolver ghc-8.10.4"
- "--resolver ghc-8.8.4"
- "--resolver ghc-8.6.5"
- "--resolver ghc-8.4.4"
- "--resolver ghc-8.2.2"
ghc-version:
- 'latest'
- '9.8'
- '9.6'
- '9.4'
- '9.2'
- '9.0'
- '8.10'
- '8.8'
- '8.6'
- '8.4'
- '8.2'

steps:
- name: Clone project
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Build and run tests
shell: bash
- name: Set up GHC ${{ matrix.ghc-version }}
uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc-version }}
# Defaults, added for clarity:
cabal-version: 'latest'
cabal-update: true

- name: Set up autotools (Windows)
if: ${{ runner.os == 'Windows' }}
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
autotools
- name: Run autoreconf (Windows)
if: ${{ runner.os == 'Windows' }}
run: autoreconf -i
shell: "msys2 {0}"

- name: Run autoreconf (Linux & Mac)
if: ${{ runner.os != 'Windows' }}
run: autoreconf -i

- name: Configure the build
run: |
set -ex
stack upgrade
stack --version
if [[ "${{ runner.os }}" = 'Windows' ]]
then
# Looks like a bug in Stack, this shouldn't break things
ls C:/ProgramData/Chocolatey/bin/
rm -rf C:/ProgramData/Chocolatey/bin/ghc*
stack ${{ matrix.args }} exec pacman -- --sync --refresh --noconfirm autoconf
fi
stack build
stack sdist --test-tarball
cd test
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}
cabal configure --enable-tests --enable-benchmarks --disable-documentation
cabal build all --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Install dependencies
# If we had an exact cache hit, the dependencies will be up to date.
if: steps.cache.outputs.cache-hit != 'true'
run: cabal build process --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# If we had an exact cache hit, trying to save the cache would error because of key clash.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build
run: cabal build process

- name: Run tests
run: cabal run process-tests:test

# On Windows and with GHC >= 9.0, re-run the test-suite using WinIO.
- name: Re-run tests with WinIO (Windows && GHC >= 9.0)
if: ${{ runner.os == 'Windows' && matrix.ghc-version >= '9.0' }}
run: cabal run process-tests:test -- +RTS --io-manager=native -RTS

- name: Build documentation
run: cabal haddock process

- name: Check process.cabal
run: cabal check

- name: Source dist
run: cabal sdist all --ignore-project

- name: Check process-tests.cabal
working-directory: ./test
run: cabal check
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: ., test
11 changes: 11 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
resolver: ghc-9.2.3

packages:
- .
- test

extra-deps:
- Cabal-3.6.3.0

allow-newer: True
allow-newer-deps:
- Cabal
10 changes: 8 additions & 2 deletions test/process-tests.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ source-repository head
location: https://github.com/haskell/process.git
subdir: test

custom-setup
setup-depends:
base >= 4.10 && < 4.20,
directory >= 1.1 && < 1.4,
filepath >= 1.2 && < 1.6,
Cabal >= 2.4 && < 3.12,

test-suite test
import: process-dep
default-language: Haskell2010
hs-source-dirs: .
main-is: main.hs
type: exitcode-stdio-1.0
-- Add otherwise redundant bounds on base since GHC's build system runs
-- `cabal check`, which mandates bounds on base.
build-depends: base >= 4 && < 5
, bytestring
, deepseq
Expand Down
9 changes: 0 additions & 9 deletions test/stack.yaml

This file was deleted.

0 comments on commit b73115c

Please sign in to comment.