ci(sonar-cloud): warm PR builds via a Linux-gradle-main- baseline cache [NO-JIRA]#303
Merged
Merged
Conversation
…anch builds [NO-JIRA] GitHub/runs-on caches are branch-scoped: a run can only restore caches from its own ref + the default branch (main). The Kotlin PR test workflow (#298) never runs on main, so no Linux-gradle-* cache exists there, and its Linux-gradle- fallback can't reach sibling PR caches -> every fresh branch's first build is cold (~3-4m recompile). sonar-cloud.yml already compiles + tests on main (code-analysis on push:main). Have it save ~/.gradle under Linux-gradle-main-<sha> (split restore/save, replacing setup-java's frozen cache:'gradle'). That sits on refs/heads/main = default branch, so the PR test workflow's existing Linux-gradle- fallback matches it -> fresh PR branches start warm. No change to pull-request-kotlin.yml needed. Save is guarded to refs/heads/main so a PR-context run can't poison the baseline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
joscdk
approved these changes
Jun 5, 2026
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.
What
Make the main analysis build publish a
Linux-gradle-main-<sha>cache, so the Kotlin PR test workflow's fresh-branch builds start warm.Why
pull-request-kotlin.yml(#298) caches~/.gradleper-branch with a…-gradle-fallback — but GitHub/runs-on caches are branch-scoped: a run can only restore caches from its own ref + the default branch (main). Sibling PR caches are invisible, and the PR test workflow never runs on main, so there's noLinux-gradle-*cache on main to fall back to → every fresh branch's first build is cold (~3–4m recompile). (Confirmed from the cache list: allLinux-gradle-*entries sit onrefs/pull/*/ branch refs, none onrefs/heads/main.)How
sonar-cloud.ymlalready compiles + tests on main (code-analysis.ymlonpush: main). Give it the #298 split-cache treatment:setup-java's frozencache: 'gradle'withactions/cache/restore(key: …-gradle-main-<sha>, restore-key…-gradle-main-).actions/cache/save…-gradle-main-<sha>at the end.That cache lands on
refs/heads/main(default branch) → the PR test workflow's existing…-gradle-fallback matches it → fresh PR branches start warm. No change topull-request-kotlin.ymlneeded.Safety: the save is guarded
github.ref == 'refs/heads/main', so a PR-context run of this workflow can never write (poison) the trusted main baseline.Scope
~/.sonar/cachestep as-is (separate, small).Canary plan
On
service-feature: merge → main runscode-analysis(seedsLinux-gradle-main-), then open a fresh PR and confirm its first build restores the main cache and compilesFROM-CACHE(vs today's ~3–4m cold).🤖 Generated with Claude Code