blob: c49922167b13dbb2a41f2cf71f20c2363702ee0f [file] [log] [blame]
pantord4c7aa52020-03-21 15:28:39 +01001# Based on: https://github.com/onqtam/doctest/blob/master/.github/workflows/main.yml
2
pantor095defc2020-03-21 15:14:22 +01003name: CI
pantor3705e3e2019-09-08 15:50:38 +02004
pantord0102062020-06-15 20:44:36 +02005on: [push, pull_request]
pantor3705e3e2019-09-08 15:50:38 +02006
7jobs:
pantor095defc2020-03-21 15:14:22 +01008 ci:
9 name: ${{ matrix.name }}
pantor23b5edd2020-03-18 09:03:28 +010010 runs-on: ${{ matrix.os }}
pantor095defc2020-03-21 15:14:22 +010011
12 env:
13 CMAKE_GENERATOR: Ninja
14
pantor23b5edd2020-03-18 09:03:28 +010015 strategy:
pantor095defc2020-03-21 15:14:22 +010016 fail-fast: false
pantor23b5edd2020-03-18 09:03:28 +010017 matrix:
pantor095defc2020-03-21 15:14:22 +010018 name: [
pantor095defc2020-03-21 15:14:22 +010019 ubuntu-18.04-gcc-7,
20 ubuntu-18.04-gcc-8,
21 ubuntu-18.04-gcc-9,
pantorb14f8a12021-05-19 20:16:00 +020022 ubuntu-20.04-gcc-10,
23 ubuntu-20.04-gcc-11,
pantor095defc2020-03-21 15:14:22 +010024 ubuntu-18.04-clang-5.0,
25 ubuntu-18.04-clang-6.0,
26 ubuntu-18.04-clang-7,
27 ubuntu-18.04-clang-8,
pantor81172f72020-11-25 11:46:13 +010028 ubuntu-20.04-clang-9,
pantor06ff2712021-05-19 20:09:40 +020029 ubuntu-20.04-clang-10,
30 ubuntu-20.04-clang-11,
31 ubuntu-20.04-clang-11-no-exceptions,
pantor095defc2020-03-21 15:14:22 +010032 windows-2019-cl,
33 windows-2019-clang-cl,
34 windows-2019-clang,
35 windows-2019-gcc,
pantord4c7aa52020-03-21 15:28:39 +010036 macOS-10.15-gcc-7,
37 macOS-10.15-gcc-8,
38 macOS-10.15-gcc-9,
pantorbbb1f3a2020-03-21 15:21:42 +010039 macOS-latest-xcode-11.3,
pantor719f0ae2020-11-25 11:52:58 +010040 macOS-latest-xcode-12.2,
pantor92afd502020-03-18 09:57:45 +010041 ]
pantor3705e3e2019-09-08 15:50:38 +020042
pantor095defc2020-03-21 15:14:22 +010043 include:
pantor095defc2020-03-21 15:14:22 +010044 - name: ubuntu-18.04-gcc-7
45 os: ubuntu-18.04
46 compiler: gcc
47 version: "7"
48
49 - name: ubuntu-18.04-gcc-8
50 os: ubuntu-18.04
51 compiler: gcc
52 version: "8"
53
54 - name: ubuntu-18.04-gcc-9
55 os: ubuntu-18.04
56 compiler: gcc
57 version: "9"
58
pantorb14f8a12021-05-19 20:16:00 +020059 - name: ubuntu-20.04-gcc-10
60 os: ubuntu-20.04
61 compiler: gcc
62 version: "10"
63
64 - name: ubuntu-20.04-gcc-11
65 os: ubuntu-20.04
66 compiler: gcc
67 version: "11"
68
pantor095defc2020-03-21 15:14:22 +010069 - name: ubuntu-18.04-clang-5.0
70 os: ubuntu-18.04
71 compiler: clang
72 version: "5.0"
73
74 - name: ubuntu-18.04-clang-6.0
75 os: ubuntu-18.04
76 compiler: clang
77 version: "6.0"
78
79 - name: ubuntu-18.04-clang-7
80 os: ubuntu-18.04
81 compiler: clang
82 version: "7"
83
84 - name: ubuntu-18.04-clang-8
85 os: ubuntu-18.04
86 compiler: clang
87 version: "8"
88
pantor81172f72020-11-25 11:46:13 +010089 - name: ubuntu-20.04-clang-9
90 os: ubuntu-20.04
pantor095defc2020-03-21 15:14:22 +010091 compiler: clang
92 version: "9"
93
pantor06ff2712021-05-19 20:09:40 +020094 - name: ubuntu-20.04-clang-10
95 os: ubuntu-20.04
96 compiler: clang
97 version: "10"
98
99 - name: ubuntu-20.04-clang-11
100 os: ubuntu-20.04
101 compiler: clang
102 version: "11"
103
104 - name: ubuntu-20.04-clang-11-no-exceptions
105 os: ubuntu-20.04
106 compiler: clang
107 version: "11"
108 cmake_vars: "-DCMAKE_CXX_FLAGS=-fno-exceptions -DBUILD_TESTING=OFF -DBUILD_BENCHMARK=ON"
109
pantor095defc2020-03-21 15:14:22 +0100110 - name: windows-2019-cl
111 os: windows-2019
112 compiler: cl
113
pantor095defc2020-03-21 15:14:22 +0100114 - name: windows-2019-clang-cl
115 os: windows-2019
116 compiler: clang-cl
117
118 - name: windows-2019-clang
119 os: windows-2019
120 compiler: clang
121
122 - name: windows-2019-gcc
123 os: windows-2019
124 compiler: gcc
125
pantord4c7aa52020-03-21 15:28:39 +0100126 - name: macOS-10.15-gcc-7
127 os: macOS-10.15
pantor095defc2020-03-21 15:14:22 +0100128 compiler: gcc
129 version: "7"
130
pantord4c7aa52020-03-21 15:28:39 +0100131 - name: macOS-10.15-gcc-8
132 os: macOS-10.15
pantor095defc2020-03-21 15:14:22 +0100133 compiler: gcc
134 version: "8"
135
pantord4c7aa52020-03-21 15:28:39 +0100136 - name: macOS-10.15-gcc-9
137 os: macOS-10.15
pantor095defc2020-03-21 15:14:22 +0100138 compiler: gcc
139 version: "9"
140
pantorbbb1f3a2020-03-21 15:21:42 +0100141 - name: macOS-latest-xcode-11.3
142 os: macOS-latest
143 compiler: xcode
144 version: "11.3"
145
pantor719f0ae2020-11-25 11:52:58 +0100146 - name: macOS-latest-xcode-12.2
147 os: macOS-latest
148 compiler: xcode
149 version: "12.2"
150
pantor3705e3e2019-09-08 15:50:38 +0200151 steps:
pantor06ff2712021-05-19 20:09:40 +0200152 - uses: actions/checkout@v2
pantor3705e3e2019-09-08 15:50:38 +0200153
pantor095defc2020-03-21 15:14:22 +0100154 - name: Install (Linux)
155 if: runner.os == 'Linux'
156 run: |
pantor095defc2020-03-21 15:14:22 +0100157 # Required for libc6-dbg:i386 and g++-multilib packages which are
158 # needed for x86 builds.
159 sudo dpkg --add-architecture i386
160 # clang-3.7 and earlier are not available in Bionic anymore so we get
161 # them from the Xenial repositories instead.
162 sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main"
163 sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe"
164
pantor095defc2020-03-21 15:14:22 +0100165 sudo apt-get update
166 # libc6-dbg:i386 is required for running valgrind on x86.
Jesse Mapele09faa62021-02-02 09:12:54 -0700167 sudo apt-get install -y ninja-build valgrind libc6-dbg:i386 -o APT::Immediate-Configure=0
pantor095defc2020-03-21 15:14:22 +0100168 if [ "${{ matrix.compiler }}" = "gcc" ]; then
169 sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
pantor0fbde442020-11-25 11:32:54 +0100170 echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
171 echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100172 else
173 sudo apt-get install -y clang-${{ matrix.version }} g++-multilib
pantor0fbde442020-11-25 11:32:54 +0100174 echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
175 echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100176 fi
177
178 - name: Install (macOS)
179 if: runner.os == 'macOS'
180 run: |
pantor719f0ae2020-11-25 11:52:58 +0100181 brew install ninja
pantor095defc2020-03-21 15:14:22 +0100182 if [ "${{ matrix.compiler }}" = "gcc" ]; then
183 brew install gcc@${{ matrix.version }}
pantor06bd9af2020-11-25 12:01:03 +0100184 brew link gcc@${{ matrix.version }}
pantor0fbde442020-11-25 11:32:54 +0100185 echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
186 echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100187 else
188 sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
pantor0fbde442020-11-25 11:32:54 +0100189 echo "CC=clang" >> $GITHUB_ENV
190 echo "CXX=clang++" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100191 fi
192
193 - name: Install (Windows)
194 if: runner.os == 'Windows'
195 shell: powershell
196 run: |
197 Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
198 scoop install ninja --global
199 if ("${{ matrix.compiler }}".StartsWith("clang")) {
200 scoop install llvm --global
201 }
202 if ("${{ matrix.compiler }}" -eq "gcc") {
203 # Chocolatey GCC is broken on the windows-2019 image.
204 # See: https://github.com/DaanDeMeyer/doctest/runs/231595515
205 # See: https://github.community/t5/GitHub-Actions/Something-is-wrong-with-the-chocolatey-installed-version-of-gcc/td-p/32413
pantor15b0b7f2021-01-16 18:23:20 +0100206 # scoop install gcc --global
207 choco install mingw
pantor0fbde442020-11-25 11:32:54 +0100208 echo "CC=gcc" >> $GITHUB_ENV
209 echo "CXX=g++" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100210 } elseif ("${{ matrix.compiler }}" -eq "clang") {
pantor0fbde442020-11-25 11:32:54 +0100211 echo "CC=clang" >> $GITHUB_ENV
212 echo "CXX=clang++" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100213 } else {
pantor0fbde442020-11-25 11:32:54 +0100214 echo "CC=${{ matrix.compiler }}" >> $GITHUB_ENV
215 echo "CXX=${{ matrix.compiler }}" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100216 }
217 # Scoop modifies the PATH so we make the modified PATH global.
pantor0fbde442020-11-25 11:32:54 +0100218 echo "PATH=$env:PATH" >> $GITHUB_ENV
pantor095defc2020-03-21 15:14:22 +0100219
220 - name: Configure
221 if: runner.os == 'Windows'
222 run: .github\workflows\vsenv.bat -arch=x64 -host_arch=x64
pantor3705e3e2019-09-08 15:50:38 +0200223
pantor095defc2020-03-21 15:14:22 +0100224 - name: Build & Test Debug
225 run: |
226 cmake -E remove_directory build
227 cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug
228 cmake --build build -j2
229 cd build && ctest -j2 --output-on-failure
230
231 - name: Build & Test Release
232 run: |
233 cmake -E remove_directory build
pantor06ff2712021-05-19 20:09:40 +0200234 cmake -B build -S . -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_vars }}
pantor095defc2020-03-21 15:14:22 +0100235 cmake --build build -j2
236 cd build && ctest -j2 --output-on-failure