[CI] Stop persisting Linux caches instead of caching the image

Measuring the follow-up showed the image half costs more than it frees:
the nine build images run 1.1 to 2.4 GB each on disk, about 5 to 6 GB of
cache quota for all of them once compressed, against the roughly 2.6 GB
the Linux ccache entries occupy. Persisting the image would push the
repository further over quota instead of under it, so these legs now
persist nothing: the image is rebuilt every run as before, and ccache
stays a throwaway dir shared only between the steps of one run.
This commit is contained in:
opencode 2026-10-14 21:38:18 +02:00
parent 66d067375e
commit 330818a5ac

View file

@ -168,7 +168,7 @@ jobs:
continue-on-error: ${{ matrix.allow-failure == 'yes' }} continue-on-error: ${{ matrix.allow-failure == 'yes' }}
timeout-minutes: 70 timeout-minutes: 70
env: env:
CACHE: ${{ github.workspace }}/.cache/${{ matrix.distro }}${{ matrix.version }}${{ matrix.variant }} # directory holding the build image and ccache, only the image subdir is cached below CACHE: ${{ github.workspace }}/.cache/${{ matrix.distro }}${{ matrix.version }}${{ matrix.variant }} # scratch dir for the container image build and throwaway ccache; nothing below is cached
CCACHE_EVICTION_AGE: 7d CCACHE_EVICTION_AGE: 7d
CCACHE_SIZE: 600M # space of all repo is 10Gi: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy CCACHE_SIZE: 600M # space of all repo is 10Gi: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
CMAKE_GENERATOR: 'Ninja' CMAKE_GENERATOR: 'Ninja'
@ -179,29 +179,16 @@ jobs:
- name: "Checkout" - name: "Checkout"
uses: actions/checkout@v7 uses: actions/checkout@v7
# Only the image half of this cache is worth keeping. A compile on these legs runs # Nothing on these legs is worth persisting. A compile here runs inside a
# inside a container, so ccache measures a 0.00 to 1.85 percent hit rate here against # container, so ccache measures a 0.00 to 1.85 percent hit rate against 49 to
# 49 to 50 percent on the macOS legs, and the roughly 420 MiB of ccache each entry # 50 percent on the macOS legs: persisting it spent a few hundred MiB per
# carried was buying nothing. Caching $CACHE/image alone drops that. # entry buying nothing. The build image is not an alternative: it runs 1.1 to
# The key changes name because the cached content does: the old ccache-<distro> # 2.4 GB per leg on disk, about 5 to 6 GB of quota for all nine legs once
# entries hold an image plus a ccache directory, and expire on their own untouched. # compressed, so caching it would cost more than dropping the ccache frees.
- name: "Restore build image cache" # The old ccache-<distro> entries are never read again and expire on their own.
id: restore_image_cache
uses: actions/cache/restore@v6
with:
key: image-${{ matrix.distro }}${{ matrix.version }}${{ matrix.variant }}-${{ hashFiles(format('.ci/{0}{1}/**', matrix.distro, matrix.version)) }}
path: ${{ env.CACHE }}/image
- name: "Build ${{ matrix.distro }} ${{ matrix.version }} Docker image" - name: "Build ${{ matrix.distro }} ${{ matrix.version }} Docker image"
shell: bash shell: bash
run: | run: source .ci/docker.sh --build
# --get/--save wire the $CACHE/image dir restored/saved above into the
# build: without them the image is rebuilt from scratch every run and
# the image cache saves nothing. Only persist on master; PR runs just
# reuse whatever the restore step found.
args=(--get --build)
[[ $GITHUB_REF == "refs/heads/master" ]] && args+=(--save)
source .ci/docker.sh "${args[@]}"
- name: "Build debug and test" - name: "Build debug and test"
if: matrix.test != 'skip' if: matrix.test != 'skip'
@ -263,25 +250,6 @@ jobs:
RUN --server --release --package "$package" "${args[@]}" RUN --server --release --package "$package" "${args[@]}"
# Delete used cache to emulate a cache update. See https://github.com/actions/cache/issues/342
- name: "[Linux] Delete used cache to emulate a cache update"
if: github.ref == 'refs/heads/master' && steps.restore_image_cache.outputs.cache-hit
continue-on-error: true
env:
CACHE_PRIMARY_KEY: ${{ steps.restore_image_cache.outputs.cache-primary-key }}
GH_TOKEN: ${{ github.token }}
run: |
if gh cache delete --repo "$GITHUB_REPOSITORY" "$CACHE_PRIMARY_KEY"; then
echo "Cache deleted successfully"
fi
- name: "Save updated build image cache"
if: github.ref == 'refs/heads/master'
uses: actions/cache/save@v6
with:
key: ${{ steps.restore_image_cache.outputs.cache-primary-key }}
path: ${{ env.CACHE }}/image
- name: "Upload artifact" - name: "Upload artifact"
id: upload_artifact id: upload_artifact
if: matrix.package != 'skip' if: matrix.package != 'skip'