-
Notifications
You must be signed in to change notification settings - Fork 7
330 lines (272 loc) · 9.52 KB
/
haskell.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
322
323
324
325
326
327
328
329
330
name: Haskell CI
on:
push:
branches: [ "main" ]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Build and test
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.2.8", "9.4.8", "9.6.4", "9.8.2"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest, windows-latest, macOS-latest]
cabal-flags: [""]
no-debug: [""]
exclude:
- ghc: "9.4.8"
os: windows-latest
- ghc: "9.4.8"
os: macOS-latest
- ghc: "9.8.2"
os: windows-latest
- ghc: "9.8.2"
os: macOS-latest
include:
- ghc: "9.6.4"
cabal: "3.10.2.1"
os: ubuntu-latest
cabal-flags: "+serialblockio"
- ghc: "9.6.4"
cabal: "3.10.2.1"
os: ubuntu-latest
no-debug: "no-debug"
timeout-minutes: 60
steps:
- name: CPU info (macOS)
if: ${{ startsWith(matrix.os, 'macOS') }}
run: sysctl -a machdep.cpu
- name: CPU info (Linux)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: cat /proc/cpuinfo
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: true
- name: Install liburing (on Linux)
id: setup-liburing
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt-get update || true
sudo apt-get -y install liburing-dev
sudo apt-get -y install librocksdb-dev
- name: Configure the build
run: |
cabal configure --enable-tests --enable-benchmark --ghc-options="-Werror" --flag="${{ matrix.cabal-flags }}"
cat cabal.project.local
- name: Configure the build (no-debug)
if: ${{ matrix.no-debug }}
run: |
echo "" > cabal.project.debug
cat cabal.project.debug
- name: Record cabal dependencies
id: record-deps
run: |
cabal build all --dry-run
- name: "Restore cache"
uses: actions/cache/restore@v4
id: restore-cabal-cache
env:
cache-name: cache-cabal-build
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}-${{ hashFiles('**/cabal.project.debug') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}-
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-
- name: Install cabal dependencies
id: build-dependencies
run: cabal build --only-dependencies --enable-tests --enable-benchmarks all
- name: "Save cache"
uses: actions/cache/save@v4
id: save-cabal-cache
# Note: cache-hit will be set to true only when cache hit occurs for the
# exact key match. For a partial key match via restore-keys or a cache
# miss, it will be set to false.
if: steps.build-dependencies.outcome == 'success' && steps.restore-cabal-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }}
- name: Build
run: cabal build all
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set test timeout (Unix)
if: ${{ startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macOS') }}
run: |
echo "TASTY_TIMEOUT=5m" >> "$GITHUB_ENV"
# https://github.com/actions/runner/issues/2281#issuecomment-1326748709
- name: Set test timeout (Windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
echo "TASTY_TIMEOUT=5m" >> "$env:GITHUB_ENV"
- name: Run tests
run: |
cabal test -j1 --test-show-details=direct all
- name: cabal-docspec
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20240414/cabal-docspec-0.0.0.20240414-x86_64-linux.xz > cabal-docspec.xz
echo '2d18a3f79619e8ec5f11870f926f6dc2616e02a6c889315b7f82044b95a1adb9 cabal-docspec.xz' | sha256sum -c -
xz -d < cabal-docspec.xz > ./cabal-docspec
chmod a+x ./cabal-docspec
./cabal-docspec --extra-package lsm-tree:prototypes -XOverloadedStrings -XNumericUnderscores
# Check formatting for Haskell files
stylish-haskell:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.6.4"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest]
# Fix the index-state so we can get proper caching effects. Change this to a
# more recent time if you want to use a newer version of stylish-haskell, or
# if you want stylish-haskell to use updated dependencies.
#
# We use this environment variable in the primary key of our caches, and as
# an argument to cabal install. This ensures that we never rebuild
# dependencies because of newly uploaded packages unless we want to.
env:
hackage-index-state: "2024-04-10T14:36:07Z"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install system dependencies (apt-get)
run: |
sudo apt-get update || true
sudo apt-get -y install fd-find
- name: Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: false
- name: Cabal update
run: cabal update
- name: Setup cabal bin path
run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- name: Cache cabal store
uses: actions/cache@v4
env:
cache-name: cache-cabal-stylish
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ env.hackage-index-state }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-
- name: Install stylish-haskell
run: cabal install --ignore-project --index-state="${{ env.hackage-index-state }}" stylish-haskell --constraint 'stylish-haskell == 0.14.6.0'
- name: Record stylish-haskell version
run: |
which stylish-haskell
stylish-haskell --version
- name: Run stylish-haskell
run: |
./scripts/format-stylish-fd.sh
git diff --exit-code
# Check formatting for cabal files
cabal-fmt:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.6.4"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest]
# See the comment on the hackage-index-state environment variable for the
# stylish-haskell job.
env:
hackage-index-state: "2024-04-10T14:36:07Z"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install system dependencies (apt-get)
run: |
sudo apt-get update || true
sudo apt-get -y install fd-find
- name: Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: false
- name: Cabal update
run: cabal update
- name: Setup cabal bin path
run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- name: Cache cabal store
uses: actions/cache@v4
env:
cache-name: cache-cabal-cabal-fmt-11
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ env.hackage-index-state }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-
- name: Install cabal-fmt
run: cabal install --ignore-project cabal-fmt --index-state="${{ env.hackage-index-state }}" --constraint 'cabal-fmt == 0.1.11'
- name: Record cabal-fmt version
run: |
which cabal-fmt
cabal-fmt --version
- name: Run cabal-fmt
run: |
./scripts/format-cabal-fd.sh
git diff --exit-code
# Check cabal files
cabal-check:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ghc: ["9.6.4"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: false
- name: Cabal update
run: cabal update
- name: Run cabal check
run: |
./scripts/check-cabal.sh
# HLint
hlint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: 'Set up HLint'
uses: haskell-actions/hlint-setup@v2
with:
version: '3.8'
- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["src/", "test/"]'
fail-on: suggestion