-
Notifications
You must be signed in to change notification settings - Fork 3
446 lines (399 loc) · 17.8 KB
/
build.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
name: build & test
on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
jobs:
############
#
# Defines the compiler configurations for the other jobs.
#
#####
define-matrix:
runs-on: ubuntu-latest
env:
config: |
[
{
"prefix": "Linux",
"suffix": "/libc++",
"os": "ubuntu-latest",
"container": {
"image": "ghcr.io/dnkpp/clang:18"
},
"compiler_name": "clang",
"compiler_version": 18,
"libcxx": true,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": {
"image": "ghcr.io/dnkpp/clang:18"
},
"compiler_name": "clang",
"compiler_version": 18,
"libcxx": false,
"asan": true
},
{
"prefix": "Linux",
"suffix": "/libc++",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/clang:17" },
"compiler_name": "clang",
"compiler_version": 17,
"libcxx": true,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/clang:17" },
"compiler_name": "clang",
"compiler_version": 17,
"libcxx": false,
"asan": true
},
{
"prefix": "Linux",
"suffix": "/libc++",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/clang:16" },
"compiler_name": "clang",
"compiler_version": 16,
"libcxx": true,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/clang:16" },
"compiler_name": "clang",
"compiler_version": 16,
"libcxx": false,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/gcc:14" },
"compiler_name": "gcc",
"compiler_version": 14,
"libcxx": false,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/gcc:13" },
"compiler_name": "gcc",
"compiler_version": 13,
"libcxx": false,
"asan": true
},
{
"prefix": "Linux",
"os": "ubuntu-latest",
"container": { "image": "ghcr.io/dnkpp/gcc:12" },
"compiler_name": "gcc",
"compiler_version": 12,
"libcxx": false,
"asan": true
},
{
"prefix": "Windows 2022",
"os": "windows-2022",
"compiler_name": "msvc",
"compiler_version": "v143",
"cmake_generator": "Visual Studio 17 2022",
"libcxx": false,
"asan": false
},
{
"prefix": "Windows 2022",
"os": "windows-2022",
"compiler_name": "msvc",
"compiler_version": "ClangCl",
"cmake_generator": "Visual Studio 17 2022",
"libcxx": false,
"asan": false
},
{
"prefix": "macOS",
"os": "macos-latest",
"compiler_name": "AppleClang",
"compiler_version": 18,
"ldflags_workaround": "-L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib/unwind -lunwind",
"asan": true
},
{
"prefix": "macOS",
"os": "macos-latest",
"compiler_name": "AppleClang",
"compiler_version": 17,
"ldflags_workaround": "-L/opt/homebrew/opt/llvm@17/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@17/lib/c++",
"asan": true
},
{
"prefix": "macOS",
"os": "macos-latest",
"compiler_name": "AppleClang",
"compiler_version": 16,
"ldflags_workaround": "-L/opt/homebrew/opt/llvm@16/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm@16/lib/c++",
"asan": true
}
]
outputs:
config: ${{ steps.output-config.outputs.config }}
build_modes: ${{ steps.output-options.outputs.build_modes }}
cxx_versions: ${{ steps.output-options.outputs.cxx_versions }}
steps:
- name: Output configs
id: output-config
shell: bash
run: |
# seems to convert that to a single-line json and thus please the output step
# wrap in single '!
OUTPUT='${{ env.config }}'
echo "config=$(echo $OUTPUT)" >> "$GITHUB_OUTPUT"
# enables debug-mode and c++20 for all cases
- name: Enable base matrix
shell: bash
run: |
echo "BUILD_MODES=\"Debug\"" >> $GITHUB_ENV
echo "CXX_VERSIONS=20" >> $GITHUB_ENV
# if its a PR from development or the main branch in general, add release-mode and c++23
- name: Enable extended matrix
if: ${{
(github.event_name == 'pull_request' && github.head_ref == 'development')
|| github.ref_name == 'main'
}}
shell: bash
run: |
echo "BUILD_MODES=$(echo $BUILD_MODES, \"Release\")" >> $GITHUB_ENV
echo "CXX_VERSIONS=$(echo $CXX_VERSIONS, 23)" >> $GITHUB_ENV
- name: Output build-modes and c++-versions
id: output-options
shell: bash
run: |
echo "build_modes=$(echo [ $BUILD_MODES ])" >> "$GITHUB_OUTPUT"
echo "cxx_versions=$(echo [ $CXX_VERSIONS ])" >> "$GITHUB_OUTPUT"
############
#
# Runs all general unit tests and examples, without any adapter tests.
# They are excluded, because the dependency fetching and building increased the build times quite heavily,
# which does not scale properly.
#
# Runs all tests on every machine with
# - debug and release
# - c++20 and c++23
# - std- and fmt-formatting backend
#
#####
run-unit-tests:
needs: define-matrix
name: |
[UT]
${{ matrix.config.prefix }}
${{ matrix.config.compiler_name }}-${{ matrix.config.compiler_version }}
${{ matrix.config.suffix }}
(C++${{ matrix.cxx_standard }}, ${{ matrix.build_mode }}, ${{ matrix.format_backend }}, ${{ matrix.str_matcher }})
runs-on: ${{ matrix.config.os }}
container: ${{ matrix.config.container }}
strategy:
fail-fast: false
matrix:
format_backend: [std, fmt]
str_matcher: [char, unicode]
build_mode: ${{ fromJSON(needs.define-matrix.outputs.build_modes) }}
cxx_standard: ${{ fromJSON(needs.define-matrix.outputs.cxx_versions) }}
config: ${{ fromJSON(needs.define-matrix.outputs.config) }}
exclude:
# all listed compilers do not support std's format header
- format_backend: "std"
config:
compiler_name: "clang"
compiler_version: 16
- format_backend: "std"
config:
compiler_name: "gcc"
compiler_version: 12
- format_backend: "std"
config:
compiler_name: "AppleClang"
compiler_version: 16
# The format_backend and str_matcher options are rather orthogonal.
# To see, whether support both str_matcher variants, let's use the fmt backend,
# as this is supported by all compilers.
- format_backend: "std"
str_matcher: "unicode"
steps:
- uses: actions/checkout@v4
- name: Setup macOS
if: startsWith(matrix.config.os, 'macOS')
shell: bash
run: |
env brew install ninja llvm
LLVM_NAME=llvm@${{ matrix.config.compiler_version }}
env brew install $LLVM_NAME
LLVM_PATH="$(brew --prefix $LLVM_NAME)"
echo "CC=$(echo $LLVM_PATH/bin/clang)" >> $GITHUB_ENV
echo "CXX=$(echo $LLVM_PATH/bin/clang++)" >> $GITHUB_ENV
# solves this issue: https://github.com/Homebrew/homebrew-core/issues/178435
echo "LDFLAGS=$(echo $LDFLAGS ${{ matrix.config.ldflags_workaround }})" >> $GITHUB_ENV
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV
- name: Clang libc++ setup
if: ${{ matrix.config.compiler_name == 'clang' && matrix.config.libcxx == true }}
shell: bash
run: |
echo "CXXFLAGS=$(echo $CXXFLAGS -stdlib=libc++)" >> $GITHUB_ENV
echo "LDFLAGS=$(echo $LDFLAGS -lc++abi)" >> $GITHUB_ENV
- name: Setup linux
if: ${{ matrix.config.prefix == 'Linux' }}
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV
- name: Setup msvc
if: ${{ matrix.config.compiler_name == 'msvc' }}
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -G\"${{ matrix.config.cmake_generator }}\" -T\"${{ matrix.config.compiler_version }}\" -Ax64)" >> $GITHUB_ENV
echo "CMAKE_BUILD_EXTRA=$(echo $CMAKE_BUILD_EXTRA --config ${{ matrix.build_mode }})" >> $GITHUB_ENV
- name: Enable Address and Undefined Sanitizer
if: ${{ matrix.config.asan == true }}
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DSANITIZE_ADDRESS=YES -DSANITIZE_UNDEFINED=YES)" >> $GITHUB_ENV
- name: Setup fmt as formatting backend
if: startsWith(matrix.format_backend, 'fmt')
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_USE_FMT=YES)" >> $GITHUB_ENV
- name: Enable unicode support for string matchers
if: startsWith(matrix.str_matcher, 'unicode')
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER=YES)" >> $GITHUB_ENV
# ASan has some serious trouble with libc++ exception mechanism
# see: https://github.com/llvm/llvm-project/issues/59432
- name: Disable alloc_dealloc_mismatch detection with libc++
if: ${{ matrix.config.asan == true && matrix.config.libcxx == true}}
shell: bash
run: |
echo "ASAN_OPTIONS=$(echo $ASAN_OPTIONS:alloc_dealloc_mismatch=0)" >> $GITHUB_ENV
- name: Configure
shell: bash
run: |
cmake \
-S . \
-B build \
-D CMAKE_VERBOSE_MAKEFILE=yes \
-D MIMICPP_FORCED_CXX_STANDARD="${{ matrix.cxx_standard }}" \
${{ env.CMAKE_CONFIG_EXTRA }}
- name: Build
shell: bash
run: |
cmake --build build \
-j5 \
${{ env.CMAKE_BUILD_EXTRA }}
- name: Run tests
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
ctest --test-dir build/test/unit-tests \
-C ${{ matrix.build_mode }} \
-j5
- name: Run examples
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
ctest --test-dir build/examples \
-C ${{ matrix.build_mode }} \
-j5
############
#
# Runs the adapter test on every machine.
#
#####
run-adapter-tests:
needs: define-matrix
name: |
[AT]
${{ matrix.config.prefix }}
${{ matrix.config.compiler_name }}-${{ matrix.config.compiler_version }}
${{ matrix.config.suffix }}
(C++${{ matrix.cxx_standard }}, ${{ matrix.build_mode }})
runs-on: ${{ matrix.config.os }}
container: ${{ matrix.config.container }}
strategy:
fail-fast: false
matrix:
build_mode: ${{ fromJSON(needs.define-matrix.outputs.build_modes) }}
cxx_standard: ${{ fromJSON(needs.define-matrix.outputs.cxx_versions) }}
config: ${{ fromJSON(needs.define-matrix.outputs.config) }}
steps:
- uses: actions/checkout@v4
- name: Setup macOS
if: startsWith(matrix.config.os, 'macOS')
shell: bash
run: |
env brew install ninja llvm
LLVM_NAME=llvm@${{ matrix.config.compiler_version }}
env brew install $LLVM_NAME
LLVM_PATH="$(brew --prefix $LLVM_NAME)"
echo "CC=$(echo $LLVM_PATH/bin/clang)" >> $GITHUB_ENV
echo "CXX=$(echo $LLVM_PATH/bin/clang++)" >> $GITHUB_ENV
echo "LDFLAGS=$(echo $LDFLAGS ${{ matrix.config.ldflags_workaround }})" >> $GITHUB_ENV
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV
- name: Clang libc++ setup
if: ${{ matrix.config.compiler_name == 'clang' && matrix.config.libcxx == true }}
shell: bash
run: |
echo "CXXFLAGS=$(echo $CXXFLAGS -stdlib=libc++)" >> $GITHUB_ENV
echo "LDFLAGS=$(echo $LDFLAGS -lc++abi)" >> $GITHUB_ENV
- name: Setup linux
if: ${{ matrix.config.prefix == 'Linux' }}
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DCMAKE_BUILD_TYPE=${{ matrix.build_mode }})" >> $GITHUB_ENV
- name: Setup msvc
if: ${{ matrix.config.compiler_name == 'msvc' }}
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -G\"${{ matrix.config.cmake_generator }}\" -T\"${{ matrix.config.compiler_version }}\" -Ax64)" >> $GITHUB_ENV
echo "CMAKE_BUILD_EXTRA=$(echo $CMAKE_BUILD_EXTRA --config ${{ matrix.build_mode }})" >> $GITHUB_ENV
# This is enabled by default, because that's the only formatting-backend which is supported by every compiler.
- name: Setup fmt as formatting backend
shell: bash
run: |
echo "CMAKE_CONFIG_EXTRA=$(echo $CMAKE_CONFIG_EXTRA -DMIMICPP_CONFIG_USE_FMT=YES)" >> $GITHUB_ENV
- name: Configure
shell: bash
run: |
cmake \
-S . \
-B build \
-D CMAKE_VERBOSE_MAKEFILE=yes \
-D MIMICPP_FORCED_CXX_STANDARD="${{ matrix.cxx_standard }}" \
-D MIMICPP_ENABLE_ADAPTER_TESTS=YES \
-D MIMICPP_CONFIG_EXPERIMENTAL_CATCH2_MATCHER_INTEGRATION=YES \
${{ env.CMAKE_CONFIG_EXTRA }}
- name: Build
shell: bash
run: |
cmake --build build \
-j5 \
${{ env.CMAKE_BUILD_EXTRA }}
- name: Run adapter tests
shell: bash
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: |
ctest --test-dir build/test/adapter-tests \
-C ${{ matrix.build_mode }} \
-j5