Skip to content

BUILD-10739 Cache cleanup: key-only delete + job summary#44

Merged
mikolaj-matuszny-ext-sonarsource merged 1 commit intomasterfrom
feat/mmatuszny/BUILD-10739-cache-cleanup-v3
Mar 18, 2026
Merged

BUILD-10739 Cache cleanup: key-only delete + job summary#44
mikolaj-matuszny-ext-sonarsource merged 1 commit intomasterfrom
feat/mmatuszny/BUILD-10739-cache-cleanup-v3

Conversation

@mikolaj-matuszny-ext-sonarsource
Copy link
Contributor

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource commented Mar 18, 2026

Summary

Two additions to the cache cleanup script:

  • Delete by key across all branches: Providing only key (no branch) now enters delete mode instead of list-only. List mode only activates when both branch and key are empty.
  • GitHub Actions job summary: Writes a markdown summary to $GITHUB_STEP_SUMMARY with a collapsible <details> table of matched objects. Works in list, dry-run, and delete modes. No-op when running locally.

Updated modes of operation

Scenario Branch Key Dry-run
List all cache entries (empty) (empty) n/a
Preview what would be deleted feature/my-branch (optional) true
Delete cache for a branch feature/my-branch (optional) false
Delete key across all branches (empty) sccache-Linux- false

Test plan

  • Test list mode locally (no branch, no key) - still works
  • Test key-only delete with dry-run
  • Verify GITHUB_STEP_SUMMARY renders correctly in Actions UI (collapsible table)
  • Verify script works locally without GITHUB_STEP_SUMMARY set

🤖 Generated with Claude Code

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource marked this pull request as ready for review March 18, 2026 14:58
@sonar-review-alpha
Copy link

sonar-review-alpha bot commented Mar 18, 2026

Summary

This PR adds two features to the cache cleanup script:

  1. Key-only deletion — the script now supports deleting a cache key across all branches. The list/delete mode logic changed: list mode only activates when both branch and key are empty; providing just a key now triggers delete mode. This enables cleanup scenarios like "delete all sccache-Linux-* across the entire repo."

  2. GitHub Actions job summary — a new write_summary() function writes markdown output to $GITHUB_STEP_SUMMARY with object count, total size, and a collapsible table of matched keys. It writes in all three modes (list, dry-run, delete) and safely no-ops when running locally.

Supporting changes: refactored object row extraction into a shared extract_rows() helper to avoid duplicating the jq transform between table output and the summary.

What reviewers should know

Start with: the mode detection logic change at line 175 — this is the crux. Compare the old [[ -z "$INPUT_BRANCH" ]] check against the new [[ -z "$INPUT_BRANCH" && -z "$KEY_PATTERN" ]] to understand the three-way branch/key/both logic.

Watch for: the extract_rows() refactor. It's now the single source of truth for turning S3 object JSON into TSV rows — verify it's called correctly by both print_table() and write_summary(), and that TSV field order (size, date, key) matches expectations in both consumers.

GitHub Actions integration: write_summary() only writes if $GITHUB_STEP_SUMMARY exists (safe locally). Review the markdown table format — it needs to render cleanly in the Actions UI with the collapsible <details> wrapper.

Test the boundary cases:

  • Empty branch + empty key → list mode (unchanged behavior)
  • Empty branch + key-only → delete mode across all branches (new)
  • Branch + empty key → delete for that branch (unchanged)
  • All three should produce job summaries in Actions

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource changed the title BUILD-10739 Cache cleanup - support deleting all keys accross branche… BUILD-10739 Cache cleanup: review feedback + key-only delete + job summary Mar 18, 2026
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource changed the title BUILD-10739 Cache cleanup: review feedback + key-only delete + job summary BUILD-10739 Cache cleanup: key-only delete + job summary Mar 18, 2026
Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conclusion: The feature logic and mode-switching are correct, but write_summary has a formatting bug that will surface immediately in any real run, and it duplicates extraction logic from print_table in a way that will cause silent drift over time.

🗣️ Give feedback

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource force-pushed the feat/mmatuszny/BUILD-10739-cache-cleanup-v3 branch from 3dde4e0 to 91d9cee Compare March 18, 2026 15:20
@sonarqube-cloud-us
Copy link

@sonarqubecloud
Copy link

Copy link

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

🗣️ Give feedback

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource merged commit 7b57f01 into master Mar 18, 2026
14 checks passed
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource deleted the feat/mmatuszny/BUILD-10739-cache-cleanup-v3 branch March 18, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants