Skip to content

Commit 51282d7

Browse files
committed
Reuse the restore step's cache key when saving CI venv caches
The save step recomputed the key via hashFiles('**/pyproject.toml', '**/preset.toml'), but by the time save runs every .venvs/ is already populated, so that glob walks all of site-packages too. hashFiles times out at 120s over that much content, and could pick up venv-internal files the restore step's key never saw — saving under a key no later run would ever match and restore from. Use steps.venvs_cache.outputs.cache-primary-key instead, the exact key the restore step already computed before any install happened.
1 parent d3c8566 commit 51282d7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,18 @@ jobs:
184184
# good cold install just because a later check or test failed. The only
185185
# precondition here is that the install itself succeeded; on an exact key match
186186
# there is nothing new to save.
187+
# The key is reused from the restore step, never recomputed: by now every .venvs/
188+
# is populated, so a `**/pyproject.toml` glob would walk all of site-packages
189+
# (hashFiles times out at 120s) and could hash venv-internal files the restore
190+
# key never saw, saving under a key no later run would ever restore.
187191
- name: Save venvs cache
188192
if: ${{ always() && steps.install.outcome == 'success' && steps.venvs_cache.outputs.cache-hit != 'true' }}
189193
uses: actions/cache/save@v5
190194
with:
191195
path: |
192196
.venvs
193197
**/.venvs
194-
key: ${{ runner.os }}-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml') }}
198+
key: ${{ steps.venvs_cache.outputs.cache-primary-key }}
195199

196200
audit-private:
197201
name: Audit (private layer)
@@ -326,12 +330,13 @@ jobs:
326330
shell: bash
327331

328332
# See the matching step in the `build` job for the rationale: save the venvs
329-
# whenever the install succeeded, even if a later check, audit or test failed.
333+
# whenever the install succeeded, even if a later check, audit or test failed,
334+
# and reuse the restore step's key rather than recomputing it.
330335
- name: Save venvs cache
331336
if: ${{ always() && env.HAS_PRIVATE_CLONE_APP == 'true' && steps.install.outcome == 'success' && steps.venvs_cache.outputs.cache-hit != 'true' }}
332337
uses: actions/cache/save@v5
333338
with:
334339
path: |
335340
.venvs
336341
**/.venvs
337-
key: ${{ runner.os }}-private-venvs-${{ hashFiles('**/pyproject.toml', '**/preset.toml', 'finecode-user.toml') }}
342+
key: ${{ steps.venvs_cache.outputs.cache-primary-key }}

0 commit comments

Comments
 (0)