Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/cleanup-pr-caches.yml
Original file line number Diff line number Diff line change
@@ -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."
8 changes: 6 additions & 2 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 39 additions & 2 deletions .github/workflows/warm-ccache-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#
# 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.
# 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.
Expand All @@ -17,6 +19,7 @@ on:

permissions:
contents: read
actions: write

concurrency:
group: warm-ccache-master
Expand Down Expand Up @@ -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."
Loading