pantor | d4c7aa5 | 2020-03-21 15:28:39 +0100 | [diff] [blame] | 1 | # Based on: https://github.com/onqtam/doctest/blob/master/.github/workflows/main.yml |
| 2 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 3 | name: CI |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 4 | |
pantor | d010206 | 2020-06-15 20:44:36 +0200 | [diff] [blame] | 5 | on: [push, pull_request] |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 6 | |
| 7 | jobs: |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 8 | ci: |
| 9 | name: ${{ matrix.name }} |
pantor | 23b5edd | 2020-03-18 09:03:28 +0100 | [diff] [blame] | 10 | runs-on: ${{ matrix.os }} |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 11 | |
| 12 | env: |
| 13 | CMAKE_GENERATOR: Ninja |
| 14 | |
pantor | 23b5edd | 2020-03-18 09:03:28 +0100 | [diff] [blame] | 15 | strategy: |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 16 | fail-fast: false |
pantor | 23b5edd | 2020-03-18 09:03:28 +0100 | [diff] [blame] | 17 | matrix: |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 18 | name: [ |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 19 | ubuntu-18.04-gcc-7, |
| 20 | ubuntu-18.04-gcc-8, |
| 21 | ubuntu-18.04-gcc-9, |
pantor | b14f8a1 | 2021-05-19 20:16:00 +0200 | [diff] [blame] | 22 | ubuntu-20.04-gcc-10, |
| 23 | ubuntu-20.04-gcc-11, |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 24 | 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, |
pantor | 81172f7 | 2020-11-25 11:46:13 +0100 | [diff] [blame] | 28 | ubuntu-20.04-clang-9, |
pantor | 06ff271 | 2021-05-19 20:09:40 +0200 | [diff] [blame] | 29 | ubuntu-20.04-clang-10, |
| 30 | ubuntu-20.04-clang-11, |
| 31 | ubuntu-20.04-clang-11-no-exceptions, |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 32 | windows-2019-cl, |
| 33 | windows-2019-clang-cl, |
| 34 | windows-2019-clang, |
| 35 | windows-2019-gcc, |
pantor | d4c7aa5 | 2020-03-21 15:28:39 +0100 | [diff] [blame] | 36 | macOS-10.15-gcc-7, |
| 37 | macOS-10.15-gcc-8, |
| 38 | macOS-10.15-gcc-9, |
pantor | bbb1f3a | 2020-03-21 15:21:42 +0100 | [diff] [blame] | 39 | macOS-latest-xcode-11.3, |
pantor | 719f0ae | 2020-11-25 11:52:58 +0100 | [diff] [blame] | 40 | macOS-latest-xcode-12.2, |
pantor | 92afd50 | 2020-03-18 09:57:45 +0100 | [diff] [blame] | 41 | ] |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 42 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 43 | include: |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 44 | - 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 | |
pantor | b14f8a1 | 2021-05-19 20:16:00 +0200 | [diff] [blame] | 59 | - 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 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 69 | - 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 | |
pantor | 81172f7 | 2020-11-25 11:46:13 +0100 | [diff] [blame] | 89 | - name: ubuntu-20.04-clang-9 |
| 90 | os: ubuntu-20.04 |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 91 | compiler: clang |
| 92 | version: "9" |
| 93 | |
pantor | 06ff271 | 2021-05-19 20:09:40 +0200 | [diff] [blame] | 94 | - 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 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 110 | - name: windows-2019-cl |
| 111 | os: windows-2019 |
| 112 | compiler: cl |
| 113 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 114 | - 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 | |
pantor | d4c7aa5 | 2020-03-21 15:28:39 +0100 | [diff] [blame] | 126 | - name: macOS-10.15-gcc-7 |
| 127 | os: macOS-10.15 |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 128 | compiler: gcc |
| 129 | version: "7" |
| 130 | |
pantor | d4c7aa5 | 2020-03-21 15:28:39 +0100 | [diff] [blame] | 131 | - name: macOS-10.15-gcc-8 |
| 132 | os: macOS-10.15 |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 133 | compiler: gcc |
| 134 | version: "8" |
| 135 | |
pantor | d4c7aa5 | 2020-03-21 15:28:39 +0100 | [diff] [blame] | 136 | - name: macOS-10.15-gcc-9 |
| 137 | os: macOS-10.15 |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 138 | compiler: gcc |
| 139 | version: "9" |
| 140 | |
pantor | bbb1f3a | 2020-03-21 15:21:42 +0100 | [diff] [blame] | 141 | - name: macOS-latest-xcode-11.3 |
| 142 | os: macOS-latest |
| 143 | compiler: xcode |
| 144 | version: "11.3" |
| 145 | |
pantor | 719f0ae | 2020-11-25 11:52:58 +0100 | [diff] [blame] | 146 | - name: macOS-latest-xcode-12.2 |
| 147 | os: macOS-latest |
| 148 | compiler: xcode |
| 149 | version: "12.2" |
| 150 | |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 151 | steps: |
pantor | 06ff271 | 2021-05-19 20:09:40 +0200 | [diff] [blame] | 152 | - uses: actions/checkout@v2 |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 153 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 154 | - name: Install (Linux) |
| 155 | if: runner.os == 'Linux' |
| 156 | run: | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 157 | # 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 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 165 | sudo apt-get update |
| 166 | # libc6-dbg:i386 is required for running valgrind on x86. |
Jesse Mapel | e09faa6 | 2021-02-02 09:12:54 -0700 | [diff] [blame] | 167 | sudo apt-get install -y ninja-build valgrind libc6-dbg:i386 -o APT::Immediate-Configure=0 |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 168 | if [ "${{ matrix.compiler }}" = "gcc" ]; then |
| 169 | sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 170 | echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV |
| 171 | echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 172 | else |
| 173 | sudo apt-get install -y clang-${{ matrix.version }} g++-multilib |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 174 | echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV |
| 175 | echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 176 | fi |
| 177 | |
| 178 | - name: Install (macOS) |
| 179 | if: runner.os == 'macOS' |
| 180 | run: | |
pantor | 719f0ae | 2020-11-25 11:52:58 +0100 | [diff] [blame] | 181 | brew install ninja |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 182 | if [ "${{ matrix.compiler }}" = "gcc" ]; then |
| 183 | brew install gcc@${{ matrix.version }} |
pantor | 06bd9af | 2020-11-25 12:01:03 +0100 | [diff] [blame] | 184 | brew link gcc@${{ matrix.version }} |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 185 | echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV |
| 186 | echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 187 | else |
| 188 | sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 189 | echo "CC=clang" >> $GITHUB_ENV |
| 190 | echo "CXX=clang++" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 191 | 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 |
pantor | 15b0b7f | 2021-01-16 18:23:20 +0100 | [diff] [blame] | 206 | # scoop install gcc --global |
| 207 | choco install mingw |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 208 | echo "CC=gcc" >> $GITHUB_ENV |
| 209 | echo "CXX=g++" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 210 | } elseif ("${{ matrix.compiler }}" -eq "clang") { |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 211 | echo "CC=clang" >> $GITHUB_ENV |
| 212 | echo "CXX=clang++" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 213 | } else { |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 214 | echo "CC=${{ matrix.compiler }}" >> $GITHUB_ENV |
| 215 | echo "CXX=${{ matrix.compiler }}" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 216 | } |
| 217 | # Scoop modifies the PATH so we make the modified PATH global. |
pantor | 0fbde44 | 2020-11-25 11:32:54 +0100 | [diff] [blame] | 218 | echo "PATH=$env:PATH" >> $GITHUB_ENV |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 219 | |
| 220 | - name: Configure |
| 221 | if: runner.os == 'Windows' |
| 222 | run: .github\workflows\vsenv.bat -arch=x64 -host_arch=x64 |
pantor | 3705e3e | 2019-09-08 15:50:38 +0200 | [diff] [blame] | 223 | |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 224 | - 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 |
pantor | 06ff271 | 2021-05-19 20:09:40 +0200 | [diff] [blame] | 234 | cmake -B build -S . -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_vars }} |
pantor | 095defc | 2020-03-21 15:14:22 +0100 | [diff] [blame] | 235 | cmake --build build -j2 |
| 236 | cd build && ctest -j2 --output-on-failure |