Skip to content

Commit 4335e7b

Browse files
author
arman-bd
committed
fix: split cache into separate restore and save actions for save-always support
1 parent ff565ea commit 4335e7b

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

.github/workflows/_test.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,20 @@ jobs:
108108
echo "CXX=ccache g++" >> $GITHUB_ENV
109109
shell: bash
110110

111-
- name: Cache vcpkg packages (Windows)
111+
- name: Restore vcpkg cache (Windows)
112112
if: runner.os == 'Windows'
113-
id: cache-vcpkg
114-
uses: actions/cache@v4
113+
id: cache-vcpkg-restore
114+
uses: actions/cache/restore@v4
115115
with:
116116
path: |
117117
C:/vcpkg/installed
118118
C:/vcpkg/packages
119119
key: vcpkg-nghttp2-zlib-${{ runner.os }}-v3
120120
restore-keys: |
121121
vcpkg-nghttp2-zlib-${{ runner.os }}-
122-
save-always: true
123122
124123
- name: Setup vcpkg (Windows)
125-
if: runner.os == 'Windows' && steps.cache-vcpkg.outputs.cache-hit != 'true'
124+
if: runner.os == 'Windows' && steps.cache-vcpkg-restore.outputs.cache-hit != 'true'
126125
run: |
127126
# Use pre-installed vcpkg on GitHub runners
128127
if [ -d "C:/vcpkg" ]; then
@@ -140,7 +139,7 @@ jobs:
140139
shell: bash
141140

142141
- name: Install dependencies via vcpkg (Windows)
143-
if: runner.os == 'Windows' && steps.cache-vcpkg.outputs.cache-hit != 'true'
142+
if: runner.os == 'Windows' && steps.cache-vcpkg-restore.outputs.cache-hit != 'true'
144143
run: |
145144
export VCPKG_ROOT="C:/vcpkg"
146145
export PATH="$VCPKG_ROOT:$PATH"
@@ -154,15 +153,14 @@ jobs:
154153
echo "C:/vcpkg" >> $GITHUB_PATH
155154
shell: bash
156155

157-
- name: Cache vendor dependencies
156+
- name: Restore vendor cache
158157
id: cache-vendor
159-
uses: actions/cache@v4
158+
uses: actions/cache/restore@v4
160159
with:
161160
path: vendor
162161
key: vendor-${{ runner.os }}-${{ hashFiles('scripts/setup_vendors.sh') }}-v7
163162
restore-keys: |
164163
vendor-${{ runner.os }}-
165-
save-always: true
166164
167165
- name: Setup vendor dependencies
168166
if: steps.cache-vendor.outputs.cache-hit != 'true'
@@ -178,16 +176,16 @@ jobs:
178176
du -sh vendor/ 2>/dev/null || echo "Cannot get vendor size"
179177
shell: bash
180178

181-
- name: Cache Python build artifacts
182-
uses: actions/cache@v4
179+
- name: Restore Python build cache
180+
id: cache-python-build
181+
uses: actions/cache/restore@v4
183182
with:
184183
path: |
185184
build/
186185
*.egg-info/
187186
key: python-build-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'pyproject.toml', 'src/**/*.c', 'src/**/*.cpp', 'src/**/*.h') }}
188187
restore-keys: |
189188
python-build-${{ runner.os }}-${{ matrix.python-version }}-
190-
save-always: true
191189
192190
- name: Install package
193191
run: pip install -e ".[dev]"
@@ -213,3 +211,29 @@ jobs:
213211
file: ./coverage.xml
214212
token: ${{ secrets.CODECOV_TOKEN }}
215213
fail_ci_if_error: false
214+
215+
# Save caches even if tests fail (using always())
216+
- name: Save vcpkg cache (Windows)
217+
if: always() && runner.os == 'Windows' && steps.cache-vcpkg-restore.outputs.cache-hit != 'true'
218+
uses: actions/cache/save@v4
219+
with:
220+
path: |
221+
C:/vcpkg/installed
222+
C:/vcpkg/packages
223+
key: vcpkg-nghttp2-zlib-${{ runner.os }}-v3
224+
225+
- name: Save vendor cache
226+
if: always() && steps.cache-vendor.outputs.cache-hit != 'true'
227+
uses: actions/cache/save@v4
228+
with:
229+
path: vendor
230+
key: vendor-${{ runner.os }}-${{ hashFiles('scripts/setup_vendors.sh') }}-v7
231+
232+
- name: Save Python build cache
233+
if: always()
234+
uses: actions/cache/save@v4
235+
with:
236+
path: |
237+
build/
238+
*.egg-info/
239+
key: python-build-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'pyproject.toml', 'src/**/*.c', 'src/**/*.cpp', 'src/**/*.h') }}

0 commit comments

Comments
 (0)