From 4b652540243e76354bdda9b7ffeaefbb60f23b32 Mon Sep 17 00:00:00 2001 From: Marco Scardovi Date: Mon, 19 Oct 2026 14:35:36 +0200 Subject: [PATCH 1/2] ogc: linux-unstable: GCC ccache restore-only on PRs + cleanup Keep warm-ccache-master.yml as the only writer of the shared master seed. PR builds restore it without saving per-PR entries that burn the 10GB Actions quota, and delete leftover PR-scoped caches on close. Signed-off-by: Marco Scardovi --- .github/workflows/cleanup-pr-caches.yml | 51 ++++++++++++++++++++++++ .github/workflows/test-pr.yml | 8 +++- .github/workflows/warm-ccache-master.yml | 4 +- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cleanup-pr-caches.yml diff --git a/.github/workflows/cleanup-pr-caches.yml b/.github/workflows/cleanup-pr-caches.yml new file mode 100644 index 00000000000000..015c555704efbe --- /dev/null +++ b/.github/workflows/cleanup-pr-caches.yml @@ -0,0 +1,51 @@ +# Drop Actions caches scoped to a PR merge ref when the PR closes. +# Those entries cannot seed other PRs or master, but they still count +# against the repository 10GB cache quota. + +name: Cleanup PR Actions caches + +on: + pull_request: + types: [closed] + workflow_dispatch: + inputs: + pr_number: + description: "PR number whose refs/pull/N/merge caches to delete (empty = skip)" + required: false + type: string + +permissions: + actions: write + contents: read + +jobs: + cleanup: + name: Delete PR-scoped caches + runs-on: ubuntu-latest + steps: + - name: Delete caches for the PR merge ref + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number || inputs.pr_number }} + run: | + set -euo pipefail + if [ -z "${PR_NUMBER}" ]; then + echo "No PR number; nothing to delete." + exit 0 + fi + BRANCH="refs/pull/${PR_NUMBER}/merge" + echo "Listing caches for ${BRANCH}..." + # gh cache list --ref filters by the ref that created the cache. + mapfile -t IDS < <(gh cache list --ref "${BRANCH}" --limit 100 --json id --jq '.[].id') + if [ "${#IDS[@]}" -eq 0 ]; then + echo "No caches found for ${BRANCH}." + exit 0 + fi + echo "Deleting ${#IDS[@]} cache(s)..." + set +e + for id in "${IDS[@]}"; do + echo " gh cache delete ${id}" + gh cache delete "${id}" + done + echo "Done." diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 29c4e2fb8f2dbe..1f1957f36f6f1d 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -121,12 +121,16 @@ jobs: with: fetch-depth: 1 + # Restore-only: warm-ccache-master.yml is the sole writer of the shared + # GCC seed on master. Saving per-PR caches fills the 10GB Actions quota + # and those entries are invisible to other PRs anyway. - name: Restore compiler cache - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: /ccache - key: ccache-pr-gcc-${{ github.sha }} + key: ccache-pr-gcc-master-${{ github.sha }} restore-keys: | + ccache-pr-gcc-master- ccache-pr-gcc- - name: Assemble test config (same as the Arch release build) diff --git a/.github/workflows/warm-ccache-master.yml b/.github/workflows/warm-ccache-master.yml index c19e5cf5d8b56b..43ee8395070fc4 100644 --- a/.github/workflows/warm-ccache-master.yml +++ b/.github/workflows/warm-ccache-master.yml @@ -2,8 +2,8 @@ # # GitHub Actions scopes caches by branch: entries created on a PR merge ref # are invisible to other PRs. Entries created on master are visible to every -# PR. This workflow rebuilds with the same GCC + Arch/OGC config recipe as -# test-pr.yml and saves under the shared ccache-pr-gcc- prefix. +# PR. This workflow is the sole writer of the shared GCC seed +# (ccache-pr-gcc-master-*); test-pr.yml restores it but does not save. # # Triggers on every push to master so both human PR merges and the daily # linux-next sync (force-push) refresh the cache against the current tree. From a4b50b04147e2871df346a6ef541e0f0c23f1827 Mon Sep 17 00:00:00 2001 From: Marco Scardovi Date: Mon, 19 Oct 2026 15:52:30 +0200 Subject: [PATCH 2/2] ogc: linux-unstable: prune stale master GCC ccache seeds After a successful warm save, delete older ccache-pr-gcc-master-* Actions caches so immutable per-SHA keys do not fill the 10GB quota. Signed-off-by: Marco Scardovi --- .github/workflows/warm-ccache-master.yml | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/warm-ccache-master.yml b/.github/workflows/warm-ccache-master.yml index 43ee8395070fc4..1abf0f172d50fe 100644 --- a/.github/workflows/warm-ccache-master.yml +++ b/.github/workflows/warm-ccache-master.yml @@ -4,6 +4,8 @@ # are invisible to other PRs. Entries created on master are visible to every # PR. This workflow is the sole writer of the shared GCC seed # (ccache-pr-gcc-master-*); test-pr.yml restores it but does not save. +# After a successful save it deletes older ccache-pr-gcc-master-* entries +# so the ~10GB Actions quota is not filled with stale seeds. # # Triggers on every push to master so both human PR merges and the daily # linux-next sync (force-push) refresh the cache against the current tree. @@ -17,6 +19,7 @@ on: permissions: contents: read + actions: write concurrency: group: warm-ccache-master @@ -117,4 +120,38 @@ jobs: echo "- Cache key: \`ccache-pr-gcc-master-${{ github.sha }}\`" echo "- Shared with PR builds via restore-keys prefix \`ccache-pr-gcc-\`" echo "- Config: same as test-pr.yml GCC job (Arch headers + OGC fragments, Rust off)" + echo "- Older \`ccache-pr-gcc-master-*\` seeds are pruned after this job succeeds" } >> "$GITHUB_STEP_SUMMARY" + + # actions/cache saves in a post step after all job steps finish. A dependent + # job therefore runs only once the new seed is already uploaded. + prune-old-seeds: + name: Prune older master GCC ccache seeds + needs: warm + if: success() + runs-on: ubuntu-latest + steps: + - name: Delete older ccache-pr-gcc-master-* entries + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + KEEP_KEY: ccache-pr-gcc-master-${{ github.sha }} + run: | + set -euo pipefail + echo "Keeping ${KEEP_KEY}" + mapfile -t IDS < <( + gh cache list --key ccache-pr-gcc-master- --limit 100 \ + --json id,key --jq \ + '.[] | select(.key != env.KEEP_KEY) | .id' + ) + if [ "${#IDS[@]}" -eq 0 ]; then + echo "No older master GCC seeds to delete." + exit 0 + fi + echo "Deleting ${#IDS[@]} older seed(s)..." + set +e + for id in "${IDS[@]}"; do + echo " gh cache delete ${id}" + gh cache delete "${id}" + done + echo "Done."