Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an automated cache cleanup workflow to address GitHub Actions cache limit issues that have been causing PR failures. The workflow runs every 3 hours to delete caches older than 6 hours (configurable).
- Adds a scheduled GitHub Actions workflow for automatic cache cleanup
- Implements configurable cache expiration time with a 6-hour default
- Uses GitHub CLI and jq to filter and delete old cache entries
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.github/workflows/clearCaches.yml
Outdated
| GH_TOKEN: ${{ github.token }} | ||
| GH_REPO: ${{ github.repository }} | ||
| # Filter for caches last accessed older than the expiration time | ||
| jqStr: 'map(select((.lastAccessedAt | sub("\\.\\d+Z$"; "Z") | fromdateiso8601) < (now - ${{ env.CACHE_EXPIRATION_HOUR }} * 3600))) | .[].key' |
There was a problem hiding this comment.
[nitpick] The jq filter expression is complex and hard to read when embedded in the environment variable. Consider moving the jq expression inline or breaking it into multiple steps for better readability and maintainability.
Suggested change
| jqStr: 'map(select((.lastAccessedAt | sub("\\.\\d+Z$"; "Z") | fromdateiso8601) < (now - ${{ env.CACHE_EXPIRATION_HOUR }} * 3600))) | .[].key' | |
| # Filter for caches last accessed older than the expiration time | |
| EXPIRATION_SEC=$(( ${{ env.CACHE_EXPIRATION_HOUR }} * 3600 )) | |
| gh cache list --json key,lastAccessedAt \ | |
| | jq -r 'map(select((.lastAccessedAt | sub("\\.\\d+Z$"; "Z") | fromdateiso8601) < (now - '"$EXPIRATION_SEC"'))) | .[].key' \ | |
| | while read -r cache; do | |
| gh cache delete "$cache" | |
| done | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GH_REPO: ${{ github.repository }} |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
Author
|
Force merging this for now to fix builds, will action review comments post-merge |
Merged
seanbudd
added a commit
that referenced
this pull request
Aug 19, 2025
Fixup of #18751 Uses IDs rather than keys to more consistently delete caches
39 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Part of #17878
Summary of the issue:
PRs have been failing recently as we are well over our cache limit.
GitHub actions doesn't allow us to easily delete the caches of PR builds from within PRs, due to it being a cache poisoning risk.
Instead, we should clear caches manually on a regular basis.
Description of user facing changes:
None
Description of developer facing changes:
PRs more reliable
Description of development approach:
Testing strategy:
Tested locally from CLI
Known issues with pull request:
Code Review Checklist:
@coderabbitai summary