Never save partial vcpkg caches in CI

Replace the vcpkg-cache action, whose post step saves even when the job fails or is cancelled, with actions/cache/restore and a save step that only runs after a successful configure.
This commit is contained in:
Magne Sjaastad committed 2026-10-15 18:00:47 +02:00
1 parent c323846ec5
commit fc6dfb9697
4 files changed
+50 -15

No files matched your search

+12 -4
View File
@@ -166,16 +166,17 @@ jobs:
- name: Restore vcpkg cache
id: vcpkg-cache
uses: CeetronSolutions/vcpkg-cache@copilot/optimize-cache-storage-structure
# Restore only; saved after a successful Configure so partial caches are never written.
uses: actions/cache/restore@v6
with:
cache-key: ${{ runner.os }}-${{ matrix.arch }}-clang-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
prefix: vcpkg-clang/
path: ${{ github.workspace }}/.vcpkg-cache
key: vcpkg-${{ runner.os }}-${{ matrix.arch }}-clang-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
- name: Configure
shell: bash
env:
VCPKG_FEATURE_FLAGS: "binarycaching"
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite"
run: >
cmake -S . -B cmakebuild
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-osx-release
@@ -195,6 +196,13 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
-G Ninja
- name: Save vcpkg cache
if: success() && steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/.vcpkg-cache
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
- name: Build
run: |
cmake --build cmakebuild --target install
+16 -5
View File
@@ -258,11 +258,14 @@ jobs:
- name: Restore vcpkg cache
id: vcpkg-cache
uses: CeetronSolutions/vcpkg-cache@copilot/optimize-cache-storage-structure
# Restore only. The cache is saved by the "Save vcpkg cache" step after a
# successful Configure, so failed or cancelled jobs never write partial
# caches.
uses: actions/cache/restore@v6
with:
cache-key: ${{ runner.os }}-${{ matrix.config.cxx }}-${{ steps.image-version.outputs.version }}-${{ steps.compiler-hash.outputs.hash }}-${{ matrix.config.vcpkg-triplet }}-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
prefix: vcpkg-${{ matrix.config.cxx}}/
path: ${{ github.workspace }}/.vcpkg-cache
key: vcpkg-${{ runner.os }}-${{ matrix.config.cxx }}-${{ steps.image-version.outputs.version }}-${{ steps.compiler-hash.outputs.hash }}-${{ matrix.config.vcpkg-triplet }}-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
- name: Print CMake version
shell: bash
run: |
@@ -278,7 +281,7 @@ jobs:
shell: bash
env:
VCPKG_FEATURE_FLAGS: "binarycaching" # Possibly redundant, but explicitly sets the binary caching feature flag
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite"
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: >
@@ -299,6 +302,14 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
-G Ninja
- name: Save vcpkg cache
# Only after a fully successful Configure (all ports built)
if: success() && steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/.vcpkg-cache
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
- name: Build
run: |
cmake --build cmakebuild --target install
+11 -3
View File
@@ -48,15 +48,17 @@ jobs:
- name: Restore vcpkg cache
id: vcpkg-cache
uses: CeetronSolutions/vcpkg-cache@copilot/optimize-cache-storage-structure
# Restore only; saved after a successful configure so partial caches are never written.
uses: actions/cache/restore@v6
with:
cache-key: ${{ runner.os }}-clang-tidy-19-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
path: ${{ github.workspace }}/.vcpkg-cache
key: vcpkg-${{ runner.os }}-clang-tidy-19-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
- name: Create compile commands and run clang-tidy
# https://clang.llvm.org/extra/doxygen/run-clang-tidy_8py_source.html
env:
VCPKG_FEATURE_FLAGS: "binarycaching" # Possibly redundant, but explicitly sets the binary caching feature flag
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite"
run: |
mkdir build
cd build
@@ -70,6 +72,12 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake \
..
- name: Save vcpkg cache
if: success() && steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/.vcpkg-cache
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
- name: Run clang-tidy and apply fixes
continue-on-error: true
run: |
+11 -3
View File
@@ -56,14 +56,16 @@ jobs:
- name: Restore vcpkg cache
id: vcpkg-cache
uses: CeetronSolutions/vcpkg-cache@copilot/optimize-cache-storage-structure
# Restore only; saved after a successful configure so partial caches are never written.
uses: actions/cache/restore@v6
with:
cache-key: ${{ runner.os }}-clang-tidy-19-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
path: ${{ github.workspace }}/.vcpkg-cache
key: vcpkg-${{ runner.os }}-clang-tidy-19-${{ steps.vcpkg-sha.outputs.sha }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
- name: Create compile commands
env:
VCPKG_FEATURE_FLAGS: "binarycaching" # Possibly redundant, but explicitly sets the binary caching feature flag
VCPKG_BINARY_SOURCES: "clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite"
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite"
run: |
mkdir build
cd build
@@ -77,6 +79,12 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake \
..
- name: Save vcpkg cache
if: success() && steps.vcpkg-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ${{ github.workspace }}/.vcpkg-cache
key: ${{ steps.vcpkg-cache.outputs.cache-primary-key }}
- name: Run clazy (Qt checks, report only)
continue-on-error: true
run: |