Skip to content

Commit fc53190

Browse files
Copilotjohnpatek
andauthored
fix: only write vcpkg cache on dependency and toolset changes (#16)
* Initial plan * fix: only save vcpkg cache when binary contents have changed Co-authored-by: johnpatek <31934875+johnpatek@users.noreply.github.com> Agent-Logs-Url: https://github.com/maxtek6/WebFrame/sessions/119ad140-61dd-47ae-b1a1-bf9d9daaf024 * fix: use jq hash of deps+vcpkg ref for precise cache keying Co-authored-by: johnpatek <31934875+johnpatek@users.noreply.github.com> Agent-Logs-Url: https://github.com/maxtek6/WebFrame/sessions/fb217989-1474-4e1b-9ac5-e89043f9f671 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: johnpatek <31934875+johnpatek@users.noreply.github.com>
1 parent 30a927c commit fc53190

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

.github/workflows/main.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ permissions:
77
contents: write
88
packages: write
99

10+
env:
11+
VCPKG_REF: '2026.01.16'
12+
1013
jobs:
1114
test:
1215
name: Unit Tests
@@ -20,7 +23,7 @@ jobs:
2023
with:
2124
repository: microsoft/vcpkg
2225
path: vcpkg
23-
ref: '2026.01.16'
26+
ref: ${{ env.VCPKG_REF }}
2427

2528
- name: Checkout code
2629
uses: actions/checkout@v6
@@ -29,12 +32,20 @@ jobs:
2932
path: WebFrame
3033
ref: ${{ github.ref }}
3134

35+
- name: Compute vcpkg cache hash
36+
id: vcpkg-hash
37+
shell: bash
38+
run: |
39+
hash=$(jq -cj '{features,dependencies}' WebFrame/vcpkg.json | cat - WebFrame/vcpkg-configuration.json | sha256sum | awk '{print $1}')
40+
echo "value=${hash}" >> $GITHUB_OUTPUT
41+
3242
- name: "Restore VCPKG cache"
43+
id: restore-test-cache
3344
uses: actions/cache/restore@v4
3445
with:
3546
path: ${{ github.workspace }}/vcpkg-test-cache
36-
key: vcpkg-test-cache-${{ github.run_id }}
37-
restore-keys: vcpkg-test-cache
47+
key: vcpkg-test-cache-${{ env.VCPKG_REF }}-${{ steps.vcpkg-hash.outputs.value }}
48+
restore-keys: vcpkg-test-cache-${{ env.VCPKG_REF }}
3849

3950
- name: CMake Build
4051
run: |
@@ -44,10 +55,11 @@ jobs:
4455
make test
4556
4657
- name: "Save VCPKG cache"
58+
if: steps.restore-test-cache.outputs.cache-hit != 'true'
4759
uses: actions/cache/save@v4
4860
with:
4961
path: ${{ github.workspace }}/vcpkg-test-cache
50-
key: vcpkg-test-cache-${{ github.run_id }}
62+
key: vcpkg-test-cache-${{ env.VCPKG_REF }}-${{ steps.vcpkg-hash.outputs.value }}
5163

5264
build:
5365
needs: test
@@ -66,7 +78,7 @@ jobs:
6678
with:
6779
repository: microsoft/vcpkg
6880
path: vcpkg
69-
ref: '2026.01.16'
81+
ref: ${{ env.VCPKG_REF }}
7082

7183
- name: Checkout code
7284
uses: actions/checkout@v6
@@ -75,12 +87,20 @@ jobs:
7587
path: WebFrame
7688
ref: ${{ github.ref }}
7789

90+
- name: Compute vcpkg cache hash
91+
id: vcpkg-hash
92+
shell: bash
93+
run: |
94+
hash=$(jq -cj '{features,dependencies}' WebFrame/vcpkg.json | cat - WebFrame/vcpkg-configuration.json | sha256sum | awk '{print $1}')
95+
echo "value=${hash}" >> $GITHUB_OUTPUT
96+
7897
- name: "Restore VCPKG cache"
98+
id: restore-build-cache
7999
uses: actions/cache/restore@v5
80100
with:
81101
path: ${{ github.workspace }}/vcpkg-${{ matrix.os }}
82-
key: vcpkg-${{ matrix.os }}-${{ github.run_id }}
83-
restore-keys: vcpkg-${{ matrix.os }}
102+
key: vcpkg-${{ matrix.os }}-${{ env.VCPKG_REF }}-${{ steps.vcpkg-hash.outputs.value }}
103+
restore-keys: vcpkg-${{ matrix.os }}-${{ env.VCPKG_REF }}
84104

85105
- name: Ubuntu setup
86106
if: matrix.os == 'ubuntu-latest'
@@ -96,7 +116,8 @@ jobs:
96116
cmake --build build
97117
98118
- name: "Save VCPKG cache"
119+
if: steps.restore-build-cache.outputs.cache-hit != 'true'
99120
uses: actions/cache/save@v5
100121
with:
101122
path: ${{ github.workspace }}/vcpkg-${{ matrix.os }}
102-
key: vcpkg-${{ matrix.os }}-${{ github.run_id }}
123+
key: vcpkg-${{ matrix.os }}-${{ env.VCPKG_REF }}-${{ steps.vcpkg-hash.outputs.value }}

0 commit comments

Comments
 (0)