-
Notifications
You must be signed in to change notification settings - Fork 1
226 lines (192 loc) · 6.95 KB
/
Copy pathhaskell.yml
File metadata and controls
226 lines (192 loc) · 6.95 KB
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
name: Build and test
on:
push:
branches:
- main
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
setup-matrix:
name: Setup matrix
runs-on: 'ubuntu-latest'
timeout-minutes: 5
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
defaults:
run:
shell: bash
steps:
- name: 🛠️ Setup matrix (PR)
if: ${{ github.event_name == 'pull_request' }}
run: |
{ echo 'MATRIX_COMBINATIONS<<EOF'
echo '{"runner": "ubuntu-latest", "ghc": "9.4", "llvm": "15"},'
echo '{"runner": "ubuntu-latest", "ghc": "9.4", "llvm": "22"},'
echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "14"},'
echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "22"},'
echo EOF
} >> "$GITHUB_ENV"
- name: 🛠️ Setup matrix (MQ, push to main)
if: ${{ github.event_name != 'pull_request' }}
run: |
{ echo 'MATRIX_COMBINATIONS<<EOF'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "15"},'
echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "14"},'
echo '{"runner": "macos-latest" , "ghc": "9.4", "llvm": "22"},'
# Vary LLVM version from 14 to 22.
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "16"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "18"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "20"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "21"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.4", "llvm": "22"},'
# Vary GHC version from 9.2 to 9.14.
echo '{"runner": "ubuntu-latest" , "ghc": "9.2", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.6", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.8", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.10", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.12", "llvm": "14"},'
echo '{"runner": "ubuntu-latest" , "ghc": "9.14", "llvm": "14"},'
echo EOF
} >> "$GITHUB_ENV"
- name: 🛠️ Setup matrix
id: setup-matrix
run: |
echo $MATRIX_COMBINATIONS
MATRIX="{\"include\":[$MATRIX_COMBINATIONS]}"
echo $MATRIX
{
echo 'MATRIX<<EOF'
echo "$MATRIX"
echo EOF
} >> "$GITHUB_OUTPUT"
check-success:
name: Check success
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- build-and-test
defaults:
run:
shell: bash
if: ${{ !cancelled() }}
steps:
- name: 🧪 Report failure
if: ${{ needs.build-and-test.result == 'failure' }}
run: |
echo "Some jobs failed"
exit 1
- name: 🧪 Report success
if: ${{ needs.build-and-test.result == 'success' }}
run: |
echo "All jobs succeeded"
exit 0
build-and-test:
name: Run (${{ matrix.runner }}, GHC${{ matrix.ghc }}, LLVM${{matrix.llvm }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
needs:
- setup-matrix
strategy:
matrix: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
fail-fast: false
env:
# Increment this number to reset caches.
#
# Caches of the cabal store generally grow in size: new packages are
# added, but never removed. Unless we start with a fresh cabal store once
# in a while. The cache-reset-number is part of the cache key, and if it
# is incremented, then the "Restor cache" step fails to restore a cache,
# meaning we will start with an empty cabal store that we will then save a
# new cache for.
#
# Bumped to 1 when LLVM installation moved off install-llvm-action to
# apt: the apt libclang has a different SONAME (libclang-N.so.N vs
# upstream libclang.so.N), so cabal stores built against the old toolchain
# fail to load libclang at Template-Haskell time.
cache-reset-number: 1
defaults:
run:
shell: bash
steps:
- name: 🛠️ Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: 🛠️ Fix git on macOS (prioritize system git over Homebrew)
if: runner.os == 'macOS'
run: |
echo "/usr/bin" >> "$GITHUB_PATH"
- name: 📥 Checkout
uses: actions/checkout@v7
- name: (Debug) Check disk usage (init)
run: |
echo "--- Disk usage ---"
df -h
echo "--- Home directory size ---"
du -sh $HOME
- name: 🛠️ Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 3.16
- name: 🧪 Debug (Haskell)
run: |
echo '### ghc --version'
ghc --version
echo '### ghc-pkg list'
ghc-pkg list
echo '### ghc --info'
ghc --info
- name: 🛠️ Install LLVM/Clang
uses: ./.github/actions/setup-llvm
with:
version: ${{ matrix.llvm }}
- name: (Debug) Check disk usage (after GHC and LLVM install)
run: |
echo "--- Disk usage ---"
df -h
echo "--- Home directory size ---"
du -sh $HOME
- name: 🛠️ Configure
run: |
cabal configure \
--enable-tests \
--enable-benchmarks \
--disable-documentation \
--ghc-options="-Werror"
cat cabal.project.local
- name: 💾 Generate Cabal plan
run: cabal build all --dry-run
- name: 💾 Restore cache
id: cache-cabal-restore
uses: actions/cache/restore@v6
env:
key: build-and-test-${{ env.cache-reset-number }}-${{ matrix.runner }}-ghc-${{ steps.setup-haskell.outputs.ghc-version }}-cabal-${{ steps.setup-haskell.outputs.cabal-version }}-llvm-${{ matrix.llvm }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('dist-newstyle/cache/plan.json') }}
restore-keys: ${{ env.key }}-
- name: 🛠️ Build Cabal dependencies
run: cabal build all --only-dependencies
# Only save a new cache if it does not exist yet
- name: 💾 Save Cabal dependencies
uses: actions/cache/save@v6
if: ${{ steps.cache-cabal-restore.outputs.cache-hit != 'true' }}
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.cache-cabal-restore.outputs.cache-primary-key }}
- name: 🏗️ Build
run: cabal build all
- name: (Debug) Check disk usage (after build)
run: |
echo "--- Disk usage ---"
df -h
echo "--- Home directory size ---"
du -sh $HOME
- name: 🧪 Test
run: cabal test all --test-show-details=direct