1# Copyright (c) 2021-2024 Valve Corporation 2# Copyright (c) 2021-2024 LunarG, Inc. 3 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# Author: Lenny Komow <lenny@lunarg.com> 17# Author: Charles Giessen <charles@lunarg.com> 18 19name: CI Build 20 21# https://docs.github.com/en/actions/using-jobs/using-concurrency 22concurrency: 23 # github.head_ref is only defined on pull_request 24 # Fallback to the run ID, which is guaranteed to be both unique and defined for the run. 25 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} 26 cancel-in-progress: true 27 28on: 29 push: 30 pull_request: 31 branches: 32 - main 33 34permissions: read-all 35 36jobs: 37 linux: 38 needs: codegen 39 runs-on: ${{matrix.os}} 40 strategy: 41 matrix: 42 compiler: [ {cc: gcc, cxx: g++}, {cc: clang, cxx: clang++} ] 43 config: [ Debug, Release ] 44 os: [ ubuntu-20.04, ubuntu-22.04 ] 45 steps: 46 - uses: actions/checkout@v4 47 - uses: actions/setup-python@v5 48 with: 49 python-version: '3.11' 50 - name: Test CMake min 51 # NOTE: The main users who benefit from an older CMake version 52 # are linux users stuck on older LTS releases. It's idiomatic best 53 # practice to try and support them so they don't have to install 54 # the CMake tarball. Ideally the minimum we use matches what the default 55 # package provided by Ubuntu via APT. 56 if: ${{ matrix.os == 'ubuntu-20.04' }} 57 uses: lukka/get-cmake@latest 58 with: 59 cmakeVersion: 3.22.1 60 - run: sudo apt update 61 - run: sudo apt install --yes --no-install-recommends libwayland-dev libxrandr-dev 62 # This is to combat a bug when using 6.6 linux kernels with thread/address sanitizer 63 # https://github.com/google/sanitizers/issues/1716 64 - run: sudo sysctl vm.mmap_rnd_bits=28 65 - run: | 66 cmake -S. -B build \ 67 -D CMAKE_BUILD_TYPE=${{ matrix.config }} \ 68 -D BUILD_TESTS=ON \ 69 -D UPDATE_DEPS=ON \ 70 -D LOADER_ENABLE_ADDRESS_SANITIZER=ON \ 71 -D BUILD_WERROR=ON \ 72 -D CMAKE_CXX_COMPILER=${{ matrix.compiler.cxx }} \ 73 -D CMAKE_C_COMPILER=${{ matrix.compiler.cc }} 74 - run: cmake --build build 75 - run: ctest --output-on-failure --test-dir build/ 76 - run: cmake --install build --prefix /tmp 77 78 codegen: 79 runs-on: ubuntu-latest 80 steps: 81 - uses: actions/checkout@v4 82 - run: scripts/update_deps.py --dir ext --no-build 83 - run: scripts/generate_source.py --verify ext/Vulkan-Headers/registry/ 84 85 linux-no-asm: 86 needs: codegen 87 runs-on: ubuntu-22.04 88 steps: 89 - uses: actions/checkout@v4 90 - run: sudo apt update 91 - run: sudo apt install --yes --no-install-recommends libwayland-dev libxrandr-dev 92 - run: | 93 cmake -S. -B build \ 94 -D CMAKE_BUILD_TYPE=Release \ 95 -D BUILD_TESTS=ON \ 96 -D UPDATE_DEPS=ON \ 97 -D BUILD_WERROR=ON \ 98 -D USE_GAS=OFF \ 99 -D CMAKE_C_COMPILER=clang \ 100 -D CMAKE_CXX_COMPILER=clang++ 101 - run: cmake --build build 102 - run: cmake --install build --prefix /tmp 103 - run: ctest --output-on-failure -E UnknownFunction --test-dir build/ 104 105 linux-32: 106 needs: codegen 107 runs-on: ubuntu-22.04 108 strategy: 109 matrix: 110 config: [ Debug, Release ] 111 steps: 112 - uses: actions/checkout@v4 113 - uses: actions/setup-python@v5 114 with: 115 python-version: '3.11' 116 - uses: lukka/get-cmake@latest 117 with: 118 cmakeVersion: 3.22.1 119 - name: Enable 32 bit 120 run: sudo dpkg --add-architecture i386 121 - run: sudo apt-get update 122 - run: | 123 sudo apt install --yes --no-install-recommends \ 124 gcc-multilib g++-multilib libc6:i386 libc6-dev-i386 libgcc-s1:i386 \ 125 libwayland-dev:i386 libxrandr-dev:i386 126 - run: | 127 cmake -S. -B build \ 128 -D CMAKE_BUILD_TYPE=${{matrix.config}} \ 129 -D BUILD_TESTS=ON \ 130 -D UPDATE_DEPS=ON \ 131 -D BUILD_WERROR=ON \ 132 -D SYSCONFDIR=/etc/not_vulkan \ 133 -D PKG_CONFIG_EXECUTABLE=/usr/bin/i686-linux-gnu-pkg-config \ 134 -G Ninja 135 env: 136 CFLAGS: -m32 137 CXXFLAGS: -m32 138 LDFLAGS: -m32 139 ASFLAGS: --32 140 - run: cmake --build build 141 - run: cmake --install build --prefix /tmp 142 - run: ctest --output-on-failure 143 working-directory: build/ 144 145 linux-32-no-asm: 146 needs: codegen 147 runs-on: ubuntu-22.04 148 steps: 149 - uses: actions/checkout@v4 150 - uses: actions/setup-python@v5 151 with: 152 python-version: '3.11' 153 - uses: lukka/get-cmake@latest 154 with: 155 cmakeVersion: 3.22.1 156 - name: Enable 32 bit 157 run: sudo dpkg --add-architecture i386 158 - run: sudo apt-get update 159 - run: | 160 sudo apt install --yes --no-install-recommends \ 161 gcc-multilib g++-multilib libc6:i386 libc6-dev-i386 libgcc-s1:i386 \ 162 libwayland-dev:i386 libxrandr-dev:i386 163 - run: | 164 cmake -S. -B build \ 165 -D CMAKE_BUILD_TYPE=Release \ 166 -D BUILD_TESTS=ON \ 167 -D UPDATE_DEPS=ON \ 168 -D BUILD_WERROR=ON \ 169 -D USE_GAS=OFF \ 170 -D PKG_CONFIG_EXECUTABLE=/usr/bin/i686-linux-gnu-pkg-config \ 171 -G Ninja 172 env: 173 CFLAGS: -m32 174 CXXFLAGS: -m32 175 LDFLAGS: -m32 176 ASFLAGS: --32 177 - run: cmake --build build 178 - run: ctest --output-on-failure -E UnknownFunction 179 working-directory: build/ 180 181 windows_vs: 182 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 183 needs: linux-no-asm 184 runs-on: windows-latest 185 strategy: 186 matrix: 187 arch: [ Win32, x64 ] 188 config: [ Debug, Release ] 189 steps: 190 - uses: actions/checkout@v4 191 - run: | 192 cmake -S. -B build ` 193 -D BUILD_TESTS=ON ` 194 -D UPDATE_DEPS=ON ` 195 -D CMAKE_BUILD_TYPE=${{matrix.config}} ` 196 -A ${{ matrix.arch }} ` 197 -D BUILD_WERROR=ON 198 - run: cmake --build build/ --config ${{matrix.config}} 199 - run: cmake --install build --prefix build/install --config ${{matrix.config}} 200 - run: ctest --output-on-failure -C ${{matrix.config}} --test-dir build/ 201 202 windows_vs-no-asm: 203 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 204 needs: linux-no-asm 205 runs-on: windows-latest 206 strategy: 207 matrix: 208 arch: [ Win32, x64 ] 209 steps: 210 - uses: actions/checkout@v4 211 - run: | 212 cmake -S. -B build ` 213 -D BUILD_TESTS=ON ` 214 -D UPDATE_DEPS=ON ` 215 -D USE_MASM=OFF ` 216 -D CMAKE_BUILD_TYPE=Release ` 217 -A ${{ matrix.arch }} ` 218 -D BUILD_WERROR=ON 219 - run: cmake --build build/ --config Release 220 - run: ctest --output-on-failure -C Release -E UnknownFunction --test-dir build/ 221 222 # Test both clang and clang-cl (Chromium project uses clang-cl) 223 windows_clang: 224 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 225 needs: linux-no-asm 226 runs-on: windows-2022 227 strategy: 228 matrix: 229 compiler: [ clang, clang-cl ] 230 config: [ Debug, Release ] 231 steps: 232 - uses: actions/checkout@v4 233 - uses: ilammy/msvc-dev-cmd@v1 234 - run: | 235 cmake -S. -B build ` 236 -D CMAKE_C_COMPILER=${{matrix.compiler}} ` 237 -D CMAKE_CXX_COMPILER=${{matrix.compiler}} ` 238 -D UPDATE_DEPS=ON ` 239 -D CMAKE_BUILD_TYPE=${{matrix.config}} ` 240 -D BUILD_WERROR=ON ` 241 -D BUILD_TESTS=ON ` 242 -G Ninja 243 - run: cmake --build build/ 244 - run: ctest --output-on-failure --test-dir build/ 245 - run: cmake --install build --prefix build/install 246 247 mac: 248 # Mac is 10x expensive to run on GitHub machines, so only run if we know something else passed as well 249 needs: windows_clang 250 runs-on: macos-13 251 strategy: 252 matrix: 253 config: [ Debug, Release ] 254 static_build: [ APPLE_STATIC_LOADER=ON, APPLE_STATIC_LOADER=OFF ] 255 steps: 256 - uses: actions/checkout@v4 257 - uses: actions/setup-python@v5 258 with: 259 python-version: '3.11' 260 - uses: lukka/get-cmake@latest 261 - run: | 262 cmake -S. -B build \ 263 -D CMAKE_BUILD_TYPE=${{matrix.config}} \ 264 -D ${{matrix.static_build}} \ 265 -D BUILD_TESTS=ON \ 266 -D UPDATE_DEPS=ON \ 267 -D BUILD_WERROR=ON \ 268 -D LOADER_ENABLE_ADDRESS_SANITIZER=ON \ 269 -G Ninja 270 env: 271 # Prevents regression of KhronosGroup/Vulkan-Loader/issues/1332 272 LDFLAGS: -Wl,-fatal_warnings 273 - run: cmake --build build 274 - run: cmake --install build --prefix /tmp 275 - run: ctest --output-on-failure --test-dir build/ 276 277 apple-cross-compile: 278 # Mac is 10x expensive to run on GitHub machines, so only run if we know something else passed as well 279 needs: windows_clang 280 name: ${{ matrix.CMAKE_SYSTEM_NAME }} 281 runs-on: macos-13 282 strategy: 283 matrix: 284 CMAKE_SYSTEM_NAME: [ iOS, tvOS ] 285 steps: 286 - uses: actions/checkout@v4 287 - uses: actions/setup-python@v5 288 with: 289 python-version: '3.11' 290 - uses: lukka/get-cmake@latest 291 - run: | 292 cmake -S . -B build \ 293 -D CMAKE_SYSTEM_NAME=${{ matrix.CMAKE_SYSTEM_NAME }} \ 294 "-D CMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ 295 -D CMAKE_BUILD_TYPE=Debug \ 296 -D UPDATE_DEPS=ON \ 297 -D BUILD_WERROR=ON \ 298 -G Ninja 299 env: 300 LDFLAGS: -Wl,-fatal_warnings 301 - run: cmake --build build 302 - run: cmake --install build --prefix /tmp 303 - name: Verify Universal Binary 304 run: | 305 vtool -show-build /tmp/lib/libvulkan.dylib | grep 'architecture x86_64' 306 vtool -show-build /tmp/lib/libvulkan.dylib | grep 'architecture arm64' 307 308 # Building a universal binary disables assembly automatically 309 # Furthermore the Vulkan SDK ships universal binaries 310 mac-univeral: 311 # Mac is 10x expensive to run on GitHub machines, so only run if we know something else passed as well 312 needs: windows_clang 313 name: "Universal Binary Testing (STATIC ${{ matrix.static }}) w/ ${{ matrix.generator }}" 314 runs-on: macos-latest 315 strategy: 316 matrix: 317 static: [ 'ON', 'OFF' ] 318 generator: [ Ninja, Xcode ] 319 steps: 320 - uses: actions/checkout@v4 321 - uses: actions/setup-python@v5 322 with: 323 python-version: '3.11' 324 - uses: lukka/get-cmake@latest 325 - run: | 326 cmake -S. -B build \ 327 -D CMAKE_BUILD_TYPE=Release \ 328 -D APPLE_STATIC_LOADER=${{matrix.static}} \ 329 "-D CMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ 330 -D BUILD_TESTS=ON \ 331 -D UPDATE_DEPS=ON \ 332 -D BUILD_WERROR=ON \ 333 -G ${{ matrix.generator }} 334 env: 335 LDFLAGS: -Wl,-fatal_warnings 336 - run: cmake --build build --config Release 337 - run: ctest --output-on-failure --build-config Release -E UnknownFunction --test-dir build/ 338 - run: cmake --install build --config Release --prefix /tmp 339 - name: Verify Universal Binary 340 if: ${{ matrix.static == 'OFF' }} 341 run: | 342 vtool -show-build /tmp/lib/libvulkan.dylib | grep 'architecture x86_64' 343 vtool -show-build /tmp/lib/libvulkan.dylib | grep 'architecture arm64' 344 345 chromium: 346 needs: codegen 347 runs-on: ubuntu-latest 348 steps: 349 - uses: actions/checkout@v4 350 - run: scripts/gn/gn.py 351 352 mingw: 353 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 354 needs: linux-no-asm 355 runs-on: windows-2022 356 defaults: 357 run: 358 shell: bash 359 steps: 360 - uses: actions/checkout@v4 361 - uses: actions/setup-python@v5 362 with: 363 python-version: '3.11' 364 - uses: lukka/get-cmake@latest 365 - name: Setup uasm 366 run: | 367 C:/msys64/usr/bin/pacman -Sy --noconfirm --needed mingw-w64-x86_64-uasm 368 printf '%s\n' 'C:/msys64/mingw64/bin' >> $GITHUB_PATH 369 - name: UASM Check 370 run: uasm -? 371 - run: | 372 cmake -S. -B build \ 373 -D UPDATE_DEPS=ON \ 374 -D CMAKE_BUILD_TYPE=Release \ 375 -D BUILD_WERROR=ON \ 376 -G Ninja 377 - run: cmake --build build 378 - run: cmake --install build --prefix /tmp 379 380 mingw-use-gas: 381 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 382 needs: linux-no-asm 383 runs-on: windows-2022 384 defaults: 385 run: 386 shell: bash 387 steps: 388 - uses: actions/checkout@v4 389 - uses: actions/setup-python@v5 390 with: 391 python-version: '3.11' 392 - uses: lukka/get-cmake@latest 393 - run: | 394 cmake -S. -B build \ 395 -D UPDATE_DEPS=ON \ 396 -D CMAKE_BUILD_TYPE=Release \ 397 -D BUILD_WERROR=ON \ 398 -D USE_GAS=ON \ 399 -G Ninja 400 - run: cmake --build build 401 - run: cmake --install build --prefix /tmp 402 403 mingw-no-asm: 404 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 405 needs: linux-no-asm 406 runs-on: windows-2022 407 defaults: 408 run: 409 shell: bash 410 steps: 411 - uses: actions/checkout@v4 412 - uses: actions/setup-python@v5 413 with: 414 python-version: '3.11' 415 - uses: lukka/get-cmake@latest 416 # Make sure this doesn't fail even without explicitly setting '-D USE_MASM=OFF' and without uasm 417 - run: | 418 cmake -S. -B build \ 419 -D UPDATE_DEPS=ON \ 420 -D CMAKE_BUILD_TYPE=Release \ 421 -D BUILD_WERROR=ON \ 422 -G Ninja 423 - run: cmake --build build 424 - run: cmake --install build --prefix /tmp 425 426 mingw-no-asm-explicit: 427 # windows is 2x expensive to run on GitHub machines, so only run if we know something else simple passed as well 428 needs: linux-no-asm 429 runs-on: windows-2022 430 defaults: 431 run: 432 shell: bash 433 steps: 434 - uses: actions/checkout@v4 435 - uses: lukka/get-cmake@latest 436 - run: | 437 cmake -S. -B build \ 438 -D UPDATE_DEPS=ON \ 439 -D CMAKE_BUILD_TYPE=Release \ 440 -D BUILD_WERROR=ON \ 441 -D USE_MASM=OFF \ 442 -G Ninja 443 - run: cmake --build build 444 - run: cmake --install build --prefix /tmp 445