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