3535 fetch-depth : 0
3636 submodules : recursive
3737
38+ # Cache Vulkan SDK on Windows like in workflow.yml
39+ - name : Cache Vulkan SDK (Windows)
40+ if : runner.os == 'Windows'
41+ uses : actions/cache@v3
42+ with :
43+ path : C:\VulkanSDK
44+ key : ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt', '**/*.cpp', '**/*.h') }}
45+ restore-keys : |
46+ ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-
47+ ${{ runner.os }}-vulkan-sdk-
48+
49+ # Cache vcpkg packages (Windows) like in workflow.yml
50+ - name : Cache vcpkg packages (Windows)
51+ if : runner.os == 'Windows'
52+ uses : actions/cache@v3
53+ with :
54+ path : |
55+ ${{ env.VCPKG_INSTALLATION_ROOT }}/installed
56+ ${{ env.VCPKG_INSTALLATION_ROOT }}/packages
57+ ${{ env.VCPKG_INSTALLATION_ROOT }}/buildtrees
58+ ${{ env.VCPKG_INSTALLATION_ROOT }}/downloads
59+ ${{ runner.temp }}/vcpkg-cache
60+ key : ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat', '**/CMakeLists.txt') }}
61+ restore-keys : |
62+ ${{ runner.os }}-vcpkg-${{ hashFiles('scripts/install_dependencies_windows.bat') }}-
63+ ${{ runner.os }}-vcpkg-
64+
65+ # Cache apt packages (Ubuntu)
66+ - name : Cache apt packages (Ubuntu)
67+ if : runner.os == 'Linux'
68+ uses : actions/cache@v3
69+ with :
70+ path : /var/cache/apt/archives
71+ key : ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/simple_engine.yml') }}
72+ restore-keys : |
73+ ${{ runner.os }}-apt-
74+
75+ # Cache ccache (Ubuntu)
76+ - name : Cache ccache files (Ubuntu)
77+ if : runner.os == 'Linux'
78+ uses : actions/cache@v3
79+ with :
80+ path : |
81+ ~/.ccache
82+ key : ${{ runner.os }}-ccache-${{ hashFiles('attachments/simple_engine/**', '**/CMakeLists.txt') }}
83+ restore-keys : |
84+ ${{ runner.os }}-ccache-
85+
86+ # Cache Vulkan SDK directory (Ubuntu)
87+ - name : Cache Vulkan SDK (Ubuntu)
88+ if : runner.os == 'Linux'
89+ uses : actions/cache@v3
90+ with :
91+ path : ${{ github.workspace }}/vulkan-sdk
92+ key : ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('attachments/simple_engine/**') }}
93+ restore-keys : |
94+ ${{ runner.os }}-vulkan-sdk-${{ hashFiles('**/CMakeLists.txt') }}-
95+ ${{ runner.os }}-vulkan-sdk-
96+
97+ # Cache sccache binary (Windows)
98+ - name : Cache sccache binary (Windows)
99+ if : runner.os == 'Windows'
100+ id : cache-sccache
101+ uses : actions/cache@v3
102+ with :
103+ path : ${{ runner.temp }}/sccache
104+ key : ${{ runner.os }}-sccache-0.5.4
105+
38106 # -----------------------
39107 # Linux: set up Vulkan SDK similar to workflow.yml
40108 # -----------------------
@@ -70,6 +138,15 @@ jobs:
70138 libxi-dev \
71139 libopenal-dev
72140
141+ - name : Install and configure ccache (Ubuntu)
142+ if : matrix.os == 'ubuntu-latest'
143+ run : |
144+ sudo apt-get install -y ccache
145+ ccache --max-size=2G
146+ ccache -z
147+ echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
148+ echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
149+
73150 - name : Install project deps via script (Ubuntu)
74151 if : matrix.os == 'ubuntu-latest'
75152 working-directory : attachments/simple_engine
@@ -85,32 +162,95 @@ jobs:
85162 if : matrix.os == 'windows-latest'
86163 shell : pwsh
87164 run : |
88- git clone https://github.com/microsoft/vcpkg.git $env:USERPROFILE\vcpkg
89- & $env:USERPROFILE\vcpkg\bootstrap-vcpkg.bat
165+ $vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT
166+ if (-not $vcpkgRoot) { $vcpkgRoot = "C:\vcpkg" }
167+ if (-not (Test-Path $vcpkgRoot)) {
168+ git clone https://github.com/microsoft/vcpkg.git $vcpkgRoot
169+ & "$vcpkgRoot\bootstrap-vcpkg.bat"
170+ }
90171 $triplet = 'x64-windows'
91172 # Use manifest mode; vcpkg.json at repo root defines dependencies
92- & $env:USERPROFILE\vcpkg\vcpkg.exe install --triplet $triplet
93- echo "CMAKE_TOOLCHAIN_FILE=$env:USERPROFILE\vcpkg\scripts\buildsystems\vcpkg.cmake" >> $env:GITHUB_ENV
173+ & "$vcpkgRoot\vcpkg.exe" install --triplet $triplet
174+ echo "VCPKG_INSTALLATION_ROOT=$vcpkgRoot" >> $env:GITHUB_ENV
175+ echo "CMAKE_TOOLCHAIN_FILE=$vcpkgRoot\scripts\buildsystems\vcpkg.cmake" >> $env:GITHUB_ENV
94176 echo "VCPKG_TARGET_TRIPLET=$triplet" >> $env:GITHUB_ENV
95177
178+ - name : Install sccache (Windows)
179+ if : matrix.os == 'windows-latest'
180+ shell : pwsh
181+ run : |
182+ if (Test-Path "$env:RUNNER_TEMP\sccache\sccache.exe") {
183+ Write-Host "Using cached sccache binary"
184+ $sccachePath = "$env:RUNNER_TEMP\sccache"
185+ } else {
186+ Write-Host "Downloading and installing sccache..."
187+ New-Item -ItemType Directory -Force -Path "$env:RUNNER_TEMP\sccache" | Out-Null
188+ choco install -y aria2 --no-progress
189+ aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:RUNNER_TEMP" --out="sccache.tar.gz" "https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz"
190+ tar -xzf "$env:RUNNER_TEMP\sccache.tar.gz" --strip-components=1 -C "$env:RUNNER_TEMP\sccache" "sccache-v0.5.4-x86_64-pc-windows-msvc/sccache.exe"
191+ $sccachePath = "$env:RUNNER_TEMP\sccache"
192+ }
193+ echo "$sccachePath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
194+ echo "SCCACHE_DIR=$HOME/.cache/sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
195+ echo "SCCACHE_CACHE_SIZE=4G" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
196+ echo "SCCACHE_ERROR_LOG=$HOME/.cache/sccache/sccache.log" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
197+ echo "SCCACHE_LOG=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
198+ echo "RUST_LOG=sccache=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
199+ New-Item -ItemType Directory -Force -Path "$HOME/.cache/sccache" | Out-Null
200+ & "$sccachePath\sccache.exe" --version
201+
96202 - name : Install project deps via script (Windows)
97203 if : matrix.os == 'windows-latest'
98204 shell : cmd
99205 working-directory : attachments/simple_engine
100206 run : |
101207 if exist install_dependencies_windows.bat call install_dependencies_windows.bat || exit /b 0
102208
103- # Install LunarG Vulkan SDK on Windows and export environment variables for our FindVulkan.cmake
209+ # Install LunarG Vulkan SDK on Windows and export environment variables (mirror workflow.yml)
104210 - name : Install Vulkan SDK (Windows)
105211 if : matrix.os == 'windows-latest'
106212 shell : pwsh
107213 run : |
108- choco install vulkan-sdk -y --no-progress
109- $sdkDir = Get-ChildItem -Path 'C:\VulkanSDK' -ErrorAction SilentlyContinue | Sort-Object Name -Descending | Select-Object -First 1
110- if (-not $sdkDir) { throw "Vulkan SDK was not installed to C:\VulkanSDK" }
111- echo "Using Vulkan SDK: $($sdkDir.FullName)"
112- echo "VULKAN_SDK=$($sdkDir.FullName)" >> $env:GITHUB_ENV
113- echo "PATH=$($sdkDir.FullName)\Bin;$env:PATH" >> $env:GITHUB_ENV
214+ if (Test-Path "C:\VulkanSDK") {
215+ Write-Host "Using cached Vulkan SDK"
216+ } else {
217+ Write-Host "Downloading Vulkan SDK installer from LunarG..."
218+ choco install -y aria2 --no-progress
219+ aria2c --split=16 --max-connection-per-server=16 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe"
220+
221+ Write-Host "Installing Vulkan SDK silently..."
222+ try {
223+ Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow
224+ if (-not (Test-Path "C:\VulkanSDK")) {
225+ Write-Host "Vulkan SDK installation with components failed; retrying full install..."
226+ Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow
227+ }
228+ } catch {
229+ Write-Host "Error installing Vulkan SDK: $_"
230+ Write-Host "Retrying full install without component selection..."
231+ Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow
232+ }
233+ }
234+
235+ # Resolve installed Vulkan SDK path (latest)
236+ $vulkanPath = ""
237+ if (Test-Path "C:\VulkanSDK") {
238+ $vulkanPath = Get-ChildItem "C:\VulkanSDK" | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName
239+ }
240+ if (-not $vulkanPath) {
241+ if (Test-Path "C:\VulkanSDK\latest") {
242+ $vulkanPath = "C:\VulkanSDK\latest"
243+ } else {
244+ throw "Vulkan SDK not found after installation."
245+ }
246+ }
247+
248+ Write-Host "Using Vulkan SDK: $vulkanPath"
249+ echo "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
250+ echo "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
251+ echo "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
252+ echo "Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
253+ echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
114254
115255 # -----------------------
116256 # Configure & Build
@@ -122,7 +262,9 @@ jobs:
122262 cmake -S attachments/simple_engine \
123263 -B build-simple_engine-${{ matrix.os }}-${{ matrix.build_type }}-m${{ matrix.enable_module }} \
124264 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
125- -DENABLE_CPP20_MODULE=${{ matrix.enable_module }}
265+ -DENABLE_CPP20_MODULE=${{ matrix.enable_module }} \
266+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
267+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
126268
127269 # Configure on Ubuntu with modules enabled: use Clang + Ninja (required for C++ modules)
128270 - name : " Configure (Ubuntu • module: Clang + Ninja)"
@@ -134,7 +276,9 @@ jobs:
134276 -DCMAKE_C_COMPILER=clang \
135277 -DCMAKE_CXX_COMPILER=clang++ \
136278 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
137- -DENABLE_CPP20_MODULE=${{ matrix.enable_module }}
279+ -DENABLE_CPP20_MODULE=${{ matrix.enable_module }} \
280+ -DCMAKE_C_COMPILER_LAUNCHER=ccache \
281+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
138282
139283 - name : Configure (Windows)
140284 if : matrix.os == 'windows-latest'
@@ -145,13 +289,43 @@ jobs:
145289 -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
146290 -DENABLE_CPP20_MODULE=${{ matrix.enable_module }} `
147291 -DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" `
148- -DVCPKG_TARGET_TRIPLET="$env:VCPKG_TARGET_TRIPLET"
292+ -DVCPKG_TARGET_TRIPLET="$env:VCPKG_TARGET_TRIPLET" `
293+ -DCMAKE_C_COMPILER_LAUNCHER=sccache `
294+ -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
295+
296+ # Cache build artifacts (Windows)
297+ - name : Cache build artifacts (Windows)
298+ if : runner.os == 'Windows'
299+ uses : actions/cache@v3
300+ with :
301+ path : |
302+ build-simple_engine-windows-latest-*
303+ key : ${{ runner.os }}-build-msvc-${{ hashFiles('attachments/simple_engine/**', '**/CMakeLists.txt') }}-${{ matrix.build_type }}-m${{ matrix.enable_module }}
304+ restore-keys : |
305+ ${{ runner.os }}-build-msvc-${{ hashFiles('attachments/simple_engine/**') }}-
306+ ${{ runner.os }}-build-msvc-
307+
308+ # Cache build artifacts (Ubuntu)
309+ - name : Cache build artifacts (Ubuntu)
310+ if : runner.os == 'Linux'
311+ uses : actions/cache@v3
312+ with :
313+ path : |
314+ build-simple_engine-ubuntu-latest-*
315+ key : ${{ runner.os }}-build-${{ hashFiles('attachments/simple_engine/**', '**/CMakeLists.txt') }}-${{ matrix.build_type }}-m${{ matrix.enable_module }}
316+ restore-keys : |
317+ ${{ runner.os }}-build-${{ hashFiles('attachments/simple_engine/**') }}-
318+ ${{ runner.os }}-build-
149319
150320 - name : Build
151321 run : |
152322 cmake --build build-simple_engine-${{ matrix.os }}-${{ matrix.build_type }}-m${{ matrix.enable_module }} --config ${{ matrix.build_type }}
153323
154- - name : Package (Release only)
155- if : matrix.build_type == 'Release'
156- run : |
157- cmake --build build-simple_engine-${{ matrix.os }}-${{ matrix.build_type }}-m${{ matrix.enable_module }} --target package --config ${{ matrix.build_type }}
324+ - name : ccache statistics
325+ if : runner.os == 'Linux'
326+ run : ccache -s
327+
328+ - name : sccache statistics
329+ if : runner.os == 'Windows'
330+ shell : pwsh
331+ run : sccache -s
0 commit comments