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