|
| 1 | +name: CMake |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: ${{ matrix.preset }}-${{ matrix.config }}-${{ matrix.sanitize }} |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + preset: [linux-clang, linux-gcc, macos, windows] |
| 12 | + config: [Debug, Release] |
| 13 | + sanitize: [address, thread, undefined, leak, memory] |
| 14 | + exclude: |
| 15 | + - { preset: linux-gcc, sanitize: memory } |
| 16 | + - { preset: macos, sanitize: leak } |
| 17 | + - { preset: macos, sanitize: memory } |
| 18 | + - { preset: windows, sanitize: thread } |
| 19 | + - { preset: windows, sanitize: undefined } |
| 20 | + - { preset: windows, sanitize: leak } |
| 21 | + - { preset: windows, sanitize: memory } |
| 22 | + include: |
| 23 | + - preset: linux-clang |
| 24 | + os: ubuntu-latest |
| 25 | + generator: '"Ninja Multi-Config"' |
| 26 | + cc: clang |
| 27 | + cxx: clang++ |
| 28 | + - preset: linux-gcc |
| 29 | + os: ubuntu-latest |
| 30 | + generator: '"Ninja Multi-Config"' |
| 31 | + cc: gcc |
| 32 | + cxx: g++ |
| 33 | + - preset: macos |
| 34 | + os: macos-latest |
| 35 | + generator: Xcode |
| 36 | + - preset: windows |
| 37 | + os: windows-latest |
| 38 | + generator: '"Visual Studio 17 2022"' |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + steps: |
| 41 | + - name: Prepare git before checkout |
| 42 | + run: git config --global core.autocrlf input |
| 43 | + |
| 44 | + - name: Checkout |
| 45 | + uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install dependencies on Linux |
| 48 | + if: runner.os == 'Linux' |
| 49 | + run: | |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get install -y ninja-build |
| 52 | +
|
| 53 | + - name: Set CMake caches |
| 54 | + run: | |
| 55 | + echo 'set(CMAKE_INSTALL_PREFIX install CACHE STRING "")' >> cache.cmake |
| 56 | + echo 'set(HTTPLIB_COMPILE ON CACHE STRING "")' >> cache.cmake |
| 57 | + echo 'set(HTTPLIB_TEST ON CACHE STRING "")' >> cache.cmake |
| 58 | +
|
| 59 | + - name: Set CMake caches for Linux |
| 60 | + if: runner.os == 'Linux' |
| 61 | + run: | |
| 62 | + echo 'set(CMAKE_C_COMPILER "${{ matrix.cc }}" CACHE STRING "")' >> cache.cmake |
| 63 | + echo 'set(CMAKE_CXX_COMPILER "${{ matrix.cxx }}" CACHE STRING "")' >> cache.cmake |
| 64 | +
|
| 65 | + - name: Print CMake caches |
| 66 | + run: cat cache.cmake |
| 67 | + |
| 68 | + - name: Configure |
| 69 | + run: cmake -B build -G ${{ matrix.generator }} -C cache.cmake |
| 70 | + |
| 71 | + - name: Build |
| 72 | + run: cmake --build build --config ${{ matrix.config }} |
| 73 | + |
| 74 | + - name: Test |
| 75 | + id: test |
| 76 | + working-directory: build |
| 77 | + continue-on-error: true |
| 78 | + run: ctest -C ${{ matrix.config }} --timeout 100 --schedule-random --output-on-failure |
| 79 | + |
| 80 | + - name: Rerun failed tests |
| 81 | + if: steps.test.outcome == 'failure' |
| 82 | + working-directory: build |
| 83 | + run: ctest -C ${{ matrix.config }} --timeout 100 --rerun-failed --output-on-failure |
| 84 | + |
| 85 | + - name: Install |
| 86 | + run: cmake --install build --config ${{ matrix.config }} |
| 87 | + |
| 88 | + build-mobile: |
| 89 | + name: ${{ matrix.preset }}-${{ matrix.config }} |
| 90 | + strategy: |
| 91 | + fail-fast: false |
| 92 | + matrix: |
| 93 | + preset: [android, ios] |
| 94 | + config: [Debug, Release] |
| 95 | + include: |
| 96 | + - preset: android |
| 97 | + os: ubuntu-latest |
| 98 | + generator: '"Ninja Multi-Config"' |
| 99 | + - preset: ios |
| 100 | + os: macos-latest |
| 101 | + generator: Xcode |
| 102 | + runs-on: ${{ matrix.os }} |
| 103 | + steps: |
| 104 | + - name: Checkout |
| 105 | + uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: Install dependencies on Linux |
| 108 | + if: runner.os == 'Linux' |
| 109 | + run: | |
| 110 | + sudo apt-get update |
| 111 | + sudo apt-get install -y ninja-build |
| 112 | +
|
| 113 | + - name: Set CMake caches |
| 114 | + run: | |
| 115 | + echo 'set(CMAKE_INSTALL_PREFIX install CACHE STRING "")' >> cache.cmake |
| 116 | + echo 'set(HTTPLIB_COMPILE ON CACHE STRING "")' >> cache.cmake |
| 117 | +
|
| 118 | + - name: Set CMake caches for Android |
| 119 | + if: matrix.preset == 'android' |
| 120 | + run: | |
| 121 | + echo 'set(CMAKE_TOOLCHAIN_FILE $ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake CACHE STRING "")' >> cache.cmake |
| 122 | +
|
| 123 | + - name: Set CMake caches for iOS |
| 124 | + if: matrix.preset == 'ios' |
| 125 | + run: | |
| 126 | + echo 'set(CMAKE_SYSTEM_NAME iOS)' >> ios.toolchain.cmake |
| 127 | + echo 'set(CMAKE_SYSTEM_PROCESSOR aarch64)' >> ios.toolchain.cmake |
| 128 | + echo 'set(CMAKE_OSX_ARCHITECTURES arm64)' >> ios.toolchain.cmake |
| 129 | + echo 'set(CMAKE_OSX_SYSROOT iphoneos)' >> ios.toolchain.cmake |
| 130 | + echo 'set(CMAKE_TOOLCHAIN_FILE ios.toolchain.cmake CACHE STRING "")' >> cache.cmake |
| 131 | +
|
| 132 | + - name: Print CMake caches |
| 133 | + run: cat cache.cmake |
| 134 | + |
| 135 | + - name: Configure |
| 136 | + run: cmake -B build -G ${{ matrix.generator }} -C cache.cmake |
| 137 | + |
| 138 | + - name: Build |
| 139 | + run: cmake --build build --config ${{ matrix.config }} |
| 140 | + |
| 141 | + - name: Install |
| 142 | + run: cmake --install build --config ${{ matrix.config }} |
| 143 | + |
| 144 | + build-bsd: |
| 145 | + name: ${{ matrix.preset }}-${{ matrix.arch }}-${{ matrix.config }} |
| 146 | + strategy: |
| 147 | + fail-fast: false |
| 148 | + matrix: |
| 149 | + preset: [freebsd, netbsd, openbsd] |
| 150 | + arch: [arm64, x86_64] |
| 151 | + config: [Debug, Release] |
| 152 | + exclude: |
| 153 | + - { preset: netbsd, arch: arm64 } |
| 154 | + include: |
| 155 | + - preset: freebsd |
| 156 | + version: "13.2" |
| 157 | + install: sudo pkg install -y |
| 158 | + pkg: cmake ninja python3 |
| 159 | + - preset: netbsd |
| 160 | + version: "9.3" |
| 161 | + install: sudo pkgin update && sudo pkgin -y install |
| 162 | + pkg: cmake ninja-build python310 |
| 163 | + - preset: openbsd |
| 164 | + version: "7.4" |
| 165 | + install: sudo pkg_add -U |
| 166 | + pkg: cmake ninja python3 |
| 167 | + runs-on: ubuntu-latest |
| 168 | + steps: |
| 169 | + - name: Checkout |
| 170 | + uses: actions/checkout@v4 |
| 171 | + |
| 172 | + - name: Run BSD workflows |
| 173 | + uses: cross-platform-actions/action@master |
| 174 | + with: |
| 175 | + operating_system: ${{ matrix.preset }} |
| 176 | + architecture: ${{ matrix.arch }} |
| 177 | + version: ${{ matrix.version }} |
| 178 | + shell: bash |
| 179 | + run: | |
| 180 | + ${{ matrix.install }} ${{ matrix.pkg }} |
| 181 | + cmake -B build -G "Ninja Multi-Config" \ |
| 182 | + -DCMAKE_INSTALL_PREFIX=install \ |
| 183 | + -DHTTPLIB_COMPILE=ON \ |
| 184 | + -DHTTPLIB_TEST=ON |
| 185 | + cmake --build build --config ${{ matrix.config }} |
| 186 | + cd build |
| 187 | + EXIT_CODE=0 |
| 188 | + ctest -C ${{ matrix.config }} --timeout 100 --schedule-random --output-on-failure || EXIT_CODE=$? |
| 189 | + if [ $EXIT_CODE -ne 0 ]; then ctest -C ${{ matrix.config }} --timeout 100 --rerun-failed --output-on-failure; fi |
| 190 | + cd .. |
| 191 | + cmake --install build --config ${{ matrix.config }} |
| 192 | +
|
| 193 | + build-msys2: |
| 194 | + name: msys2-${{ matrix.preset }}-${{ matrix.config }} |
| 195 | + strategy: |
| 196 | + fail-fast: false |
| 197 | + matrix: |
| 198 | + preset: [CLANG32, CLANG64, MINGW32, MINGW64, UCRT64] |
| 199 | + config: [Debug, Release] |
| 200 | + runs-on: windows-latest |
| 201 | + defaults: |
| 202 | + run: |
| 203 | + shell: msys2 {0} |
| 204 | + steps: |
| 205 | + - name: Prepare git before checkout |
| 206 | + shell: powershell |
| 207 | + run: git config --global core.autocrlf input |
| 208 | + |
| 209 | + - name: Checkout |
| 210 | + uses: actions/checkout@v4 |
| 211 | + |
| 212 | + - uses: msys2/setup-msys2@v2 |
| 213 | + with: |
| 214 | + msystem: ${{ matrix.preset }} |
| 215 | + update: true |
| 216 | + pacboy: cmake:p gcc:p ninja:p |
| 217 | + |
| 218 | + - name: Configure |
| 219 | + run: > |
| 220 | + cmake -B build -G "Ninja Multi-Config" |
| 221 | + -DCMAKE_INSTALL_PREFIX=install |
| 222 | + -DHTTPLIB_COMPILE=ON |
| 223 | + -DHTTPLIB_TEST=ON |
| 224 | +
|
| 225 | + - name: Build |
| 226 | + run: cmake --build build --config ${{ matrix.config }} |
| 227 | + |
| 228 | + - name: Test |
| 229 | + id: test |
| 230 | + working-directory: build |
| 231 | + continue-on-error: true |
| 232 | + run: ctest -C ${{ matrix.config }} --timeout 100 --schedule-random --output-on-failure |
| 233 | + |
| 234 | + - name: Rerun failed tests |
| 235 | + if: steps.test.outcome == 'failure' |
| 236 | + working-directory: build |
| 237 | + run: ctest -C ${{ matrix.config }} --timeout 100 --rerun-failed --output-on-failure |
| 238 | + |
| 239 | + - name: Install |
| 240 | + run: cmake --install build --config ${{ matrix.config }} |
| 241 | + |
| 242 | + build-cygwin: |
| 243 | + name: cygwin-${{ matrix.config }} |
| 244 | + strategy: |
| 245 | + fail-fast: false |
| 246 | + matrix: |
| 247 | + config: [Debug, Release] |
| 248 | + runs-on: windows-latest |
| 249 | + defaults: |
| 250 | + run: |
| 251 | + shell: C:\cygwin\bin\bash.exe --noprofile --norc -o igncr -eo pipefail '{0}' |
| 252 | + steps: |
| 253 | + - name: Prepare git before checkout |
| 254 | + shell: powershell |
| 255 | + run: git config --global core.autocrlf input |
| 256 | + |
| 257 | + - name: Checkout |
| 258 | + uses: actions/checkout@v4 |
| 259 | + |
| 260 | + - name: Install dependencies |
| 261 | + uses: cygwin/cygwin-install-action@v4 |
| 262 | + with: |
| 263 | + packages: cmake gcc-g++ ninja python3 libbrotli-devel libssl-devel zlib-devel |
| 264 | + |
| 265 | + - name: Configure |
| 266 | + run: > |
| 267 | + cmake -B build -G "Ninja Multi-Config" |
| 268 | + -DCMAKE_INSTALL_PREFIX=install |
| 269 | + -DHTTPLIB_COMPILE=ON |
| 270 | + -DHTTPLIB_TEST=ON |
| 271 | +
|
| 272 | + - name: Build |
| 273 | + run: cmake --build build --config ${{ matrix.config }} |
| 274 | + |
| 275 | + - name: Test |
| 276 | + id: test |
| 277 | + working-directory: build |
| 278 | + continue-on-error: true |
| 279 | + run: ctest -C ${{ matrix.config }} --timeout 100 --schedule-random --output-on-failure |
| 280 | + |
| 281 | + - name: Rerun failed tests |
| 282 | + if: steps.test.outcome == 'failure' |
| 283 | + working-directory: build |
| 284 | + run: ctest -C ${{ matrix.config }} --timeout 100 --rerun-failed --output-on-failure |
| 285 | + |
| 286 | + - name: Install |
| 287 | + run: cmake --install build --config ${{ matrix.config }} |
0 commit comments