Skip to content

ci(sonar-cloud): warm PR builds via a Linux-gradle-main- baseline cache [NO-JIRA]#303

Merged
JesperTerkelsen merged 1 commit into
mainfrom
ci/sonar-warm-gradle-main-cache
Jun 5, 2026
Merged

ci(sonar-cloud): warm PR builds via a Linux-gradle-main- baseline cache [NO-JIRA]#303
JesperTerkelsen merged 1 commit into
mainfrom
ci/sonar-warm-gradle-main-cache

Conversation

@JesperTerkelsen

Copy link
Copy Markdown
Member

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 ~/.gradle per-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 no Linux-gradle-* cache on main to fall back to → every fresh branch's first build is cold (~3–4m recompile). (Confirmed from the cache list: all Linux-gradle-* entries sit on refs/pull/* / branch refs, none on refs/heads/main.)

How

sonar-cloud.yml already compiles + tests on main (code-analysis.yml on push: main). Give it the #298 split-cache treatment:

  • Replace setup-java's frozen cache: 'gradle' with actions/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 to pull-request-kotlin.yml needed.

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

Canary plan

On service-feature: merge → main runs code-analysis (seeds Linux-gradle-main-), then open a fresh PR and confirm its first build restores the main cache and compiles FROM-CACHE (vs today's ~3–4m cold).

🤖 Generated with Claude Code

…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>
@JesperTerkelsen JesperTerkelsen marked this pull request as ready for review June 5, 2026 07:11
@JesperTerkelsen JesperTerkelsen requested a review from a team as a code owner June 5, 2026 07:11
@JesperTerkelsen JesperTerkelsen requested review from maoanran and removed request for a team June 5, 2026 07:11
@JesperTerkelsen JesperTerkelsen merged commit 5dd4fd5 into main Jun 5, 2026
1 check passed
@JesperTerkelsen JesperTerkelsen deleted the ci/sonar-warm-gradle-main-cache branch June 5, 2026 07:33
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