77 push :
88 branches : [ "master" ]
99
10+ defaults :
11+ run :
12+ shell : bash
13+
1014jobs :
11- ghc :
15+ tested-with-matrix :
16+ name : " Generate matrix from cabal"
17+ outputs :
18+ matrix : ${{ steps.set-matrix.outputs.matrix }}
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Extract the tested GHC versions
22+ id : set-matrix
23+ uses : kleidukos/get-tested@v0.1.9.1
24+ with :
25+ cabal-file : mtl.cabal
26+ ubuntu-version : " latest"
27+ macos-version : " latest"
28+ windows-version : " latest"
29+ version : 0.1.9.1
30+
31+ # workaround for https://github.com/Kleidukos/get-tested/issues/93
32+ tested-with-ghcs :
33+ runs-on : ubuntu-latest
34+ needs : ["tested-with-matrix"]
35+ outputs :
36+ matrix : ${{ steps.set-matrix.outputs.matrix }}
37+
38+ steps :
39+ - name : Generate output
40+ id : set-matrix
41+ run : |
42+ set -euo pipefail
43+ ghc_versions=$(echo '${{ needs.tested-with-matrix.outputs.matrix }}' | jq -c -r '[.include[].ghc] | unique')
44+ echo "${ghc_versions}"
45+ echo matrix="${ghc_versions}" >> "$GITHUB_OUTPUT"
46+
47+ lts-matrix :
48+ runs-on : ubuntu-latest
49+ outputs :
50+ matrix : ${{ steps.set-matrix.outputs.matrix }}
51+
52+ steps :
53+ - name : Generate output
54+ id : set-matrix
55+ run : |
56+ : "${STACK_TEST_NUM:=4}"
57+ set -euo pipefail
58+
59+ # the input is something like this:
60+ # {"lts":"lts-24.36", "lts-0":"lts-0.7", "lts-1":"lts-1.15", "nightly":"nightly-2026-04-10"}
61+ # and we want the last n LTS, sorted and deduplicated without nightlies:
62+ # lts-0.7 lts-1.15 lts-24.36
63+ lts_versions=$(curl -s https://www.stackage.org/download/snapshots.json | jq -c -r --arg n "$STACK_TEST_NUM" '
64+ [.[] | select(startswith("nightly") | not)]
65+ | unique
66+ | sort_by(split("-")[1] | split(".") | map(tonumber))
67+ | .[-(($n | tonumber)):]
68+ ')
69+ echo "${lts_versions}"
70+ echo matrix="${lts_versions}" >> "$GITHUB_OUTPUT"
71+ env :
72+ STACK_TEST_NUM : ${{ vars.STACK_TEST_NUM }}
73+
74+ cabal :
1275 name : " GHC ${{ matrix.ghc }} on ${{ matrix.os }}"
1376 runs-on : ${{ matrix.os }}
77+ needs : ["tested-with-ghcs"]
1478 strategy :
1579 matrix :
1680 os : [ubuntu-latest, macos-latest, windows-latest]
17- ghc : ['8.10', '9.2', '9.8', '9.10', '9.12']
81+ ghc : ${{ fromJSON(needs.tested-with-ghcs.outputs.matrix) }}
1882 exclude :
1983 - os : macos-latest
2084 ghc : ' 8.10' # ghc-8.10 does not support ARM
@@ -25,26 +89,71 @@ jobs:
2589
2690 - name : Set up Haskell
2791 id : setup-haskell
28- uses : haskell-actions/setup@v2
92+ uses : haskell/ghcup-setup@v1
93+ with :
94+ ghc : ${{ matrix.ghc }}
95+ cabal : ' latest'
96+ stack : ' latest'
97+ stack-hook : true
98+
99+ - name : Prepare build dir
100+ run : |
101+ cabal sdist -z -o .
102+ cabal get mtl-*.tar.gz
103+ rm -f cabal.project
104+
105+ - name : Build
106+ run : |
107+ cd mtl-*/
108+ cabal build --ghc-options='-Werror' all
109+
110+ - uses : actions/upload-artifact@v7
29111 with :
30- ghc-version : ${{ matrix.ghc }}
31- cabal-version : ' latest '
112+ name : ${{ matrix.os }}-${{ matrix. ghc }}-plan.json
113+ path : mtl-*/dist-newstyle/cache/plan.json
32114
33- - name : Configure
34- run : cabal new-configure
115+ # - name: Test
116+ # run: |
117+ # cabal --enable-tests --test-show-details=direct all
118+
119+ - name : Haddock
120+ run : |
121+ cd mtl-*/
122+ cabal haddock all
35123
36- - name : Freeze
37- run : cabal freeze
124+ - name : Cabal check
125+ run : |
126+ cd mtl-*/
127+ cabal check
128+
129+ stack :
130+ name : " LTS ${{ matrix.lts }} on ${{ matrix.os }}"
131+ runs-on : ${{ matrix.os }}
132+ needs : ["lts-matrix"]
133+ strategy :
134+ matrix :
135+ os : [ubuntu-latest, macos-latest, windows-latest]
136+ lts : ${{ fromJSON(needs.lts-matrix.outputs.matrix) }}
137+ fail-fast : false
138+ steps :
139+ - name : Checkout base repo
140+ uses : actions/checkout@v4
38141
39- - name : Cache
40- uses : actions/cache@v4
142+ - name : Set up Haskell
143+ id : setup-haskell
144+ uses : haskell/ghcup-setup@v1
41145 with :
42- path : ${{ steps.setup-haskell.outputs.cabal-store }}
43- key : ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
44- restore-keys : ${{ runner.os }}-${{ matrix.ghc }}-
146+ stack : ' latest'
147+ stack-hook : false
45148
46149 - name : Build
47- run : cabal build
150+ run : |
151+ # just in case
152+ rm -f stack.yaml stack.yaml.lock
153+ # create stack.yaml
154+ stack init --resolver=${{ matrix.lts }}
155+ # build
156+ stack build
48157
49158 mhs :
50159 runs-on : ubuntu-latest
0 commit comments