-
Notifications
You must be signed in to change notification settings - Fork 14
321 lines (277 loc) · 10.2 KB
/
workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: "/setup"
on:
push:
branches:
- main
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
test:
name: Unit Tests - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: package-lock.json
- run: npm ci --prefer-offline --no-audit --progress=false
- run: npm run bundle
- run: npm test
- name: Ensure generated files are up-to-date
run: git diff --exit-code dist/ lib/
install-haskell:
name: GHC ${{ matrix.plan.ghc }}, Cabal ${{ matrix.plan.cabal }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# Let's see how the other installs are doing and not fail on the first
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
plan:
# Latest releases
- ghc: latest
cabal: latest
cabal_update: "true"
# cabal-3.12 build always needs a repo, so, `cabal update` is mandatory
# Latest ghc with cabal head
- ghc: latest
cabal: head
cabal_update: "true"
# Recent releases
- ghc: "9.8"
cabal: "3.10"
cabal_update: "false"
- ghc: "9.6"
cabal: "3.10"
cabal_update: "true"
# Test #210 (XDG): is the cabal store-dir set to something meaningful?
- ghc: "9.4"
cabal: "3.8"
cabal_update: "false"
- ghc: "9.2"
cabal: "3.6"
cabal_update: "false"
# The following tests do not set 'cabal-update', which defaults to 'true' then.
include:
# Some previously recommended releases of ghc with matching cabal
- os: macos-13
# GHC 9.0 does not work on macos-14 (LLVM problem #77)
plan:
ghc: "9.0"
cabal: "3.4"
- os: ubuntu-latest
plan:
ghc: "8.10"
cabal: "3.2"
- os: ubuntu-latest
plan:
ghc: "8.8"
cabal: "3.0"
# cabal-3.0 install might have the Windows symlinking problem
# https://github.com/haskell/cabal/issues/5748
- os: ubuntu-latest
plan:
ghc: "8.6"
cabal: "2.4"
cabal_update: "false"
# Setting cabal_update to "true" will try to build the test project
# with hackage dependencies, but something goes wrong.
# TODO: figure out what.
# cabal update needed here since cabal-2.4 is still v1
# Test some old versions
- os: ubuntu-latest
plan:
ghc: "8.2.2"
cabal: "2.4.1.0"
cabal_update: "false"
# Test ghcup pre-release channel
- os: ubuntu-latest
ghcup_release_channel: "https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.7.yaml"
plan:
ghc: "9.6.0.20230111"
cabal: "3.8"
# Test ghc nightly
- os: ubuntu-latest
ghcup_release_channel: "https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml"
plan:
ghc: "latest-nightly"
cabal: "latest"
## Andreas, 2024-05-03, deprecate GHC 7, do not test it any longer
#
# - os: ubuntu-20.04
# plan:
# ghc: "7.4.2"
# cabal: "3.4"
# # ubuntu-20.04/hvr has of GHC 7 just 7.0.1, 7.0.4, 7.2.2, 7.4.2, 7.10.3
# # and of cabal just 2.4, 3.0, 3.2, 3.4
# # according to https://launchpad.net/~hvr/+archive/ubuntu/ghc?field.series_filter=focal
#
# # setup does something special for 7.10.3 (issue #79)
# - os: ubuntu-20.04
# plan:
# ghc: "7.10.3"
# cabal: "3.6"
# - os: macOS-latest
# plan:
# ghc: "7.10.3"
# cabal: "3.4"
#
# # Andreas 2022-12-29, issue #98: GHC 7.10 failed to install on windows (choco)
# - os: windows-latest
# plan:
# ghc: "7.10"
# cabal: "3.0"
## Andreas, 2024-05-03, stop testing old minor versions
#
# # Test for issue #129: GHC 9.4.3 failed to install on windows (choco)
# - os: windows-latest
# plan:
# ghc: "9.4.3"
# cabal: "3.8.1.0"
# # Test ghcup on windows (PR #206) which choco does not have 9.4.5
# - os: windows-latest
# plan:
# ghc: "9.4.5"
# cabal: "3.8"
# # Test GHC 9.4.4 on windows (Issue #245)
# - os: windows-latest
# plan:
# ghc: "9.4.4"
# cabal: "3.10.1.0"
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup
with:
ghc-version: ${{ matrix.plan.ghc }}
ghcup-release-channel: ${{ matrix.ghcup_release_channel }}
cabal-version: ${{ matrix.plan.cabal }}
cabal-update: ${{ matrix.plan.cabal_update }}
- name: Show installed versions and PATH
run: |
cabal --version
ghc --version
echo "$PATH"
- name: Confirm resolved and installed versions match
shell: bash
run: |
CABALVER="$(cabal --numeric-version)"
GHCVER="$(ghc --numeric-version)"
echo "CABALVER=${CABALVER}" >> "${GITHUB_ENV}"
echo "GHCVER=${GHCVER}" >> "${GITHUB_ENV}"
if [[ "${{ steps.setup.outputs.ghc-version }}" == "latest-nightly" ]]
then
GHCVER_EXPECTED=$( \
curl "${{ matrix.ghcup_release_channel }}" | \
yq '.ghcupDownloads.GHC[] | select(.viTags[] | contains("LatestNightly")) | key' \
)
echo "Latest nightly: ${GHCVER_EXPECTED}"
else
GHCVER_EXPECTED="${{ steps.setup.outputs.ghc-version }}"
fi
if [[ "${{ steps.setup.outputs.cabal-version }}" == "head" ]]
then
CABALVER_EXPECTED=$( \
curl --silent https://raw.githubusercontent.com/haskell/cabal/master/cabal-install/cabal-install.cabal | \
sed -E -n 's/^Version:[[:space:]]+//p' \
)
echo "Cabal head: ${CABALVER_EXPECTED}"
else
CABALVER_EXPECTED="${{ steps.setup.outputs.cabal-version }}"
fi
[[ "${CABALVER_EXPECTED}" == ${CABALVER}* ]] && \
[[ "${GHCVER}" == "${GHCVER_EXPECTED}" ]]
- name: Test runghc
run: |
runghc --version
runghc __tests__/hello.hs
- name: Build test project
working-directory: __tests__/project
run: cabal build
- name: Run test project
working-directory: __tests__/project
run: cabal run
- name: Install test project
working-directory: __tests__/project
run: cabal install
- name: Run installed test project
run: hello-haskell-setup
# This tests whether the default installdir has been added to the PATH (issue #130).
- name: Build and run test with Hackage dependency
if: ${{ matrix.plan.cabal_update != 'false' }}
working-directory: __tests__/project-with-hackage-dependency
run: cabal build && cabal run
- name: Confirm installed and expected versions match
shell: bash
# check that if given in the matrix, the actual version matches:
# - cabal: major version
# - ghc: major and minor version
# pure bash startsWith
run: |
if [[ "${{ matrix.plan.cabal }}" =~ ^([0-9]+\.[0-9]+) ]]; then cabalmajor="${BASH_REMATCH[1]}"; fi
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+) ]]; then ghcmajor="${BASH_REMATCH[1]}"; fi
if [[ "${{ matrix.plan.ghc }}" =~ ^([0-9]+\.[0-9]+\.[0-9]+) ]]; then ghcver="${BASH_REMATCH[1]}"; fi
[[ "${CABALVER}" =~ ^"${cabalmajor}" ]] && [[ "${GHCVER}" =~ ^"${ghcmajor}" ]] && [[ "${GHCVER}" =~ ^"${ghcver}" ]]
test-fallback:
name: Test GHC Installation Fallbacks - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup
env:
RUNNER_DEBUG: "1"
with:
ghc-version: 8.21.5
- name: Error on success
if: steps.setup.outputs.failed != 'true'
# NB: 'failed' is an undeclared output of the setup action, used in debug mode
run: |
echo "Error: ghc 8.21.5 didn't fail to install"
install-stack:
name: Stack ${{ matrix.stack }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
stack: ["latest", "2.9.3"]
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup
with:
enable-stack: true
stack-no-global: true
stack-version: ${{ matrix.stack }}
- run: |
stack --version
stack --help
- name: Checking if returned stack-root output is correct
shell: bash
# NB: we invoke `stack path` twice, because the first time it
# might install things (like MSYS2 on Windows) which clobber the output.
run: |
stack path --system-ghc
expected_stack_root=$(stack path --system-ghc --stack-root)
if [ "${expected_stack_root}" != "${{ steps.setup.outputs.stack-root }}" ]; then
echo "Stack-root does not match expected value"
echo "Expected stack-root: ${expected_stack_root}"
echo "Returned stack-root: ${{ steps.setup.outputs.stack-root }}"
exit 1
fi