From fc46cbc4fb58060bff6c7d0962d5e98249b079b2 Mon Sep 17 00:00:00 2001 From: Andrei Gherzan Date: Sun, 18 Oct 2026 20:47:22 +0100 Subject: [PATCH] ci: prune unused sstate weekly Nothing removes artifacts from the runner's SSTATE_DIR, so it grows without bound. Delete sstate files not touched in 30 days. bitbake touches sstate files whenever a build checks or unpacks them, so mtime tracks last use across all branches. DL_DIR is not pruned. Download stamps are only touched by do_fetch, which sstate-restored recipes skip, so their age doesn't reflect whether a rebuild would need them. Signed-off-by: Andrei Gherzan --- .github/workflows/prune-caches.yml | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/prune-caches.yml diff --git a/.github/workflows/prune-caches.yml b/.github/workflows/prune-caches.yml new file mode 100644 index 0000000..ba8c50a --- /dev/null +++ b/.github/workflows/prune-caches.yml @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: Andrei Gherzan +# +# SPDX-License-Identifier: MIT + +--- + +name: Prune caches + +on: + schedule: + - cron: "0 3 * * 0" + workflow_dispatch: + +concurrency: + group: prune-caches + +jobs: + sstate: + name: Prune unused sstate + runs-on: [self-hosted, Linux] + env: + DL_DIR: /var/lib/ci/yocto/downloads + SSTATE_DIR: /var/lib/ci/yocto/sstate + SSTATE_MAX_AGE_DAYS: 30 + steps: + - name: Prune sstate not used in ${{ env.SSTATE_MAX_AGE_DAYS }} days + # bitbake touches sstate files whenever a build uses them, so mtime is + # a reliable last-use time. + run: | + du -sh "$DL_DIR" "$SSTATE_DIR" + find "$SSTATE_DIR" -type f -name 'sstate:*' \ + -mtime +"$SSTATE_MAX_AGE_DAYS" -delete + find "$SSTATE_DIR" -mindepth 1 -type d -empty -delete + du -sh "$SSTATE_DIR"