Skip to content

fix(ci): stable SonarQube scanner cache key for PRs [NOJIRA]#308

Open
tobias0106 wants to merge 2 commits into
mainfrom
chore/stable-sonar-cache-key
Open

fix(ci): stable SonarQube scanner cache key for PRs [NOJIRA]#308
tobias0106 wants to merge 2 commits into
mainfrom
chore/stable-sonar-cache-key

Conversation

@tobias0106

Copy link
Copy Markdown
Contributor

Problem

pull-request-kotlin.yml caches ~/.sonar/cache with key ${{ runner.os }}-sonar-${{ github.head_ref }}-${{ github.sha }} and restore-key ${{ runner.os }}-sonar-.

  • The branch+sha key means every commit on every PR is a fresh key → miss.
  • The restore-key …-sonar- (trailing dash) never matches the main-branch cache saved by sonar-cloud.yml, which uses ${{ runner.os }}-sonar (no dash).
  • PR-only caches aren't shared across branches, so there's nothing to fall back to.

Net: every PR re-downloads the scanner JRE + analyzer plugins — adds minutes, and is the source of the intermittent Call to .../api/v2/analysis/jres/… failed: stream was reset failures.

Fix

Align the PR workflow to the same stable ${{ runner.os }}-sonar key that sonar-cloud.yml (main-branch) already uses, so PRs restore the warm cache populated on main. (Cache is immutable per key, so the save no-ops when the hit is from main; it self-refreshes on the 7-day eviction cycle.)

Fixes the cache miss seen across the Kotlin fleet (e.g. service-wallet PRs).

Follow-up (separate, discussed)

-Dsonar.scanner.skipJreProvisioning=true to skip the JRE download entirely (runners already have Corretto JDK) — bigger reliability win, will propose separately.

🤖 Generated with Claude Code

tobias0106 and others added 2 commits June 10, 2026 15:07
pull-request-kotlin.yml keyed the ~/.sonar/cache on
`${os}-sonar-${head_ref}-${sha}` with restore-key `${os}-sonar-`. That never
matches the main-branch cache saved by sonar-cloud.yml (`${os}-sonar`, no
trailing dash), and PR-only caches aren't shared across branches — so every PR
missed and re-downloaded the scanner JRE + analyzer plugins (~minutes, and the
source of the intermittent "stream was reset" JRE-download failures).

Align the PR workflow to the same stable `${os}-sonar` key so PRs restore the
warm cache populated by the main-branch scan.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Removed comments explaining the cache key for Sonar.
@tobias0106 tobias0106 marked this pull request as ready for review June 10, 2026 13:55
@tobias0106 tobias0106 requested a review from a team as a code owner June 10, 2026 13:55
@tobias0106 tobias0106 requested review from prasad-manu and removed request for a team June 10, 2026 13:55

@morten-andersen morten-andersen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice catch

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