Skip to content

Conversation

@akien-mga
Copy link
Member

This is pretty much copied from the GitHub Actions documentation: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

To test this properly, it needs to be merge so that it's active, and then we should monitor what happens when merging PRs. I've tested this in a non-Godot repo and it works fine there, but the cache setup is slightly different.

Related to #104076 but can be merged independently.

Copy link
Contributor

@Repiteo Repiteo left a comment

Choose a reason for hiding this comment

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

You'd think they'd automate this, because PR caches cannot be reused by anything at that point. Oh well!

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

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

Hard to confirm on its own but I trust the GitHub docs on this

BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge
run: |
echo "Fetching list of cache key"
cache_keys_for_pr=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this deletes only up to 100 caches (that's what the docs example does).

After #104076 we should only have a single cache key pattern per PR, so maybe around 20 caches totally from all our jobs, so it should be fine.

Currently this might not even include all caches in a PR where e.g. a commit was amended 10 times, which would have around 200 unique caches. The rest would be culled after 7 days.

Copy link
Member Author

Choose a reason for hiding this comment

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

So since #104076 isn't going to work, maybe we need to reconsider how many caches we want to query here, as we might have multiple hundreds in a lot of PRs.

Copy link
Member

@AThousandShips AThousandShips Mar 13, 2025

Choose a reason for hiding this comment

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

100 caches would be a bit over 5 runs of a PR, that's not an unreasonable case, 200 would be pretty sufficient I'd say, that's 10 recent runs

Note also that a significant portion of PRs are merged when they have no caches around, or at most one set likely, the general retention for caches with the pressure we have is about a day, essentially always no older than two days (never seen a cache on the repo that old AFAIK)

So only cases where a PR is amended repeatedly shortly before (within 24 hours) being merged would we need to worry about that I'd say (I occasionally go through and check for old caches that are for merged PRs and there often aren't any/many)

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked quickly some recent PRs that had multiple commits today and they all have only 19 caches. So it sounds like previous caches already get dropped somehow, maybe because we're already at such a saturated level that they quickly get garbage collected.

We can reassess after we've reduced our cache congestion further to see if it needs to be increased.

Copy link
Member

Choose a reason for hiding this comment

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

PRs that were merged recently?

Copy link
Member Author

Choose a reason for hiding this comment

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

No some that are still open and had multiple commits today, e.g. the Traits PR.

@akien-mga akien-mga modified the milestones: 4.x, 4.5 Mar 13, 2025
@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Mar 13, 2025
@AThousandShips
Copy link
Member

The one area where this would be annoying would be where PRs are closed due to other reasons, for example a rebase error, but that seems rare enough not to be an issue

@akien-mga akien-mga merged commit de7756d into godotengine:master Mar 13, 2025
20 checks passed
@akien-mga akien-mga deleted the ci-cache-cleanup-on-pr-close branch March 13, 2025 23:14
@AThousandShips
Copy link
Member

@akien-mga
Copy link
Member Author

That's weird, the config on this repo is:

image

And I don't see us limiting permissions in the yaml.

@AThousandShips
Copy link
Member

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants