forked from libmir/mir-algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
348 lines (325 loc) · 12.9 KB
/
ci.yml
File metadata and controls
348 lines (325 loc) · 12.9 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
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
# allow this workflow to be triggered manually
# Only allow for one job to run at a time, and cancel any jobs currently in progress.
concurrency:
group: gh-actions-${{ github.actor }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
setup:
name: 'Load job configuration'
runs-on: ubuntu-24.04
outputs:
compilers: ${{ steps.load-config.outputs.compilers }}
steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
# This step checks if we want to only run tests on a specific platform or
# if we want to skip CI entirely, then outputs the compilers to be used for
# each job.
- id: load-config
uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e
with:
script: |
const base_compiler_config = require("./.github/workflows/compilers.json");
const compilers = {"windows": [], "macos": [], "ubuntu": []};
const {owner, repo} = context.repo;
let commit_sha = context.sha;
if (context.eventName == "pull_request")
{
commit_sha = context.payload.pull_request.head.sha;
}
const commit = await github.rest.git.getCommit({
owner,
repo,
commit_sha
});
const head_commit_message = commit.data.message;
if (head_commit_message.startsWith("[windows-only]"))
{
compilers.windows = base_compiler_config;
}
else if (head_commit_message.startsWith("[macos-only]"))
{
compilers.macos = base_compiler_config;
}
else if (head_commit_message.startsWith("[ubuntu-only]"))
{
compilers.ubuntu = base_compiler_config;
}
else if (!head_commit_message.startsWith("[skip-ci]"))
{
compilers.windows = base_compiler_config;
compilers.macos = base_compiler_config;
compilers.ubuntu = base_compiler_config;
}
core.setOutput("compilers", JSON.stringify(compilers));
macos:
name: '[macos] x86_64/${{ matrix.dc }}'
runs-on: macos-15-intel
timeout-minutes: 60
needs: setup
# Only run if the setup phase explicitly defined compilers to be used
if: ${{ fromJSON(needs.setup.outputs.compilers).macos != '' && fromJSON(needs.setup.outputs.compilers).macos != '[]' }}
# Beta / master versions of any compiler are allowed to fail
continue-on-error: ${{ contains(matrix.dc, 'beta') || contains(matrix.dc, 'master') }}
env:
ARCH: x86_64
strategy:
fail-fast: false
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).macos }}
steps:
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Setup D compiler
uses: dlang-community/setup-dlang@d7d85fcde7c4cd5f9a6618fce1bccc316e1e910b
with:
compiler: ${{ matrix.dc }}
- name: Verify toolchain
shell: bash
env:
DC_NAME: ${{ matrix.dc }}
run: |
set -euo pipefail
echo "matrix.dc = ${DC_NAME}"
# dub must exist for all jobs
if ! command -v dub >/dev/null 2>&1; then
echo "ERROR: dub not found on PATH"
exit 1
fi
which dub
file "$(which dub)" || true
dub --version
if [[ "${DC_NAME}" == dmd* ]]; then
if ! command -v dmd >/dev/null 2>&1; then
echo "ERROR: dmd not found on PATH (matrix.dc=${DC_NAME})"
exit 1
fi
dmd --version
elif [[ "${DC_NAME}" == ldc* ]]; then
if ! command -v ldc2 >/dev/null 2>&1; then
echo "ERROR: ldc2 not found on PATH (matrix.dc=${DC_NAME})"
exit 1
fi
ldc2 --version
else
echo "ERROR: Unknown compiler in matrix.dc: '${DC_NAME}' (expected prefix 'dmd' or 'ldc')"
exit 1
fi
echo "ARCH=${ARCH:-<unset>}"
echo "PATH=${PATH}"
- name: Cache dub packages (safe to share)
uses: actions/cache@v4
with:
path: |
~/.dub/packages
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-packages-
- name: Cache dub build cache (compiler-specific)
uses: actions/cache@v4
with:
path: |
~/Library/Caches/dub
key: ${{ runner.os }}-dub-${{ matrix.dc }}-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-cache-${{ matrix.dc }}-
- name: Build / test (nightly compiler; no coverage)
if: contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')
run: dub test --arch=$ARCH --combined
shell: bash
- name: Build / test (stable compiler; with coverage)
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
run: |
dub test --arch=$ARCH --build=unittest-cov
dub test --arch=$ARCH --combined
shell: bash
- name: Upload coverage data
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ubuntu:
name: '[ubuntu] ${{ matrix.arch }}/${{ matrix.dc }}'
runs-on: ubuntu-24.04
timeout-minutes: 60
needs: setup
# Only run if the setup phase explicitly defined compilers to be used
if: ${{ fromJSON(needs.setup.outputs.compilers).ubuntu != '' && fromJSON(needs.setup.outputs.compilers).ubuntu != '[]' }}
# Beta / master versions of any compiler are allowed to fail
continue-on-error: ${{ contains(matrix.dc, 'beta') || contains(matrix.dc, 'master') }}
env:
ARCH: ${{ matrix.arch }}
strategy:
fail-fast: false
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).ubuntu }}
arch: [x86, x86_64]
steps:
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Setup D compiler
uses: dlang-community/setup-dlang@d7d85fcde7c4cd5f9a6618fce1bccc316e1e910b
with:
compiler: ${{ matrix.dc }}
- name: Install multi-lib for 32-bit systems
if: matrix.arch == 'x86'
run: sudo apt-get update && sudo apt-get install gcc-multilib
- name: Verify toolchain
shell: bash
env:
DC_NAME: ${{ matrix.dc }}
run: |
set -euo pipefail
echo "matrix.dc = ${DC_NAME}"
# dub must exist for all jobs
if ! command -v dub >/dev/null 2>&1; then
echo "ERROR: dub not found on PATH"
exit 1
fi
dub --version
if [[ "${DC_NAME}" == dmd* ]]; then
if ! command -v dmd >/dev/null 2>&1; then
echo "ERROR: dmd not found on PATH (matrix.dc=${DC_NAME})"
exit 1
fi
dmd --version
elif [[ "${DC_NAME}" == ldc* ]]; then
if ! command -v ldc2 >/dev/null 2>&1; then
echo "ERROR: ldc2 not found on PATH (matrix.dc=${DC_NAME})"
exit 1
fi
ldc2 --version
else
echo "ERROR: Unknown compiler in matrix.dc: '${DC_NAME}' (expected prefix 'dmd' or 'ldc')"
exit 1
fi
echo "ARCH=${ARCH:-<unset>}"
echo "PATH=${PATH}"
- name: Cache dub packages (safe to share)
uses: actions/cache@v4
with:
path: |
~/.dub/packages
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-packages
- name: Cache dub build cache (compiler-specific)
uses: actions/cache@v4
with:
path: |
~/.cache/dub
key: ${{ runner.os }}-dub-cache-${{ matrix.arch }}-${{ matrix.dc }}-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-cache-${{ matrix.arch }}-${{ matrix.dc }}-
- name: Build / test (nightly compiler; no coverage)
if: contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')
run: dub test --arch=$ARCH --combined
shell: bash
- name: Build / test (stable compiler; with coverage)
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
run: |
dub test --arch=$ARCH --build=unittest-cov
dub test --arch=$ARCH --combined
shell: bash
- name: Upload coverage data
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
windows:
name: '[windows] x86_64/${{ matrix.dc }}'
runs-on: windows-2022
timeout-minutes: 60
needs: setup
# Only run if the setup phase explicitly defined compilers to be used
if: ${{ fromJSON(needs.setup.outputs.compilers).windows != '' && fromJSON(needs.setup.outputs.compilers).windows != '[]' }}
# Beta / master versions of any compiler are allowed to fail
continue-on-error: ${{ contains(matrix.dc, 'beta') || contains(matrix.dc, 'master') }}
env:
ARCH: x86_64
strategy:
fail-fast: false
matrix:
dc: ${{ fromJSON(needs.setup.outputs.compilers).windows }}
steps:
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Setup D compiler
uses: dlang-community/setup-dlang@d7d85fcde7c4cd5f9a6618fce1bccc316e1e910b
with:
compiler: ${{ matrix.dc }}
- name: Verify toolchain
shell: pwsh
env:
DC_NAME: ${{ matrix.dc }}
run: |
Write-Host "matrix.dc = $env:DC_NAME"
dub --version 2>$null
if ($LASTEXITCODE -ne 0) { throw "dub not found" }
if ($env:DC_NAME -like "dmd*") {
dmd --version 2>$null
if ($LASTEXITCODE -ne 0) { throw "dmd not found" }
} elseif ($env:DC_NAME -like "ldc*") {
ldc2 --version 2>$null
if ($LASTEXITCODE -ne 0) { throw "ldc2 not found" }
} else {
throw "Unknown compiler in matrix.dc: '$env:DC_NAME' (expected prefix 'dmd' or 'ldc')"
}
Write-Host "ARCH=$env:ARCH"
Write-Host "Path=$env:Path"
- name: Cache dub packages (safe to share)
uses: actions/cache@v4
with:
path: |
${{ env.APPDATA }}\dub\packages
key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-
- name: Cache dub build cache (compiler-specific)
uses: actions/cache@v4
with:
path: |
${{ env.LOCALAPPDATA }}\dub
key: ${{ runner.os }}-dub-${{ matrix.dc }}-${{ hashFiles('**/dub.sdl', '**/dub.json', '**/dub.selections.json') }}
restore-keys: |
${{ runner.os }}-dub-${{ matrix.dc }}-
# Tests are split up to work around OOM errors -- no combined testing is done
# as it's simply too big for the compiler to handle on Windows.
- name: Build / test (nightly compiler; no coverage)
if: contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')
run: |
dub test --arch=$env:ARCH --build=unittest-ci -c ci-bignum-test
dub test --arch=$env:ARCH --build=unittest-ci -c ci-core-test
dub test --arch=$env:ARCH --build=unittest-ci -c ci-ndslice-test
dub test --arch=$env:ARCH --build=unittest-ci -c ci-test
shell: pwsh
- name: Build / test (stable compiler; with coverage)
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
run: |
dub test --arch=$env:ARCH --build=unittest-cov-ci -c ci-bignum-test
dub test --arch=$env:ARCH --build=unittest-cov-ci -c ci-core-test
dub test --arch=$env:ARCH --build=unittest-cov-ci -c ci-ndslice-test
dub test --arch=$env:ARCH --build=unittest-cov-ci -c ci-test
shell: pwsh
- name: Upload coverage data
if: ${{ !(contains(matrix.dc, 'beta') || contains(matrix.dc, 'master')) }}
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}