|
| 1 | +name: Linux+MacOS Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + release: |
| 9 | + types: |
| 10 | + - published |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + formatting: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: ghcr.io/motis-project/docker-cpp-build |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Format files |
| 24 | + run: | |
| 25 | + find base libs modules test \ |
| 26 | + -type f -a \( -name "*.cc" -o -name "*.h" -o -name ".cuh" -o -name ".cu" \) \ |
| 27 | + -print0 | xargs -0 clang-format-16 -i |
| 28 | +
|
| 29 | + - name: Check for differences |
| 30 | + run: | |
| 31 | + git config --global --add safe.directory `pwd` |
| 32 | + git status --porcelain |
| 33 | + git status --porcelain | xargs -I {} -0 test -z \"{}\" |
| 34 | +
|
| 35 | + msvc: |
| 36 | + runs-on: windows-latest |
| 37 | + |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + config: |
| 42 | + - mode: Debug |
| 43 | + - mode: Release |
| 44 | + |
| 45 | + env: |
| 46 | + CXX: cl.exe |
| 47 | + CC: cl.exe |
| 48 | + BUILDCACHE_COMPRESS: true |
| 49 | + BUILDCACHE_DIRECT_MODE: true |
| 50 | + BUILDCACHE_ACCURACY: SLOPPY # not suitable for coverage/debugging |
| 51 | + BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache |
| 52 | + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools |
| 53 | + CLICOLOR_FORCE: 1 |
| 54 | + |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - name: Install ninja |
| 59 | + run: choco install ninja |
| 60 | + |
| 61 | + - name: Restore buildcache Cache |
| 62 | + uses: actions/cache/restore@v4 |
| 63 | + id: restore-buildcache |
| 64 | + with: |
| 65 | + path: ${{ github.workspace }}/.buildcache |
| 66 | + key: buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }} |
| 67 | + restore-keys: | |
| 68 | + buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }} |
| 69 | + buildcache-wnds-${{ matrix.config.mode }}-${{ hashFiles('.pkg') }}- |
| 70 | + buildcache-wnds-${{ matrix.config.mode }}- |
| 71 | +
|
| 72 | + - name: Dependencies Cache |
| 73 | + uses: actions/cache@v4 |
| 74 | + with: |
| 75 | + path: ${{ github.workspace }}/deps |
| 76 | + key: deps-${{ hashFiles('.pkg') }} |
| 77 | + restore-keys: deps- |
| 78 | + |
| 79 | + - uses: ilammy/msvc-dev-cmd@v1 |
| 80 | + |
| 81 | + - name: Build |
| 82 | + run: | |
| 83 | + cmake ` |
| 84 | + -GNinja -S . -B build ` |
| 85 | + -DCMAKE_BUILD_TYPE=${{ matrix.config.mode }} |
| 86 | + .\build\buildcache\bin\buildcache.exe -z |
| 87 | + cmake --build build --target osr-extract osr-backend osr-benchmark osr-test |
| 88 | + $CompilerExitCode = $LastExitCode |
| 89 | + .\build\buildcache\bin\buildcache.exe -s |
| 90 | + exit $CompilerExitCode |
| 91 | +
|
| 92 | + # ==== TESTS ==== |
| 93 | + - name: Run Tests |
| 94 | + run: .\build\osr-test.exe |
| 95 | + |
| 96 | + # ==== SAVE CACHE ==== |
| 97 | + - name: Save buildcache Cache |
| 98 | + if: always() |
| 99 | + uses: actions/cache/save@v4 |
| 100 | + with: |
| 101 | + path: ${{ github.workspace }}/.buildcache |
| 102 | + key: ${{ steps.restore-buildcache.outputs.cache-primary-key }} |
| 103 | + |
| 104 | + # ==== DISTRIBUTION ==== |
| 105 | + - name: Create Distribution |
| 106 | + if: matrix.config.mode == 'Release' |
| 107 | + run: | |
| 108 | + mkdir dist |
| 109 | + mv web dist |
| 110 | + mv .\build\osr-extract.exe dist |
| 111 | + mv .\build\osr-backend.exe dist |
| 112 | + cd dist |
| 113 | + 7z a osr-windows.zip * |
| 114 | + mv osr-windows.zip .. |
| 115 | +
|
| 116 | + - name: Upload Distribution |
| 117 | + if: matrix.config.mode == 'Release' |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: osr-windows |
| 121 | + path: dist |
| 122 | + |
| 123 | + # ==== RELEASE ==== |
| 124 | + - name: Upload Release |
| 125 | + if: github.event.action == 'published' && matrix.config.mode == 'Release' |
| 126 | + uses: actions/upload-release-asset@v1.0.2 |
| 127 | + env: |
| 128 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + with: |
| 130 | + upload_url: ${{ github.event.release.upload_url }} |
| 131 | + asset_path: ./osr-windows.zip |
| 132 | + asset_name: osr-windows.zip |
| 133 | + asset_content_type: application/zip |
| 134 | + |
| 135 | + macos: |
| 136 | + runs-on: ${{ matrix.config.os }} |
| 137 | + strategy: |
| 138 | + fail-fast: false |
| 139 | + matrix: |
| 140 | + config: |
| 141 | + - preset: macos-x86_64 |
| 142 | + os: macos-13 |
| 143 | + - preset: macos-arm64 |
| 144 | + os: macos-14 |
| 145 | + env: |
| 146 | + BUILDCACHE_COMPRESS: true |
| 147 | + BUILDCACHE_DIRECT_MODE: true |
| 148 | + BUILDCACHE_ACCURACY: SLOPPY |
| 149 | + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools |
| 150 | + BUILDCACHE_DIR: ${{ github.workspace }}/.buildcache |
| 151 | + BUILDCACHE_MAX_CACHE_SIZE: 1073741824 |
| 152 | + BUILDCACHE_DEBUG: 0 |
| 153 | + UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1 |
| 154 | + ASAN_OPTIONS: alloc_dealloc_mismatch=0 |
| 155 | + CLICOLOR_FORCE: 1 |
| 156 | + steps: |
| 157 | + - uses: actions/checkout@v4 |
| 158 | + |
| 159 | + # ==== RESTORE CACHE ==== |
| 160 | + - name: Restore buildcache Cache |
| 161 | + uses: actions/cache/restore@v4 |
| 162 | + id: restore-buildcache |
| 163 | + with: |
| 164 | + path: ${{ github.workspace }}/.buildcache |
| 165 | + key: buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}-${{ hashFiles('**/*.cc') }} |
| 166 | + restore-keys: | |
| 167 | + buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}-${{ hashFiles('**/*.h') }}- |
| 168 | + buildcache-${{ matrix.config.preset }}-${{ hashFiles('.pkg') }}- |
| 169 | + buildcache-${{ matrix.config.preset }}- |
| 170 | +
|
| 171 | + - name: Restore Dependencies Cache |
| 172 | + uses: actions/cache/restore@v4 |
| 173 | + id: restore-deps-cache |
| 174 | + with: |
| 175 | + path: ${{ github.workspace }}/deps |
| 176 | + enableCrossOsArchive: true |
| 177 | + key: deps-${{ hashFiles('.pkg') }} |
| 178 | + restore-keys: | |
| 179 | + deps- |
| 180 | +
|
| 181 | + - name: Install Ninja |
| 182 | + run: brew install ninja |
| 183 | + |
| 184 | + # ==== BUILD ==== |
| 185 | + - name: CMake |
| 186 | + run: | |
| 187 | + git config --global --add safe.directory `pwd` |
| 188 | + cmake -G Ninja -S . -B build --preset=${{ matrix.config.preset }} |
| 189 | +
|
| 190 | + - name: Build |
| 191 | + run: cmake --build build --target osr-extract osr-backend osr-benchmark osr-test |
| 192 | + |
| 193 | + # ==== TESTS ==== |
| 194 | + - name: Run Tests |
| 195 | + run: ./build/osr-test |
| 196 | + |
| 197 | + # ==== DISTRIBUTION ==== |
| 198 | + - name: Create Distribution |
| 199 | + run: | |
| 200 | + mkdir osr |
| 201 | + mv build/osr-extract osr/osr-extract |
| 202 | + mv build/osr-backend osr/osr-backend |
| 203 | + tar cjf osr-${{ matrix.config.preset }}.tar.bz2 osr |
| 204 | +
|
| 205 | + - name: Upload Distribution |
| 206 | + uses: actions/upload-artifact@v4 |
| 207 | + with: |
| 208 | + name: osr-${{ matrix.config.preset }} |
| 209 | + path: osr-${{ matrix.config.preset }}.tar.bz2 |
| 210 | + |
| 211 | + # ==== RELEASE ==== |
| 212 | + - name: Upload Release |
| 213 | + if: github.event.action == 'published' |
| 214 | + uses: actions/upload-release-asset@v1.0.2 |
| 215 | + env: |
| 216 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 217 | + with: |
| 218 | + upload_url: ${{ github.event.release.upload_url }} |
| 219 | + asset_path: ./osr-${{ matrix.config.preset }}.tar.bz2 |
| 220 | + asset_name: osr-${{ matrix.config.preset }}.tar.bz2 |
| 221 | + asset_content_type: application/x-tar |
| 222 | + |
| 223 | + # ==== SAVE CACHE ==== |
| 224 | + - name: Save buildcache Cache |
| 225 | + if: always() |
| 226 | + uses: actions/cache/save@v4 |
| 227 | + with: |
| 228 | + path: ${{ github.workspace }}/.buildcache |
| 229 | + key: ${{ steps.restore-buildcache.outputs.cache-primary-key }} |
| 230 | + |
| 231 | + - name: Save Dependencies Cache |
| 232 | + if: always() |
| 233 | + uses: actions/cache/save@v4 |
| 234 | + with: |
| 235 | + path: ${{ github.workspace }}/deps |
| 236 | + key: ${{ steps.restore-deps-cache.outputs.cache-primary-key }} |
| 237 | + enableCrossOsArchive: true |
| 238 | + |
| 239 | + linux: |
| 240 | + runs-on: [ self-hosted, linux, x64, "${{ matrix.config.preset }}" ] |
| 241 | + container: |
| 242 | + image: ghcr.io/motis-project/docker-cpp-build |
| 243 | + volumes: |
| 244 | + - ${{ github.event.repository.name }}-${{ matrix.config.preset }}-deps:/deps |
| 245 | + - ${{ github.event.repository.name }}-${{ matrix.config.preset }}-buildcache:/buildcache |
| 246 | + strategy: |
| 247 | + fail-fast: false |
| 248 | + matrix: |
| 249 | + config: |
| 250 | + - preset: linux-amd64-release |
| 251 | + artifact: linux-amd64 |
| 252 | + - preset: linux-arm64-release |
| 253 | + artifact: linux-arm64 |
| 254 | + emulator: qemu-aarch64-static |
| 255 | + - preset: clang-tidy |
| 256 | + - preset: linux-sanitizer |
| 257 | + - preset: linux-debug |
| 258 | + emulator: valgrind --leak-check=full --error-exitcode=1 |
| 259 | + env: |
| 260 | + BUILDCACHE_DIR: /buildcache |
| 261 | + BUILDCACHE_COMPRESS: true |
| 262 | + BUILDCACHE_ACCURACY: SLOPPY |
| 263 | + BUILDCACHE_DIRECT_MODE: true |
| 264 | + BUILDCACHE_MAX_CACHE_SIZE: 2147483648 |
| 265 | + BUILDCACHE_LUA_PATH: ${{ github.workspace }}/tools |
| 266 | + UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1 |
| 267 | + ASAN_OPTIONS: alloc_dealloc_mismatch=0 |
| 268 | + steps: |
| 269 | + - uses: actions/checkout@v4 |
| 270 | + |
| 271 | + - name: Get deps |
| 272 | + run: ln -s /deps deps |
| 273 | + |
| 274 | + - name: CMake |
| 275 | + run: | |
| 276 | + git config --global --add safe.directory `pwd` |
| 277 | + cmake -G Ninja -S . -B build --preset=${{ matrix.config.preset }} |
| 278 | +
|
| 279 | + # ==== BUILD ==== |
| 280 | + - name: Build |
| 281 | + run: | |
| 282 | + buildcache -z |
| 283 | + cmake --build build --target osr-extract osr-backend osr-benchmark osr-test |
| 284 | + buildcache -s |
| 285 | +
|
| 286 | + # ==== TESTS ==== |
| 287 | + - name: Run Tests |
| 288 | + if: ${{ !matrix.config.skiptests }} |
| 289 | + run: ${{ matrix.config.emulator }} build/osr-test |
| 290 | + |
| 291 | + # ==== DISTRIBUTION ==== |
| 292 | + - name: Create Distribution |
| 293 | + if: matrix.config.artifact |
| 294 | + run: | |
| 295 | + mkdir osr |
| 296 | + mv web osr/web |
| 297 | + mv build/osr-extract osr/osr-extract |
| 298 | + mv build/osr-backend osr/osr-backend |
| 299 | + tar cjf osr-${{ matrix.config.artifact }}.tar.bz2 osr |
| 300 | +
|
| 301 | + - name: Upload Distribution |
| 302 | + if: matrix.config.artifact |
| 303 | + uses: actions/upload-artifact@v4 |
| 304 | + with: |
| 305 | + name: osr-${{ matrix.config.artifact }} |
| 306 | + path: osr-${{ matrix.config.artifact }}.tar.bz2 |
| 307 | + |
| 308 | + # ==== RELEASE ==== |
| 309 | + - name: Upload Release |
| 310 | + if: github.event.action == 'published' && matrix.config.artifact |
| 311 | + uses: actions/upload-release-asset@v1.0.2 |
| 312 | + env: |
| 313 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 314 | + with: |
| 315 | + upload_url: ${{ github.event.release.upload_url }} |
| 316 | + asset_path: ./osr-${{ matrix.config.artifact }}.tar.bz2 |
| 317 | + asset_name: osr-${{ matrix.config.artifact }}.tar.bz2 |
| 318 | + asset_content_type: application/x-tar |
0 commit comments