Skip to content

[build-win]

[build-win] #719

Workflow file for this run

name: Windows Server 2025 build x86 MSVC and Clang (in container)
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
permissions:
contents: read
packages: read
env:
BUILD_TYPE: Debug
BUILD_DIR: build
BUILD_DIR_RELEASE: build_release
VULKAN_VERSION: 1.4.328.1
CLANG_VERSION: 21.1.5
VULKAN_SDK_PATH: C:\VulkanSDK
CLANG_PROFILE_PRESET: x64-ClangCL-Windows-Profile
jobs:
build:
if: contains(github.event.head_commit.message, '[build-win]')
# Use a SELF-HOSTED Windows runner with Docker (Windows containers) enabled
runs-on: [self-hosted, windows]
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
submodules: recursive
- name: Docker login (GHCR)
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || !github.event.pull_request }}
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$token = "${{ secrets.GITHUB_TOKEN }}"
echo $token | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Pull container image
shell: pwsh
run: |
docker pull ghcr.io/kataglyphis/kataglyphis_beschleuniger:winamd64
- name: Start container (detached)
shell: pwsh
run: |
docker rm -f ci 2>$null | Out-Null
docker run -d --name ci --isolation=process `
-e BUILD_TYPE="${{ env.BUILD_TYPE }}" `
-e BUILD_DIR="${{ env.BUILD_DIR }}" `
-e BUILD_DIR_RELEASE="${{ env.BUILD_DIR_RELEASE }}" `
-e VULKAN_VERSION="${{ env.VULKAN_VERSION }}" `
-e CLANG_VERSION="${{ env.CLANG_VERSION }}" `
-e VULKAN_SDK_PATH="${{ env.VULKAN_SDK_PATH }}" `
-e CLANG_PROFILE_PRESET="${{ env.CLANG_PROFILE_PRESET }}" `
-e WORKDIR="C:\work" `
-v "${{ github.workspace }}:C:\work" `
-w "C:\work" `
ghcr.io/kataglyphis/kataglyphis_beschleuniger:winamd64 `
powershell -NoProfile -Command "while ($true) { Start-Sleep -Seconds 3600 }"
# ===================== Run your steps inside the container =====================
- name: Install Windows Dependencies (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"./Scripts/Windows/setup-dependencies.ps1 `
-VulkanVersion $Env:VULKAN_VERSION `
-ClangVersion $Env:CLANG_VERSION `
-VulkanSdkPath $Env:VULKAN_SDK_PATH"
- name: Push Clang and LLVM to Path (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"Add-Content -Path $Env:GITHUB_PATH -Value 'C:\Program Files\LLVM\bin'; `
'`$env:USERPROFILE\scoop\shims' | Out-File -Append -FilePath $Env:GITHUB_PATH"
- name: CMake Build for MSVC Debug (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"cmake -B `"$Env:WORKDIR\$Env:BUILD_DIR`" --preset 'x64-MSVC-Windows-Debug' -Dmyproject_ENABLE_CPPCHECK=OFF -DWINDOWS_CI=ON; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR`""
- name: Test (MSVC) (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"pushd `"$Env:WORKDIR\$Env:BUILD_DIR`"; ctest; popd"
- name: Prepare for MSVC Release (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"Remove-Item -Path `"$Env:WORKDIR\$Env:BUILD_DIR`" -Recurse -Force"
- name: CMake Build for MSVC Release (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"cmake -B `"$Env:WORKDIR\$Env:BUILD_DIR`" --preset 'x64-MSVC-Windows-Release' -Dmyproject_ENABLE_CPPCHECK=OFF; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR`""
- name: Configure/Build Clang Debug (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"Remove-Item -Path `"$Env:WORKDIR\$Env:BUILD_DIR`" -Recurse -Force; `
cmake -B `"$Env:WORKDIR\$Env:BUILD_DIR`" --preset 'x64-ClangCL-Windows-Debug' -Dmyproject_ENABLE_CPPCHECK=OFF; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR`" --preset 'x64-ClangCL-Windows-Debug'"
- name: Clang coverage (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"pushd `"$Env:WORKDIR\$Env:BUILD_DIR`"; `
ctest; `
& 'llvm-profdata.exe' merge -sparse 'Test\compile\default.profraw' -o 'compileTestSuite.profdata'; `
& 'llvm-cov.exe' report 'compileTestSuite.exe' -instr-profile='compileTestSuite.profdata'; `
& 'llvm-cov.exe' export 'compileTestSuite.exe' -format=text -instr-profile='compileTestSuite.profdata' | Out-File -FilePath 'coverage.json' -Encoding UTF8; `
& 'llvm-cov.exe' show 'compileTestSuite.exe' -instr-profile='compileTestSuite.profdata'; `
popd"
- name: Run Clang static analysis (HTML) (in container)
shell: pwsh
continue-on-error: true
run: |
docker exec ci powershell -NoProfile -Command `
"`$sourceFiles = Get-ChildItem -Path 'Src' -Recurse -Include '*.cpp','*.cc' | ForEach-Object { `$_.FullName }; `
clang++ --analyze -DUSE_RUST=1 -Xanalyzer -analyzer-output=html @sourceFiles"
- name: scan-build (in container)
shell: pwsh
continue-on-error: true
run: |
docker exec ci powershell -NoProfile -Command `
"New-Item -ItemType Directory -Path 'scan-build-reports' -Force | Out-Null; `
scan-build --use-analyzer='C:\Program Files\LLVM\bin\clang-cl.exe' -o scan-build-reports `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR`" --preset 'x64-ClangCL-Windows-Debug'"
- name: Profiling build (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"clang --version; `
cmake -B `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" --preset `"$Env:CLANG_PROFILE_PRESET`" -Dmyproject_ENABLE_CPPCHECK=OFF; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" --preset `"$Env:CLANG_PROFILE_PRESET`""
- name: Run performance benchmarks (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"pushd `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`"; `
.\perfTestSuite.exe --benchmark_out=results.json --benchmark_out_format=json; `
popd"
- name: Clang Release configure/build/package (in container)
shell: pwsh
run: |
docker exec ci powershell -NoProfile -Command `
"Remove-Item -Path `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" -Recurse -Force; `
clang --version; `
cmake -B `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" --preset 'x64-ClangCL-Windows-Release' -Dmyproject_ENABLE_CPPCHECK=OFF -DWINDOWS_CI=ON; `
`$env:CMAKE_BUILD_PARALLEL_LEVEL = `$env:NUMBER_OF_PROCESSORS; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" --preset 'x64-ClangCL-Windows-Release' -DWINDOWS_CI=ON; `
cmake --build `"$Env:WORKDIR\$Env:BUILD_DIR_RELEASE`" --target package --verbose"
- name: Upload Installers & Zip
uses: actions/upload-artifact@v4
with:
name: windows-installers
path: |
${{ github.workspace }}\${{ env.BUILD_DIR_RELEASE }}\*.msi
${{ github.workspace }}\${{ env.BUILD_DIR_RELEASE }}\*.exe
${{ github.workspace }}\${{ env.BUILD_DIR_RELEASE }}\*.zip
- name: Stop container
if: always()
shell: pwsh
run: |
docker rm -f ci 2>$null | Out-Null