github: prevent pull requests from saving ccache #382
Merged
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.
Pull request builds were creating their own ccache entries in GitHub's cache storage, leading to cache bloat and potentially filling the cache quota with ephemeral data from feature branches that will never be reused.
Use actions/cache/restore (read-only) for pull request workflows to restore the main branch cache without saving new entries. Only main branch builds use actions/cache (read-write) to update the canonical cache that all subsequent builds can benefit from.
This ensures pull requests still get the performance benefit of the cached main branch build artifacts while preventing them from polluting the cache with their own entries that would only be useful if the exact same PR builds again with the same git ref.
Additionally, remove the overly broad fallback restore-keys that would match any ref. The main branch cache is sufficient for warming the cache. Also switch from ccache -sv to ccache -z to reset statistics at the start of each build for clearer per-build metrics.
Summary by CodeRabbit