Skip to content

Commit 08ab66c

Browse files
Merge pull request #1448 from lukaszstolarczuk/win-cache
[CI] Add vcpkg caching in Win workflows
2 parents 91ef7f2 + a585ad9 commit 08ab66c

File tree

7 files changed

+263
-83
lines changed

7 files changed

+263
-83
lines changed

.github/workflows/nightly.yml

Lines changed: 120 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,34 @@ jobs:
130130
with:
131131
fetch-depth: 0
132132

133-
- name: Set VCPKG_PATH without hwloc
134-
if: matrix.static_hwloc == 'ON'
135-
run: echo "VCPKG_PATH=${{env.VCPKG_PATH_NO_HWLOC}}" >> $env:GITHUB_ENV
133+
- name: Restore vcpkg cache
134+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
135+
id: cache
136+
with:
137+
path: vcpkg_pkgs_cache.zip
138+
key: vcpkg-generators-windows-latest-${{ hashFiles('vcpkg.json') }}
139+
140+
- name: Unpack vcpkg cache
141+
if: steps.cache.outputs.cache-hit == 'true'
142+
run: |
143+
Expand-Archive -Path ${{github.workspace}}/vcpkg_pkgs_cache.zip -DestinationPath ${{env.BUILD_DIR}}/vcpkg -Force
136144
137145
- name: Initialize vcpkg
146+
if: steps.cache.outputs.cache-hit != 'true'
138147
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
139148
with:
140149
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
141150
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
142151
vcpkgJsonGlob: '**/vcpkg.json'
143152

144153
- name: Install dependencies
154+
if: steps.cache.outputs.cache-hit != 'true'
145155
run: vcpkg install --triplet x64-windows
146156

157+
- name: Set VCPKG_PATH without hwloc
158+
if: matrix.static_hwloc == 'ON'
159+
run: echo "VCPKG_PATH=${{env.VCPKG_PATH_NO_HWLOC}}" >> $env:GITHUB_ENV
160+
147161
- name: Install Ninja
148162
if: matrix.generator == 'Ninja'
149163
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
@@ -222,6 +236,18 @@ jobs:
222236
working-directory: ${{github.workspace}}/examples/fetch_content/build
223237
run: ctest -V
224238

239+
- name: Prepare vcpkg cache
240+
if: steps.cache.outputs.cache-hit != 'true'
241+
run: |
242+
Compress-Archive -Path ${{env.BUILD_DIR}}/vcpkg/packages -DestinationPath ${{github.workspace}}/vcpkg_pkgs_cache.zip -Force -CompressionLevel Fastest
243+
244+
- name: Save vcpkg cache
245+
if: steps.cache.outputs.cache-hit != 'true'
246+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
247+
with:
248+
path: ${{github.workspace}}/vcpkg_pkgs_cache.zip
249+
key: ${{ steps.cache.outputs.cache-primary-key }}
250+
225251
# Build and test UMF with Intel C++ Compiler (ICX) on Windows
226252
Windows-icx:
227253
env:
@@ -241,71 +267,97 @@ jobs:
241267
runs-on: ${{matrix.os}}
242268

243269
steps:
244-
- name: Checkout
245-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
246-
with:
247-
fetch-depth: 0
248-
249-
- name: Initialize vcpkg
250-
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
251-
with:
252-
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
253-
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
254-
vcpkgJsonGlob: '**/vcpkg.json'
255-
256-
- name: Install dependencies
257-
run: vcpkg install --triplet x64-windows
258-
259-
- name: Install Ninja
260-
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
261-
262-
- name: Download icx compiler
263-
env:
264-
# Link source: https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler-download.html
265-
CMPLR_LINK: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/15a35578-2f9a-4f39-804b-3906e0a5f8fc/w_dpcpp-cpp-compiler_p_2024.2.1.83_offline.exe"
266-
run: |
267-
Invoke-WebRequest -Uri "${{ env.CMPLR_LINK }}" -OutFile compiler_install.exe
268-
269-
- name: Install icx compiler
270-
shell: cmd
271-
run: |
272-
start /b /wait .\compiler_install.exe -s -x -f extracted --log extract.log
273-
extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 ^
274-
-p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
275-
276-
- name: Configure build
277-
shell: cmd
278-
run: |
279-
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
280-
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
281-
cmake ^
282-
-B ${{env.BUILD_DIR}} ^
283-
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}" ^
284-
-DCMAKE_C_COMPILER=${{matrix.compiler.c}} ^
285-
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} ^
286-
-G Ninja ^
287-
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}} ^
288-
-DUMF_FORMAT_CODE_STYLE=OFF ^
289-
-DUMF_DEVELOPER_MODE=ON ^
290-
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON ^
291-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON ^
292-
-DUMF_BUILD_CUDA_PROVIDER=ON ^
293-
-DUMF_TESTS_FAIL_ON_SKIP=ON
294-
295-
- name: Build UMF
296-
shell: cmd
297-
run: |
298-
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
299-
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
300-
cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS%
301-
302-
- name: Run tests
303-
shell: cmd
304-
working-directory: ${{env.BUILD_DIR}}
305-
run: |
306-
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
307-
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
308-
ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
270+
- name: Checkout
271+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
272+
with:
273+
fetch-depth: 0
274+
275+
- name: Restore vcpkg cache
276+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
277+
id: cache
278+
with:
279+
path: vcpkg_pkgs_cache.zip
280+
key: vcpkg-icx-${{matrix.os}}-${{ hashFiles('vcpkg.json') }}
281+
282+
- name: Unpack vcpkg cache
283+
if: steps.cache.outputs.cache-hit == 'true'
284+
run: |
285+
Expand-Archive -Path ${{github.workspace}}/vcpkg_pkgs_cache.zip -DestinationPath ${{env.BUILD_DIR}}/vcpkg -Force
286+
287+
- name: Initialize vcpkg
288+
if: steps.cache.outputs.cache-hit != 'true'
289+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
290+
with:
291+
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
292+
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
293+
vcpkgJsonGlob: '**/vcpkg.json'
294+
295+
- name: Install dependencies
296+
if: steps.cache.outputs.cache-hit != 'true'
297+
run: vcpkg install --triplet x64-windows
298+
299+
- name: Install Ninja
300+
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
301+
302+
- name: Download icx compiler
303+
env:
304+
# Link source: https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler-download.html
305+
CMPLR_LINK: "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/15a35578-2f9a-4f39-804b-3906e0a5f8fc/w_dpcpp-cpp-compiler_p_2024.2.1.83_offline.exe"
306+
run: |
307+
Invoke-WebRequest -Uri "${{ env.CMPLR_LINK }}" -OutFile compiler_install.exe
308+
309+
- name: Install icx compiler
310+
shell: cmd
311+
run: |
312+
start /b /wait .\compiler_install.exe -s -x -f extracted --log extract.log
313+
extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 ^
314+
-p=NEED_VS2019_INTEGRATION=0 -p=NEED_VS2022_INTEGRATION=0 --log-dir=.
315+
316+
- name: Configure build
317+
shell: cmd
318+
run: |
319+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
320+
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
321+
cmake ^
322+
-B ${{env.BUILD_DIR}} ^
323+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}" ^
324+
-DCMAKE_C_COMPILER=${{matrix.compiler.c}} ^
325+
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}} ^
326+
-G Ninja ^
327+
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}} ^
328+
-DUMF_FORMAT_CODE_STYLE=OFF ^
329+
-DUMF_DEVELOPER_MODE=ON ^
330+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON ^
331+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON ^
332+
-DUMF_BUILD_CUDA_PROVIDER=ON ^
333+
-DUMF_TESTS_FAIL_ON_SKIP=ON
334+
335+
- name: Build UMF
336+
shell: cmd
337+
run: |
338+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
339+
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
340+
cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS%
341+
342+
- name: Run tests
343+
shell: cmd
344+
working-directory: ${{env.BUILD_DIR}}
345+
run: |
346+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
347+
call "C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat"
348+
ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
349+
350+
- name: Prepare vcpkg cache
351+
if: steps.cache.outputs.cache-hit != 'true'
352+
run: |
353+
Compress-Archive -Path ${{env.BUILD_DIR}}/vcpkg/packages -DestinationPath ${{github.workspace}}/vcpkg_pkgs_cache.zip -Force -CompressionLevel Fastest
354+
355+
- name: Save vcpkg cache
356+
if: steps.cache.outputs.cache-hit != 'true'
357+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
358+
with:
359+
path: ${{github.workspace}}/vcpkg_pkgs_cache.zip
360+
key: ${{ steps.cache.outputs.cache-primary-key }}
309361

310362
# Scenarios where UMF_LINK_HWLOC_STATICALLY is set to OFF and hwloc is not installed in the system
311363
# The hwloc library is fetched implicitly

.github/workflows/reusable_basic.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,27 +311,40 @@ jobs:
311311
with:
312312
arch: x64
313313

314+
- name: Restore vcpkg cache
315+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
316+
id: cache
317+
with:
318+
path: vcpkg_pkgs_cache.zip
319+
key: vcpkg-basic-${{matrix.os}}-${{ hashFiles('vcpkg.json') }}
320+
321+
- name: Unpack vcpkg cache
322+
if: steps.cache.outputs.cache-hit == 'true'
323+
run: |
324+
Expand-Archive -Path ${{github.workspace}}/vcpkg_pkgs_cache.zip -DestinationPath ${{github.workspace}}/vcpkg -Force
325+
314326
- name: Initialize vcpkg
327+
if: steps.cache.outputs.cache-hit != 'true'
315328
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
316329
with:
317330
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
318331
vcpkgDirectory: ${{github.workspace}}/vcpkg
319332
vcpkgJsonGlob: '**/vcpkg.json'
320333

321-
# Install the dependencies and add the bin folders to the PATH for older
322-
# versions of CMake to correctly locate the libraries
323334
- name: Install dependencies
335+
if: steps.cache.outputs.cache-hit != 'true'
336+
run: vcpkg install --triplet x64-windows
337+
338+
# Older versions of CMake require this step to correctly locate dependencies
339+
- name: Add vcpkg bin dirs to PATH
324340
run: |
325-
vcpkg install --triplet x64-windows
326341
$env:Path = "${{env.VCPKG_PATH_BIN}};$env:Path"
327342
echo "PATH=$env:Path" >> $env:GITHUB_ENV
328-
shell: pwsh
329343
330344
- name: Get UMF version
331345
run: |
332346
$version = (git describe --tags --abbrev=0 | Select-String -Pattern '\d+\.\d+\.\d+').Matches.Value
333347
echo "UMF_VERSION=$version" >> $env:GITHUB_ENV
334-
shell: pwsh
335348
336349
- name: Configure build (Debug)
337350
run: >
@@ -442,6 +455,18 @@ jobs:
442455
run: ${{github.workspace}}/.github/scripts/check_dll_flags.ps1 ${{env.BUILD_RELEASE_DIR}}/src/proxy_lib/Release/umf_proxy.dll
443456
shell: pwsh
444457

458+
- name: Prepare vcpkg cache
459+
if: steps.cache.outputs.cache-hit != 'true'
460+
run: |
461+
Compress-Archive -Path ${{github.workspace}}/vcpkg/packages -DestinationPath ${{github.workspace}}/vcpkg_pkgs_cache.zip -Force -CompressionLevel Fastest
462+
463+
- name: Save vcpkg cache
464+
if: steps.cache.outputs.cache-hit != 'true'
465+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
466+
with:
467+
path: ${{github.workspace}}/vcpkg_pkgs_cache.zip
468+
key: ${{ steps.cache.outputs.cache-primary-key }}
469+
445470
windows-dynamic_build_hwloc:
446471
name: "Windows dynamic UMF + static hwloc"
447472
strategy:

.github/workflows/reusable_codeql.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,34 @@ jobs:
4545
with:
4646
languages: cpp
4747

48-
- name: "[Win] Initialize vcpkg"
48+
- name: "[Win] Restore vcpkg cache"
4949
if: matrix.os == 'windows-latest'
50+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
51+
id: cache
52+
with:
53+
path: vcpkg_pkgs_cache.zip
54+
key: vcpkg-codeql-${{matrix.os}}-${{ hashFiles('vcpkg.json') }}
55+
56+
- name: "[Win] Unpack vcpkg cache"
57+
if: matrix.os == 'windows-latest' && steps.cache.outputs.cache-hit == 'true'
58+
run: |
59+
Expand-Archive -Path ${{github.workspace}}/vcpkg_pkgs_cache.zip -DestinationPath ${{env.BUILD_DIR}}/vcpkg -Force
60+
61+
- name: "[Win] Initialize vcpkg"
62+
if: matrix.os == 'windows-latest' && steps.cache.outputs.cache-hit != 'true'
5063
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
5164
with:
5265
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
5366
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
5467
vcpkgJsonGlob: '**/vcpkg.json'
5568

56-
- name: "[Win] Install dependencies"
69+
- name: "[Win] Install vcpkg dependencies"
70+
if: matrix.os == 'windows-latest' && steps.cache.outputs.cache-hit != 'true'
71+
run: vcpkg install --triplet x64-windows
72+
73+
- name: "[Win] Install Python requirements"
5774
if: matrix.os == 'windows-latest'
58-
run: |
59-
vcpkg install --triplet x64-windows
60-
python3 -m pip install -r third_party/requirements.txt
75+
run: python3 -m pip install -r third_party/requirements.txt
6176

6277
- name: "[Lin] Install apt packages"
6378
if: matrix.os == 'ubuntu-latest'
@@ -93,3 +108,15 @@ jobs:
93108

94109
- name: Perform CodeQL Analysis
95110
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
111+
112+
- name: "[Win] Prepare vcpkg cache"
113+
if: matrix.os == 'windows-latest' && steps.cache.outputs.cache-hit != 'true'
114+
run: |
115+
Compress-Archive -Path ${{env.BUILD_DIR}}/vcpkg/packages -DestinationPath ${{github.workspace}}/vcpkg_pkgs_cache.zip -Force -CompressionLevel Fastest
116+
117+
- name: "[Win] Save vcpkg cache"
118+
if: matrix.os == 'windows-latest' && steps.cache.outputs.cache-hit != 'true'
119+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
120+
with:
121+
path: ${{github.workspace}}/vcpkg_pkgs_cache.zip
122+
key: ${{ steps.cache.outputs.cache-primary-key }}

.github/workflows/reusable_compatibility.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,20 @@ jobs:
136136
ref: refs/tags/${{inputs.tag}}
137137
path: ${{github.workspace}}/tag_version
138138

139+
- name: Restore vcpkg cache
140+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
141+
id: cache
142+
with:
143+
path: vcpkg_pkgs_cache.zip
144+
key: vcpkg-compat-windows-latest-${{ hashFiles('tag_version/vcpkg.json') }}
145+
146+
- name: Unpack vcpkg cache
147+
if: steps.cache.outputs.cache-hit == 'true'
148+
run: |
149+
Expand-Archive -Path ${{github.workspace}}/vcpkg_pkgs_cache.zip -DestinationPath ${{github.workspace}}/vcpkg -Force
150+
139151
- name: Initialize vcpkg
152+
if: steps.cache.outputs.cache-hit != 'true'
140153
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
141154
with:
142155
vcpkgGitCommitId: ea2a964f9303270322cf3f2d51c265ba146c422d # 1.04.2025
@@ -145,9 +158,9 @@ jobs:
145158

146159
# NOTE we use vcpkg setup from "tag" version
147160
- name: Install dependencies
161+
if: steps.cache.outputs.cache-hit != 'true'
148162
working-directory: ${{github.workspace}}/tag_version
149163
run: vcpkg install --triplet x64-windows
150-
shell: pwsh # Specifies PowerShell as the shell for running the script.
151164

152165
- name: Checkout latest UMF version
153166
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -254,6 +267,18 @@ jobs:
254267
}
255268
}
256269
270+
- name: Prepare vcpkg cache
271+
if: steps.cache.outputs.cache-hit != 'true'
272+
run: |
273+
Compress-Archive -Path ${{github.workspace}}/vcpkg/packages -DestinationPath ${{github.workspace}}/vcpkg_pkgs_cache.zip -Force -CompressionLevel Fastest
274+
275+
- name: Save vcpkg cache
276+
if: steps.cache.outputs.cache-hit != 'true'
277+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
278+
with:
279+
path: ${{github.workspace}}/vcpkg_pkgs_cache.zip
280+
key: ${{ steps.cache.outputs.cache-primary-key }}
281+
257282
gpu:
258283
name: GPU Ubuntu
259284
# run only on upstream; forks will not have the HW

0 commit comments

Comments
 (0)