blob: 3e1855ca3c04db0eea3e99cb52f0671c04b2accf [file] [log] [blame]
Daan De Meyerf9726022019-10-10 22:16:49 +02001name: CI
2
3on: push
4
5jobs:
6 ci:
7 name: ${{ matrix.name }}
8 runs-on: ${{ matrix.os }}
9
10 env:
11 CMAKE_GENERATOR: Ninja
12 ASAN_OPTIONS: strict_string_checks=true:detect_odr_violation=2:detect_stack_use_after_return=true:check_initialization_order=true:strict_init_order=true
13 TSAN_OPTIONS: force_seq_cst_atomics=1
Daan De Meyerd1de6182019-10-12 17:57:53 +020014 CTEST_OUTPUT_ON_FAILURE: ON
15 CTEST_PARALLEL_LEVEL: 2
Daan De Meyerf9726022019-10-10 22:16:49 +020016
17 strategy:
18 fail-fast: false
19 matrix:
20 # Github Actions requires a single row to be added to the build matrix.
21 # See https://help.github.com/en/articles/workflow-syntax-for-github-actions.
22 name: [
23 ubuntu-18.04-gcc-4.8,
24 ubuntu-18.04-gcc-4.9,
25 ubuntu-18.04-gcc-5,
26 ubuntu-18.04-gcc-6,
27 ubuntu-18.04-gcc-7,
28 ubuntu-18.04-gcc-8,
29 ubuntu-18.04-gcc-9,
30 ubuntu-18.04-clang-3.5,
31 ubuntu-18.04-clang-3.6,
32 ubuntu-18.04-clang-3.7,
33 ubuntu-18.04-clang-3.8,
34 ubuntu-18.04-clang-3.9,
35 ubuntu-18.04-clang-4.0,
36 ubuntu-18.04-clang-5.0,
37 ubuntu-18.04-clang-6.0,
38 ubuntu-18.04-clang-7,
39 ubuntu-18.04-clang-8,
40 ubuntu-18.04-clang-9,
41 windows-2016-cl,
42 windows-2016-clang-cl,
43 windows-2016-clang,
44 windows-2016-gcc,
45 windows-2019-cl,
46 windows-2019-clang-cl,
47 windows-2019-clang,
48 windows-2019-gcc,
49 macOS-10.14-xcode-9.4.1,
50 macOS-10.14-xcode-10.0,
51 macOS-10.14-xcode-10.1,
52 macOS-10.14-xcode-10.2,
53 macOS-10.14-xcode-10.2.1,
54 macOS-10.14-xcode-10.3,
Daan De Meyer2e3d2652019-10-12 16:10:46 +020055 macOS-10.14-xcode-11.0,
Daan De Meyerf9726022019-10-10 22:16:49 +020056 macOS-10.14-gcc-7,
57 macOS-10.14-gcc-8,
58 macOS-10.14-gcc-9,
59 ]
60
61 include:
62 - name: ubuntu-18.04-gcc-4.8
63 os: ubuntu-18.04
64 compiler: gcc
65 version: "4.8"
66
67 - name: ubuntu-18.04-gcc-4.9
68 os: ubuntu-18.04
69 compiler: gcc
70 version: "4.9"
71
72 - name: ubuntu-18.04-gcc-5
73 os: ubuntu-18.04
74 compiler: gcc
75 version: "5"
76
77 - name: ubuntu-18.04-gcc-6
78 os: ubuntu-18.04
79 compiler: gcc
80 version: "6"
81
82 - name: ubuntu-18.04-gcc-7
83 os: ubuntu-18.04
84 compiler: gcc
85 version: "7"
86
87 - name: ubuntu-18.04-gcc-8
88 os: ubuntu-18.04
89 compiler: gcc
90 version: "8"
91
92 - name: ubuntu-18.04-gcc-9
93 os: ubuntu-18.04
94 compiler: gcc
95 version: "9"
96
97 - name: ubuntu-18.04-clang-3.5
98 os: ubuntu-18.04
99 compiler: clang
100 version: "3.5"
101
102 - name: ubuntu-18.04-clang-3.6
103 os: ubuntu-18.04
104 compiler: clang
105 version: "3.6"
106
107 - name: ubuntu-18.04-clang-3.7
108 os: ubuntu-18.04
109 compiler: clang
110 version: "3.7"
111
112 - name: ubuntu-18.04-clang-3.8
113 os: ubuntu-18.04
114 compiler: clang
115 version: "3.8"
116
117 - name: ubuntu-18.04-clang-3.9
118 os: ubuntu-18.04
119 compiler: clang
120 version: "3.9"
121
122 - name: ubuntu-18.04-clang-4.0
123 os: ubuntu-18.04
124 compiler: clang
125 version: "4.0"
126
127 - name: ubuntu-18.04-clang-5.0
128 os: ubuntu-18.04
129 compiler: clang
130 version: "5.0"
131
132 - name: ubuntu-18.04-clang-6.0
133 os: ubuntu-18.04
134 compiler: clang
135 version: "6.0"
136
137 - name: ubuntu-18.04-clang-7
138 os: ubuntu-18.04
139 compiler: clang
140 version: "7"
141
142 - name: ubuntu-18.04-clang-8
143 os: ubuntu-18.04
144 compiler: clang
145 version: "8"
146
147 - name: ubuntu-18.04-clang-9
148 os: ubuntu-18.04
149 compiler: clang
150 version: "9"
151
152 - name: windows-2016-cl
153 os: windows-2016
154 compiler: cl
155
156 - name: windows-2016-clang-cl
157 os: windows-2016
158 compiler: clang-cl
159
160 - name: windows-2016-clang
161 os: windows-2016
162 compiler: clang
163
164 - name: windows-2019-cl
165 os: windows-2019
166 compiler: cl
167
168 - name: windows-2016-gcc
169 os: windows-2016
170 compiler: gcc
171
172 - name: windows-2019-clang-cl
173 os: windows-2019
174 compiler: clang-cl
175
176 - name: windows-2019-clang
177 os: windows-2019
178 compiler: clang
179
180 - name: windows-2019-gcc
181 os: windows-2019
182 compiler: gcc
183
184 - name: macOS-10.14-xcode-9.4.1
185 os: macOS-10.14
186 compiler: xcode
187 version: "9.4.1"
188
189 - name: macOS-10.14-xcode-10.0
190 os: macOS-10.14
191 compiler: xcode
192 version: "10"
193
194 - name: macOS-10.14-xcode-10.1
195 os: macOS-10.14
196 compiler: xcode
197 version: "10.1"
198
199 - name: macOS-10.14-Xcode-10.2
200 os: macOS-10.14
201 compiler: xcode
202 version: "10.2"
203
204 - name: macOS-10.14-xcode-10.2.1
205 os: macOS-10.14
206 compiler: xcode
207 version: "10.2.1"
208
209 - name: macOS-10.14-xcode-10.3
210 os: macOS-10.14
211 compiler: xcode
212 version: "10.3"
213
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200214 - name: macOS-10.14-xcode-11.0
215 os: macOS-10.14
216 compiler: xcode
217 version: "11"
218
Daan De Meyerf9726022019-10-10 22:16:49 +0200219 - name: macOS-10.14-gcc-7
220 os: macOS-10.14
221 compiler: gcc
222 version: "7"
223
224 - name: macOS-10.14-gcc-8
225 os: macOS-10.14
226 compiler: gcc
227 version: "8"
228
229 - name: macOS-10.14-gcc-9
230 os: macOS-10.14
231 compiler: gcc
232 version: "9"
233
234 steps:
235 - uses: actions/checkout@v1
236
237 - name: Install (Linux)
238 if: runner.os == 'Linux'
239 run: |
240 # CMake 3.15 allows specifying the generator using the CMAKE_GENERATOR
241 # environment variable.
242 curl -sSL https://github.com/Kitware/CMake/releases/download/v3.15.4/cmake-3.15.4-Linux-x86_64.tar.gz -o cmake.tar.gz
243 sudo tar xf cmake.tar.gz --strip 1 -C /usr/local
244
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200245 # Required for libc6-dbg:i386 and g++-multilib packages which are
Daan De Meyerf9726022019-10-10 22:16:49 +0200246 # needed for x86 builds.
247 sudo dpkg --add-architecture i386
248
249 # clang-3.7 and earlier are not available in Bionic anymore so we get
250 # them from the Xenial repositories instead.
251 sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main"
252 sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe"
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200253
Daan De Meyerf9726022019-10-10 22:16:49 +0200254 # LLVM 9 is not in Bionic's repositories so we add the official LLVM repository.
255 if [ "${{ matrix.compiler }}" = "clang" ] && [ "${{ matrix.version }}" = "9" ]; then
256 sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
257 fi
258
259 sudo apt-get update
260
261 # libc6-dbg:i386 is required for running valgrind on x86.
262 sudo apt-get install -y ninja-build valgrind libc6-dbg:i386
263
264 if [ "${{ matrix.compiler }}" = "gcc" ]; then
265 sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
266 echo "::set-env name=CC::gcc-${{ matrix.version }}"
267 echo "::set-env name=CXX::g++-${{ matrix.version }}"
268 else
269 sudo apt-get install -y clang-${{ matrix.version }} g++-multilib
270 echo "::set-env name=CC::clang-${{ matrix.version }}"
271 echo "::set-env name=CXX::clang++-${{ matrix.version }}"
272 fi
273
274 - name: Install (macOS)
275 if: runner.os == 'macOS'
276 run: |
277 brew install cmake ninja
278
279 if [ "${{ matrix.compiler }}" = "gcc" ]; then
280 brew install gcc@${{ matrix.version }}
281 echo "::set-env name=CC::gcc-${{ matrix.version }}"
282 echo "::set-env name=CXX::g++-${{ matrix.version }}"
283 else
284 sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
285 echo "::set-env name=CC::clang"
286 echo "::set-env name=CXX::clang++"
287 fi
288
289 - name: Install (Windows)
290 if: runner.os == 'Windows'
291 shell: powershell
292 run: |
293 Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
294 scoop install ninja --global
295
296 if ("${{ matrix.compiler }}".StartsWith("clang")) {
297 scoop install llvm --global
298 }
299
300 if ("${{ matrix.compiler }}" -eq "gcc") {
301 # Chocolatey GCC is broken on the windows-2019 image.
302 # See: https://github.com/DaanDeMeyer/doctest/runs/231595515
303 # See: https://github.community/t5/GitHub-Actions/Something-is-wrong-with-the-chocolatey-installed-version-of-gcc/td-p/32413
304 scoop install gcc --global
305 echo "::set-env name=CC::gcc"
306 echo "::set-env name=CXX::g++"
307 } elseif ("${{ matrix.compiler }}" -eq "clang") {
308 echo "::set-env name=CC::clang"
309 echo "::set-env name=CXX::clang++"
310 } else {
311 echo "::set-env name=CC::${{ matrix.compiler }}"
312 echo "::set-env name=CXX::${{ matrix.compiler }}"
313 }
314
315 # Scoop modifies the PATH so we make the modified PATH global.
316 echo "::set-env name=PATH::$env:PATH"
317
318 - name: Configure ASAN/UBSAN
319 if: runner.os == 'Linux' || runner.os == 'macOS'
320 run: |
321 # https://stackoverflow.com/a/37939589/11900641
322 function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
323
324 # Disable sanitizers in configurations where we know they are buggy.
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200325
326 # TODO: Move these conditions to the if clause if Github Actions ever
Daan De Meyerf9726022019-10-10 22:16:49 +0200327 # adds support for comparing versions.
328 # See: https://github.community/t5/GitHub-Actions/Allow-comparing-versions-in-if-conditions/m-p/33912#M1710
329
330 if [ "${{ runner.os }}" = "Linux" ] && \
331 [ "${{ matrix.compiler }}" = "gcc" ] && \
332 [ $(version ${{ matrix.version }}) -le $(version "5.0") ]; then
333 exit 0
334 fi
335
336 if [ "${{ runner.os }}" = "Linux" ] && \
337 [ "${{ matrix.compiler }}" = "clang" ] && \
338 [ $(version ${{ matrix.version }}) -le $(version "6.0") ]; then
339 exit 0
340 fi
341
342 if [ "${{ runner.os }}" = "macOS" ] && \
343 [ "${{ matrix.compiler }}" = "xcode" ] && \
344 [ $(version ${{ matrix.version }}) -le $(version "9.4.1") ]; then
345 exit 0
346 fi
347
348 if [ "${{ runner.os }}" = "macOS" ] && \
349 [ "${{ matrix.compiler }}" = "gcc" ]; then
350 exit 0
351 fi
352
353 ASAN_UBSAN_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer"
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200354
355 # Link statically against ASAN libraries because dynamically linking
Daan De Meyerf9726022019-10-10 22:16:49 +0200356 # against ASAN libraries causes problems when using dlopen on Ubuntu.
357 # See: https://github.com/DaanDeMeyer/doctest/runs/249002713
358 if [ "${{ runner.os }}" = "Linux" ] && [ "${{ matrix.compiler }}" = "gcc" ]; then
359 ASAN_UBSAN_FLAGS="$ASAN_UBSAN_FLAGS -static-libasan"
360 fi
361
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200362 # Compiling in bash on Windows doesn't work and powershell doesn't
Daan De Meyerf9726022019-10-10 22:16:49 +0200363 # exit on non-zero exit codes so we're forced to use cmd which means
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200364 # we don't have a cross platform way to access environment variables.
365 # To circumvent this, we put the sanitizer flags in an environment
Daan De Meyerf9726022019-10-10 22:16:49 +0200366 # variable that is automatically picked up by CMake.
367 echo "::set-env name=CXXFLAGS::$ASAN_UBSAN_FLAGS"
368
369 - name: Configure TSAN
370 if: runner.os == 'Linux' || runner.os == 'macOS'
371 run: |
372 # https://stackoverflow.com/a/37939589/11900641
373 function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200374
Daan De Meyerf9726022019-10-10 22:16:49 +0200375 if [ "${{ runner.os }}" = "Linux" ] && \
376 [ "${{ matrix.compiler }}" = "gcc" ] && \
377 [ $(version ${{ matrix.version }}) -le $(version "6.0") ]; then
378 exit 0
379 fi
380
381 if [ "${{ runner.os }}" = "Linux" ] && \
382 [ "${{ matrix.compiler }}" = "clang" ] && \
383 [ $(version ${{ matrix.version }}) -le $(version "3.9") ]; then
384 exit 0
385 fi
386
387 if [ "${{ runner.os }}" = "macOS" ] && \
388 [ "${{ matrix.compiler }}" = "gcc" ]; then
389 exit 0
390 fi
391
392 TSAN_FLAGS="-fsanitize=thread -pie -fPIE"
393
394 if [ "${{ runner.os }}" = "Linux" ] && [ "${{ matrix.compiler }}" = "gcc" ]; then
395 TSAN_FLAGS="$TSAN_FLAGS -static-libtsan"
396 fi
397
Daan De Meyer2e3d2652019-10-12 16:10:46 +0200398 # The thread sanitizers build does not run on Windows so we can just
399 # use bash syntax to access the TSAN flags in the thread sanitizers
Daan De Meyerf9726022019-10-10 22:16:49 +0200400 # build step.
401 echo "::set-env name=TSAN_FLAGS::$TSAN_FLAGS"
402
403 - name: Configure x64
404 if: runner.os == 'Windows'
405 run: .github\workflows\vsenv.bat -arch=x64 -host_arch=x64
406
407 - name: Build & Test Debug x64
408 run: |
409 cmake -E remove_directory build
410 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DDOCTEST_TEST_MODE=COMPARE
411 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200412 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200413
414 - name: Build & Test Release x64
415 run: |
416 cmake -E remove_directory build
417 cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DDOCTEST_TEST_MODE=COMPARE
418 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200419 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200420
421 # Valgrind doesn't support the latest macOS versions.
422 # `-DCMAKE_CXX_FLAGS=""` overrides CXXFLAGS (disables sanitizers).
423
424 - name: Build & Test Debug x64 Valgrind
425 if: runner.os == 'Linux'
426 run: |
427 cmake -E remove_directory build
428 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="" -DDOCTEST_TEST_MODE=VALGRIND
429 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200430 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200431
432 - name: Build & Test Release x64 Valgrind
433 if: runner.os == 'Linux'
434 run: |
435 cmake -E remove_directory build
436 cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="" -DDOCTEST_TEST_MODE=VALGRIND
437 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200438 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200439
440 - name: Build & Test Debug x64 Thread Sanitizers
441 if: runner.os == 'Linux' || runner.os == 'macOS'
442 run: |
443 cmake -E remove_directory build
444 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$TSAN_FLAGS" -DDOCTEST_TEST_MODE=COMPARE
445 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200446 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200447
448 - name: Build & Test Debug x64 without RTTI
449 if: runner.os == 'Linux' || runner.os == 'macOS'
450 run: |
451 cmake -E remove_directory build
452 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fno-rtti" -DDOCTEST_TEST_MODE=COMPARE
453 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200454 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200455
456 - name: Build x64 Debug without exceptions
457 if: runner.os == 'Linux' || runner.os == 'macOS'
458 run: |
459 cmake -E remove_directory build
460 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-fno-exceptions -DDOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS"
461 cmake --build build
462
463 # MinGW x86 tests fail on Windows: https://github.com/DaanDeMeyer/doctest/runs/240600881.
464 # MacOS doesn't support x86 from Xcode 10 onwards.
465
466 - name: Configure x86
467 shell: pwsh
468 if: (runner.os == 'Windows' && matrix.compiler != 'gcc') || runner.os == 'Linux'
469 run: |
470 if ("${{ runner.os }}" -eq "Windows") {
471 & .github\workflows\vsenv.bat -arch=x86 -host_arch=x64
472 }
473
474 if ("${{ matrix.compiler }}" -notcontains "cl") {
475 echo "::set-env name=CXXFLAGS::$env:CXXFLAGS -m32"
476 }
477
478 - name: Build & Test Debug x86
479 if: (runner.os == 'Windows' && matrix.compiler != 'gcc') || runner.os == 'Linux'
480 run: |
481 cmake -E remove_directory build
482 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DDOCTEST_TEST_MODE=COMPARE
483 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200484 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200485
486 - name: Build & Test Release x86
487 if: (runner.os == 'Windows' && matrix.compiler != 'gcc') || runner.os == 'Linux'
488 run: |
489 cmake -E remove_directory build
490 cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DDOCTEST_TEST_MODE=COMPARE
491 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200492 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200493
494 - name: Build & Test Debug x86 Valgrind
495 if: runner.os == 'Linux'
496 run: |
497 cmake -E remove_directory build
498 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-m32" -DDOCTEST_TEST_MODE=VALGRIND
499 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200500 cd build && ctest
Daan De Meyerf9726022019-10-10 22:16:49 +0200501
502 - name: Build & Test Release x86 Valgrind
503 if: runner.os == 'Linux'
504 run: |
505 cmake -E remove_directory build
506 cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-m32" -DDOCTEST_TEST_MODE=VALGRIND
507 cmake --build build
Daan De Meyerd1de6182019-10-12 17:57:53 +0200508 cd build && ctest