Skip to content

Commit f5e5438

Browse files
committed
Sets up multi ghc build
1 parent 6626cb0 commit f5e5438

27 files changed

+309
-101
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref_name }}
8+
cancel-in-progress: ${{ github.ref_name != 'main' }}
9+
10+
defaults:
11+
run:
12+
shell: bash
13+
14+
jobs:
15+
find-stack-yamls:
16+
name: Find stack.yamls for GHC Matrix
17+
runs-on: ubuntu-22.04
18+
outputs:
19+
stack-yamls: ${{ steps.set-output.outputs.stack-yamls }}
20+
steps:
21+
- name: Find Stack Yamls
22+
id: set-output
23+
uses: flipstone/github-actions/find-stack-ghc-yamls@bef3396e6c3777767d1d4837203cfdb2635b4933
24+
25+
build:
26+
name: Build and Test
27+
needs: find-stack-yamls
28+
runs-on: ubuntu-22.04
29+
strategy:
30+
max-parallel: 5
31+
matrix:
32+
stack-yaml: ${{ fromJson(needs.find-stack-yamls.outputs.stack-yamls) }}
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Cache
39+
uses: actions/cache@v4
40+
env:
41+
cache-version: v3
42+
with:
43+
key: ${{ env.cache-version }}-${{ matrix.stack-yaml }}-${{ hashFiles(matrix.stack-yaml, 'stack-base.yaml', 'package.yaml') }}
44+
restore-keys: |
45+
${{ env.cache-version }}-${{ matrix.stack-yaml }}-
46+
path: |
47+
./stack-root
48+
49+
- name: Setup Stack
50+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
51+
with:
52+
stack-root: ./stack-root
53+
54+
- name: Build and test
55+
run: ./scripts/test --stack-yaml ${{ matrix.stack-yaml }}
56+
57+
formatting-check:
58+
name: Formatting Check
59+
runs-on: ubuntu-22.04
60+
permissions:
61+
contents: read
62+
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
67+
- name: Setup Stack (for docker env)
68+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
69+
with:
70+
stack-root: ./stack-root
71+
72+
- name: Format and Check for Diff
73+
run: ./scripts/format-repo
74+
75+
cabal-check:
76+
name: Cabal Check
77+
runs-on: ubuntu-22.04
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v4
81+
82+
- name: Setup Stack (for docker env)
83+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
84+
with:
85+
stack-root: ./stack-root
86+
87+
- name: Check for Hackage releasable issues
88+
run: docker compose run --rm dev cabal check
89+
90+
shellcheck:
91+
name: shellcheck
92+
runs-on: ubuntu-22.04
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Setup Stack (for docker env)
98+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
99+
with:
100+
stack-root: ./stack-root
101+
102+
- name: Format and Check for Diff
103+
run: scripts/shellcheck
104+
105+
cabal-latest-build:
106+
name: Cabal Build
107+
runs-on: ubuntu-22.04
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v4
111+
112+
- name: Setup Stack (for docker env)
113+
uses: flipstone/github-actions/setup-dockerized-stack@bef3396e6c3777767d1d4837203cfdb2635b4933
114+
with:
115+
stack-root: ./stack-root
116+
117+
- name: Build with cabal and latest ghc+deps
118+
# When a new ghc version is released, we might not be able to build all the dependencies for
119+
# a little while. So we need to allow failure here. It is a very unfortunate situation that
120+
# github does not give us a better UX for this as the closest thing to a required check is
121+
# not configured here, but seemingly only through the api/webui for "branch protection"
122+
continue-on-error: true
123+
run: scripts/cabal-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.stack-work/
22
*~
33
.env
4+
test-all-logs/

compose.override.github.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

optparse-repl.cabal

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ library
3737
build-depends:
3838
base >=4.7 && <5
3939
, isocline ==1.0.*
40-
, optparse-applicative >=0.17 && <0.19
40+
, optparse-applicative >=0.16 && <0.19
4141
, safe-exceptions ==0.1.*
4242
default-language: Haskell2010
4343
if flag(strict)
44-
ghc-options: -Weverything -Werror -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-missing-kind-signatures -Wno-prepositive-qualified-module -Wno-implicit-prelude -Wno-safe -Wno-unsafe -Wno-missing-safe-haskell-mode -Wno-missing-deriving-strategies -Wno-all-missed-specialisations -Wno-missed-specialisations
44+
ghc-options: -Weverything -Werror -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-prepositive-qualified-module -Wno-implicit-prelude -Wno-safe -Wno-unsafe -Wno-missing-safe-haskell-mode -Wno-missing-deriving-strategies -Wno-all-missed-specialisations -Wno-missed-specialisations
45+
if impl (ghc >= 9.2)
46+
ghc-options: -Wno-missing-kind-signatures
47+
if impl (ghc >= 9.8)
48+
ghc-options: -Wno-missing-role-annotations -Wno-missing-poly-kind-signatures
49+
if impl (ghc >= 9.10)
50+
ghc-options: -Wno-defaulted-exception-context
4551
else
4652
ghc-options: -Wall

package.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ description: Please see the README on GitHub at <https://github.com/gith
2121
dependencies:
2222
- base >= 4.7 && < 5
2323
- isocline >= 1.0 && < 1.1
24-
- optparse-applicative >= 0.17 && < 0.19
24+
- optparse-applicative >= 0.16 && < 0.19
2525
- safe-exceptions >= 0.1 && < 0.2
2626

2727
flags:
@@ -38,7 +38,6 @@ when:
3838
- -Werror
3939
- -Wno-missing-local-signatures
4040
- -Wno-monomorphism-restriction
41-
- -Wno-missing-kind-signatures
4241
- -Wno-prepositive-qualified-module
4342
- -Wno-implicit-prelude
4443
- -Wno-safe
@@ -47,6 +46,17 @@ when:
4746
- -Wno-missing-deriving-strategies
4847
- -Wno-all-missed-specialisations
4948
- -Wno-missed-specialisations
49+
when:
50+
- condition: impl (ghc >= 9.2)
51+
ghc-options:
52+
- -Wno-missing-kind-signatures
53+
- condition: impl (ghc >= 9.8)
54+
ghc-options:
55+
- -Wno-missing-role-annotations
56+
- -Wno-missing-poly-kind-signatures
57+
- condition: impl (ghc >= 9.10)
58+
ghc-options:
59+
- -Wno-defaulted-exception-context
5060
else:
5161
ghc-options:
5262
- -Wall

scripts/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -e
55
source scripts/lib/run-in-container.sh
66

77
./scripts/format-repo
8-
./scripts/test
8+
./scripts/test-all

scripts/format-repo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e
55
source scripts/lib/run-in-container.sh
66

77
if [ "$CI" ]; then
8+
git config --global --add safe.directory $PWD
89
MODE=check
910
else
1011
MODE=inplace

scripts/lib/run-in-container.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ if [ "$IN_DEV_CONTAINER" ]; then
33
:
44
else
55
docker compose build
6-
exec docker compose run dev $0 "$@"
6+
exec docker compose run --rm dev $0 "$@"
77
fi

scripts/test-all

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
#
4+
# This script will run compile and run the tests against all the
5+
# stack*.yaml files that are found in the root of the repo, reporting
6+
# whether each one passed or failed.
7+
#
8+
# It is generally useful for doing a final check before pushing, rather
9+
# then as the regular edit/compile/test loop to get feedback during
10+
# development.
11+
12+
. scripts/lib/run-in-container.sh
13+
14+
rm -rf test-all-logs
15+
mkdir test-all-logs
16+
17+
for stack_file in stack-ghc*.yaml; do
18+
log_file="./test-all-logs/$stack_file.log"
19+
20+
echo "Testing with $stack_file... "
21+
if stack --stack-yaml "$stack_file" test >"$log_file" 2>&1; then
22+
echo "Passed"
23+
else
24+
SOME_TEST_FAILED=1
25+
echo "Failed, see $log_file for details"
26+
fi
27+
done
28+
29+
if [ "$SOME_TEST_FAILED" ]; then
30+
echo ""
31+
echo "!!"
32+
echo "!! At least one test failed above. Be sure to check it out!"
33+
echo "!!"
34+
exit 1
35+
fi

0 commit comments

Comments
 (0)