Ecosystem and profiles chapters #29
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CMake CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| ccache: ccache | |
| vulkan-install: | | |
| VULKAN_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/linux.txt) | |
| echo "Using Vulkan SDK version: $VULKAN_VERSION" | |
| mkdir -p vulkan-sdk | |
| cd vulkan-sdk | |
| curl -O "https://sdk.lunarg.com/sdk/download/$VULKAN_VERSION/linux/vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz" | |
| tar -xJf vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz | |
| echo "VULKAN_SDK=$PWD/$VULKAN_VERSION/x86_64" >> $GITHUB_ENV | |
| echo "PATH=$PWD/$VULKAN_VERSION/x86_64/bin:$PATH" >> $GITHUB_ENV | |
| echo "LD_LIBRARY_PATH=$PWD/$VULKAN_VERSION/x86_64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
| echo "VK_LAYER_PATH=$PWD/$VULKAN_VERSION/x86_64/etc/vulkan/explicit_layer.d" >> $GITHUB_ENV | |
| cd .. | |
| deps-install: | | |
| chmod +x scripts/install_dependencies_linux.sh | |
| ./scripts/install_dependencies_linux.sh | |
| test-cmd: | | |
| if [ -f "00_base_code/00_base_code" ]; then | |
| echo "00_base_code built successfully" | |
| else | |
| echo "00_base_code build failed" | |
| exit 1 | |
| fi | |
| if [ -f "15_hello_triangle/15_hello_triangle" ]; then | |
| echo "15_hello_triangle built successfully" | |
| else | |
| echo "15_hello_triangle build failed" | |
| exit 1 | |
| fi | |
| if [ -f "31_compute_shader/31_compute_shader" ]; then | |
| echo "31_compute_shader built successfully" | |
| else | |
| echo "31_compute_shader build failed" | |
| exit 1 | |
| fi | |
| - os: windows-latest | |
| ccache: sccache | |
| vulkan-install: | | |
| Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" -OutFile "$env:TEMP\vulkan-sdk.exe" | |
| Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow | |
| $vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName | |
| if (-not $vulkanPath) { | |
| $vulkanPath = "C:\VulkanSDK\latest" | |
| } | |
| echo "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| Write-Host "Vulkan SDK path: $vulkanPath" | |
| if (Test-Path "$vulkanPath\Lib") { | |
| Write-Host "Lib directory exists" | |
| } else { | |
| Write-Host "Lib directory does not exist" | |
| } | |
| if (Test-Path "$vulkanPath\Include") { | |
| Write-Host "Include directory exists" | |
| } else { | |
| Write-Host "Include directory does not exist" | |
| } | |
| deps-install: | | |
| .\scripts\install_dependencies_windows.bat | |
| echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV | |
| test-cmd: | | |
| if (Test-Path "00_base_code/Release/00_base_code.exe") { | |
| echo "00_base_code built successfully" | |
| } else { | |
| echo "00_base_code build failed" | |
| exit 1 | |
| } | |
| if (Test-Path "15_hello_triangle/Release/15_hello_triangle.exe") { | |
| echo "15_hello_triangle built successfully" | |
| } else { | |
| echo "15_hello_triangle build failed" | |
| exit 1 | |
| } | |
| if (Test-Path "31_compute_shader/Release/31_compute_shader.exe") { | |
| echo "31_compute_shader built successfully" | |
| } else { | |
| echo "31_compute_shader build failed" | |
| exit 1 | |
| } | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Cache vcpkg packages (Windows) | |
| if: runner.os == 'Windows' | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ env.VCPKG_INSTALLATION_ROOT }}/installed | |
| ${{ env.VCPKG_INSTALLATION_ROOT }}/packages | |
| ${{ env.VCPKG_INSTALLATION_ROOT }}/buildtrees | |
| key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }} | |
| restore-keys: | | |
| ${{ runner.os }}-vcpkg-${{ hashFiles('**/CMakeLists.txt') }}- | |
| ${{ runner.os }}-vcpkg- | |
| - name: Cache Vulkan SDK (Windows) | |
| if: runner.os == 'Windows' | |
| uses: actions/cache@v3 | |
| with: | |
| path: C:\VulkanSDK | |
| key: ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-vulkan-sdk- | |
| - name: Cache apt packages (Ubuntu) | |
| if: runner.os == 'Linux' | |
| uses: actions/cache@v3 | |
| with: | |
| path: /var/cache/apt/archives | |
| key: ${{ runner.os }}-apt-${{ hashFiles('**/workflow.yml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| - name: Cache ccache files | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.ccache | |
| ~/.cache/sccache | |
| key: ${{ runner.os }}-${{ matrix.ccache }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.ccache }}- | |
| - name: Cache Vulkan SDK (Ubuntu) | |
| if: runner.os == 'Linux' | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/vulkan-sdk | |
| key: ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }} | |
| restore-keys: | | |
| ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}- | |
| ${{ runner.os }}-vulkan-sdk- | |
| - name: Install ccache (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ccache | |
| ccache --max-size=2G | |
| ccache -z | |
| echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV | |
| echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV | |
| - name: Install sccache (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| Invoke-WebRequest -Uri "https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz" -OutFile "sccache.tar.gz" | |
| tar -xzf sccache.tar.gz | |
| $sccachePath = Join-Path -Path (Get-Location) -ChildPath "sccache-v0.5.4-x86_64-pc-windows-msvc" | |
| echo "$sccachePath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| echo "SCCACHE_DIR=$HOME/.cache/sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| echo "SCCACHE_CACHE_SIZE=2G" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Install dependencies | |
| run: ${{ matrix.deps-install }} | |
| - name: Install Vulkan SDK | |
| run: ${{ matrix.vulkan-install }} | |
| - name: Verify Vulkan Installation (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| if (Test-Path $env:VULKAN_SDK) { | |
| echo "Vulkan SDK found at: $env:VULKAN_SDK" | |
| $criticalPaths = @( | |
| "$env:VULKAN_SDK\Include", | |
| "$env:VULKAN_SDK\Lib", | |
| "$env:VULKAN_SDK\Bin", | |
| "$env:VULKAN_SDK\Include\vulkan\vulkan.h", | |
| "$env:VULKAN_SDK\Lib\vulkan-1.lib", | |
| "$env:VULKAN_SDK\Bin\glslangValidator.exe" | |
| ) | |
| $allPathsExist = $true | |
| foreach ($path in $criticalPaths) { | |
| if (Test-Path $path) { | |
| echo "✓ Found: $path" | |
| } else { | |
| echo "✗ Missing: $path" | |
| $allPathsExist = $false | |
| } | |
| } | |
| if ($allPathsExist) { | |
| echo "Vulkan SDK installation verified successfully" | |
| } else { | |
| echo "Vulkan SDK installation is incomplete!" | |
| exit 1 | |
| } | |
| } else { | |
| echo "Vulkan SDK not found!" | |
| exit 1 | |
| } | |
| - name: Cache build artifacts (Windows) | |
| if: runner.os == 'Windows' | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{github.workspace}}/attachments/build | |
| key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}-${{ hashFiles('**/*.h') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}- | |
| ${{ runner.os }}-build- | |
| - name: Configure CMake (Windows) | |
| working-directory: ${{github.workspace}}/attachments | |
| if: runner.os == 'Windows' | |
| run: | | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release ` | |
| -DVulkan_INCLUDE_DIR="$env:Vulkan_INCLUDE_DIR" ` | |
| -DVulkan_LIBRARY="$env:Vulkan_LIBRARY" ` | |
| -DCMAKE_PREFIX_PATH="$env:VULKAN_SDK" ` | |
| -DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" ` | |
| -DCMAKE_C_COMPILER_LAUNCHER=sccache ` | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=sccache | |
| if (Test-Path "build/CMakeCache.txt") { | |
| Write-Host "CMake cache contents:" | |
| Get-Content "build/CMakeCache.txt" | Select-String -Pattern "Vulkan" | |
| } | |
| - name: Verify Vulkan Installation (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| if [ -d "$VULKAN_SDK" ]; then | |
| echo "Vulkan SDK found at: $VULKAN_SDK" | |
| echo "Vulkan SDK installation verified" | |
| else | |
| echo "Vulkan SDK not found!" | |
| exit 1 | |
| fi | |
| - name: Cache build artifacts (Ubuntu) | |
| if: runner.os == 'Linux' | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{github.workspace}}/attachments/build | |
| key: ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('**/*.cpp') }}-${{ hashFiles('**/*.h') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt') }}- | |
| ${{ runner.os }}-build- | |
| - name: Configure CMake (Unix) | |
| working-directory: ${{github.workspace}}/attachments | |
| if: runner.os != 'Windows' | |
| run: | | |
| export CC="ccache clang" | |
| export CXX="ccache clang++" | |
| cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_CXX_SCAN_FOR_MODULES=ON \ | |
| -DCMAKE_CXX_FLAGS="-std=c++20" \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| - name: Build | |
| working-directory: ${{github.workspace}}/attachments | |
| run: cmake --build build --config Release | |
| - name: ccache statistics | |
| if: runner.os == 'Linux' | |
| run: ccache -s | |
| - name: sccache statistics | |
| if: runner.os == 'Windows' | |
| run: sccache -s | |
| - name: Test Build Output | |
| working-directory: ${{github.workspace}}/attachments/build | |
| run: ${{ matrix.test-cmd }} | |
| android-build: | |
| name: Android Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Cache ccache files | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.ccache | |
| key: android-ccache-${{ github.sha }} | |
| restore-keys: | | |
| android-ccache- | |
| - name: Cache KTX and tinygltf | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| /usr/local/include/ktx | |
| /usr/local/lib/libktx* | |
| /usr/local/include/tinygltf | |
| key: android-libs-${{ hashFiles('**/workflow.yml') }} | |
| restore-keys: | | |
| android-libs- | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| ${{github.workspace}}/attachments/android/.gradle | |
| ${{github.workspace}}/attachments/android/app/build/intermediates | |
| ${{github.workspace}}/attachments/android/app/build/outputs | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-${{ hashFiles('**/*.cpp', '**/*.h') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}- | |
| ${{ runner.os }}-gradle- | |
| - name: Install ccache | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ccache | |
| ccache --max-size=2G | |
| ccache -z | |
| echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV | |
| echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV | |
| - name: Set up Android SDK and NDK | |
| run: | | |
| echo "Using pre-installed Android SDK and NDK on GitHub runner" | |
| echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV | |
| echo "ANDROID_NDK_HOME=$ANDROID_NDK_ROOT" >> $GITHUB_ENV | |
| echo "Android SDK location: $ANDROID_SDK_ROOT" | |
| echo "Android NDK location: $ANDROID_NDK_ROOT" | |
| # Install CMake 4.0.2 using sdkmanager | |
| echo "Installing CMake 4.0.2 from Android SDK..." | |
| yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "cmake;4.0.2" | |
| echo "CMake installation completed" | |
| - name: Install KTX library | |
| run: | | |
| if [ -d "/usr/local/include/ktx" ] && [ -f "/usr/local/lib/libktx.so" ]; then | |
| echo "KTX library already installed from cache" | |
| else | |
| echo "Installing KTX library..." | |
| git clone https://github.com/KhronosGroup/KTX-Software.git | |
| cd KTX-Software | |
| git checkout v4.1.0 | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release -DKTX_FEATURE_TOOLS=OFF | |
| cmake --build . --config Release | |
| sudo cmake --install . | |
| cd ../.. | |
| fi | |
| - name: Install tinygltf | |
| run: | | |
| if [ -d "/usr/local/include/tinygltf" ]; then | |
| echo "tinygltf library already installed from cache" | |
| else | |
| echo "Installing tinygltf..." | |
| git clone https://github.com/syoyo/tinygltf.git | |
| cd tinygltf | |
| mkdir build && cd build | |
| cmake .. -DCMAKE_BUILD_TYPE=Release -DTINYGLTF_BUILD_LOADER_EXAMPLE=OFF | |
| cmake --build . --config Release | |
| sudo cmake --install . | |
| cd ../.. | |
| fi | |
| - name: Build Android Chapters | |
| working-directory: ${{github.workspace}}/attachments/android | |
| run: | | |
| if [ ! -f "gradlew" ]; then | |
| echo "Generating Gradle wrapper..." | |
| gradle wrapper | |
| fi | |
| SUPPORTED_CHAPTERS=$(grep -A 20 "set(SUPPORTED_CHAPTERS" app/src/main/cpp/CMakeLists.txt | | |
| sed -n '/set(SUPPORTED_CHAPTERS/,/)/p' | | |
| grep -o '"[^"]*"' | | |
| sed 's/"//g') | |
| readarray -t CHAPTERS <<< "$SUPPORTED_CHAPTERS" | |
| echo "Detected supported Android chapters: ${CHAPTERS[@]}" | |
| for chapter in "${CHAPTERS[@]}"; do | |
| if [ -n "$chapter" ]; then | |
| echo "Building $chapter chapter..." | |
| if [ "$chapter" != "${CHAPTERS[0]}" ]; then | |
| ./gradlew clean | |
| fi | |
| ./gradlew assembleDebug -Pchapter=$chapter | |
| if [ -f "app/build/outputs/apk/debug/app-debug.apk" ]; then | |
| echo "$chapter built successfully" | |
| else | |
| echo "$chapter build failed" | |
| exit 1 | |
| fi | |
| fi | |
| done |