Skip to content

Commit 0fb8c9d

Browse files
committed
Enhance CI workflow for Vulkan SDK setup and dependency management
- Improved Vulkan SDK installation for both Windows and Linux, including error handling and streamlined processes. - Replaced direct vcpkg calls with platform-specific dependency install scripts. - Added configuration for Ninja builds and automated test execution.
1 parent b5a8882 commit 0fb8c9d

File tree

1 file changed

+92
-14
lines changed

1 file changed

+92
-14
lines changed

.github/workflows/simple_engine_ci.yml

Lines changed: 92 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,24 @@ jobs:
4040
if: runner.os == 'Windows'
4141
shell: pwsh
4242
run: |
43+
$ErrorActionPreference = 'Stop'
44+
45+
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
46+
throw "Chocolatey is required on windows-latest runners"
47+
}
48+
4349
if (Test-Path "C:\VulkanSDK") {
44-
Write-Host "Using cached Vulkan SDK"
50+
Write-Host "Using existing Vulkan SDK at C:\VulkanSDK"
4551
} else {
4652
Write-Host "Downloading Vulkan SDK installer..."
4753
choco install -y aria2
54+
$installer = Join-Path $env:TEMP "vulkan-sdk.exe"
4855
aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe"
49-
Write-Host "Installing Vulkan SDK (minimal components)..."
50-
Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow
56+
57+
Write-Host "Installing Vulkan SDK (silent, default feature set)..."
58+
# NOTE: Do not pass --components here. LunarG has changed component IDs over time,
59+
# and specifying them can cause 'Component(s) not found' failures.
60+
Start-Process -FilePath $installer -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow
5161
}
5262
5363
$vulkanPath = ""
@@ -64,25 +74,93 @@ jobs:
6474
"Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
6575
"Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
6676
67-
- name: Install Linux prerequisites
77+
- name: Install Vulkan SDK (Linux)
6878
if: runner.os == 'Linux'
79+
shell: bash
6980
run: |
81+
set -euo pipefail
82+
sudo apt-get update
83+
sudo apt-get install -y wget gnupg ca-certificates
84+
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
85+
86+
# Pick the correct LunarG repo list for the runner's Ubuntu codename.
87+
codename=""
88+
if [ -f /etc/os-release ]; then
89+
. /etc/os-release
90+
codename="${VERSION_CODENAME:-}"
91+
fi
92+
if [ -z "$codename" ] && command -v lsb_release >/dev/null 2>&1; then
93+
codename="$(lsb_release -sc)"
94+
fi
95+
if [ -z "$codename" ]; then
96+
codename="jammy"
97+
fi
98+
99+
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
100+
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
101+
if ! sudo wget -qO "$listPath" "$listUrl"; then
102+
echo "Warning: failed to fetch ${listUrl}; falling back to jammy list"
103+
codename="jammy"
104+
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
105+
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
106+
sudo wget -qO "$listPath" "$listUrl"
107+
fi
108+
70109
sudo apt-get update
71-
sudo apt-get install -y ninja-build libvulkan-dev \
72-
libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
110+
sudo apt-get install -y vulkan-sdk
111+
112+
# We configure with Ninja on Linux; ensure it's available.
113+
sudo apt-get install -y ninja-build
114+
115+
# Use the engine's dependency install scripts instead of calling vcpkg directly in CI.
116+
- name: Bootstrap vcpkg (Windows)
117+
if: runner.os == 'Windows'
118+
shell: pwsh
119+
run: |
120+
$ErrorActionPreference = 'Stop'
121+
122+
$vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg"
123+
if (-not (Test-Path $vcpkgRoot)) {
124+
git clone https://github.com/microsoft/vcpkg $vcpkgRoot
125+
}
126+
Push-Location $vcpkgRoot
127+
.\bootstrap-vcpkg.bat
128+
Pop-Location
73129
74-
- name: Set up vcpkg (manifest)
75-
id: runvcpkg
76-
uses: lukka/run-vcpkg@v11
77-
with:
78-
vcpkgJsonGlob: 'attachments/simple_engine/vcpkg.json'
79-
runVcpkgInstall: true
130+
"VCPKG_INSTALLATION_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
131+
"$vcpkgRoot" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
132+
"CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
80133
81-
- name: Configure
134+
- name: Install dependencies (Windows)
135+
if: runner.os == 'Windows'
136+
shell: cmd
137+
run: |
138+
call install_dependencies_windows.bat
139+
140+
- name: Install dependencies (Linux)
141+
if: runner.os == 'Linux'
142+
shell: bash
143+
run: |
144+
chmod +x ./install_dependencies_linux.sh
145+
./install_dependencies_linux.sh
146+
147+
- name: Configure (Windows)
148+
if: runner.os == 'Windows'
149+
shell: pwsh
150+
run: >
151+
cmake -S . -B build -G Ninja
152+
-DCMAKE_BUILD_TYPE=Release
153+
-DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE"
154+
155+
- name: Configure (Linux)
156+
if: runner.os == 'Linux'
157+
shell: bash
82158
run: >
83159
cmake -S . -B build -G Ninja
84160
-DCMAKE_BUILD_TYPE=Release
85-
-DCMAKE_TOOLCHAIN_FILE="${{ steps.runvcpkg.outputs.vcpkgRootDir }}/scripts/buildsystems/vcpkg.cmake"
86161
87162
- name: Build
88163
run: cmake --build build --target SimpleEngine --parallel 4
164+
165+
- name: Test
166+
run: ctest --test-dir build --output-on-failure

0 commit comments

Comments
 (0)