Skip to content

Commit e7ff41f

Browse files
committed
ci: include runner image version in cache key for cache-apt-pkgs-action
1 parent 47ac762 commit e7ff41f

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

.github/actions/setup-build/action.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ runs:
269269
echo "DISTNAME=form-$(./scripts/git-version-gen.sh -r | sed '2q;d' | sed 's/^v//')" >>"$GITHUB_ENV"
270270
fi
271271
272+
# Get cache key for the image ###
273+
274+
# See: https://github.com/actions/upload-artifact/issues/231
275+
echo "image_key=$ImageOS-$ImageVersion" >>"$GITHUB_OUTPUT"
276+
272277
- name: Install dependencies (Ubuntu)
273278
if: runner.os == 'Linux' && steps.setup.outputs.container == 'false'
274279
uses: awalsh128/cache-apt-pkgs-action@a605dbde2ac49a823c9c87ad58491b51848bf355 # for empty_packages_behavior
@@ -281,7 +286,9 @@ runs:
281286
${{ steps.setup.outputs.mpfr == 'true' && 'libmpfr-dev' || '' }}
282287
${{ steps.setup.outputs.zstd == 'true' && 'libzstd-dev' || '' }}
283288
${{ steps.setup.outputs.valgrind == 'true' && 'valgrind' || '' }}
284-
version: 1.0
289+
# Include the runner image version in the cache key to avoid using stale cache.
290+
# See: https://github.com/awalsh128/cache-apt-pkgs-action/issues/187
291+
version: ${{ steps.setup.outputs.image_key }}-1.0
285292
empty_packages_behavior: ignore
286293

287294
# awalsh128/cache-apt-pkgs-action does not work for MPI.
@@ -440,16 +447,6 @@ runs:
440447
${{ steps.setup.outputs.zlib == 'true' && 'mingw-w64-clang-aarch64-zlib' || '' }}
441448
${{ steps.setup.outputs.zstd == 'true' && 'mingw-w64-clang-aarch64-zstd' || '' }}
442449
443-
- name: Get cache key for the image
444-
id: cache_key
445-
if: steps.setup.outputs.build_flint == 'true'
446-
shell: ${{ steps.setup.outputs.msys2 == 'true' && 'msys2 {0}' || 'bash' }}
447-
run: |
448-
### Get cache key for the image ###
449-
450-
# See: https://github.com/actions/upload-artifact/issues/231
451-
echo "image_key=$ImageOS-$ImageVersion" >>"$GITHUB_OUTPUT"
452-
453450
- name: Cache FLINT
454451
id: cache-flint
455452
if: steps.setup.outputs.build_flint == 'true'
@@ -458,7 +455,7 @@ runs:
458455
path: lib/flint
459456
# Here, we set a conservative cache key so that the cache is not reused
460457
# when the version or environment changes even slightly.
461-
key: flint-${{ inputs.flint_version }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.cache_key.outputs.image_key }}
458+
key: flint-${{ inputs.flint_version }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.setup.outputs.image_key }}
462459

463460
# Note that we always set --enable-static so that release and non-release
464461
# builds can share the same cache.

0 commit comments

Comments
 (0)