Skip to content

SONARJAVA-6253 Ensure integration tests do not share cache#5568

Merged
alban-auzeill merged 3 commits intomasterfrom
tt/its-cache-hack
Apr 16, 2026
Merged

SONARJAVA-6253 Ensure integration tests do not share cache#5568
alban-auzeill merged 3 commits intomasterfrom
tt/its-cache-hack

Conversation

@tomasz-tylenda-sonarsource
Copy link
Copy Markdown
Contributor

@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource commented Apr 13, 2026

Use separate caches for plugin, ruling, and other ITs. See SONARJAVA-6253 for details.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod bot changed the title Ensure ITs jobs do not share cache SONARJAVA-6253 Ensure ITs jobs do not share cache Apr 13, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown
Contributor

hashicorp-vault-sonar-prod bot commented Apr 13, 2026

SONARJAVA-6253

@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource force-pushed the tt/its-cache-hack branch 2 times, most recently from 9487245 to a9dd221 Compare April 13, 2026 14:43
@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource changed the title SONARJAVA-6253 Ensure ITs jobs do not share cache SONARJAVA-6253 Ensure integration tests do not share cache Apr 13, 2026
@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource marked this pull request as ready for review April 13, 2026 14:57
@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha bot commented Apr 13, 2026

Summary

This PR fixes cache sharing between integration test jobs in the CI pipeline. Different test jobs (ruling, plugin, sanity, autoscan, etc.) were previously sharing the same Maven dependency cache, which could cause test flakiness or failure propagation. The fix introduces separate cache keys for each job by writing a job-specific file before Maven runs—since GitHub's Maven caching is based on pom.xml hashing, this forces each job to have an isolated cache.

What reviewers should know

How it works:

  • New custom action .github/actions/write-file writes a sentinel file to target/just_for_cache_key_calculation/pom.xml before Maven runs
  • Each job includes its name (and matrix variables for parameterized jobs) in the file content, making the cache key unique per job variant
  • This prevents cache collisions between ruling-qa, plugin-qa, sanity, custom-rules-license-check, autoscan, and qa-os-win jobs

Where to look:

  • .github/actions/write-file/action.yml - the new helper action (straightforward bash file write)
  • build.yml jobs - each test job now has an "Ensure Separate Job Cache Key" step before Maven configuration
  • Matrix jobs like ruling-qa and plugin-qa include their matrix variables in the cache key; single-run jobs only use the job name

Design notes:

  • The file path and name are intentional: target/ keeps it out of source control, just_for_cache_key_calculation/ signals its purpose clearly
  • Step placement is important: it runs after checkout but before Maven is configured, ensuring the file exists when the cache is initialized
  • No test coverage changes needed—this is pure infrastructure/CI work

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

sonar-review-alpha[bot]

This comment was marked as outdated.

@tomasz-tylenda-sonarsource
Copy link
Copy Markdown
Contributor Author

I have an alternative fix in #5567 and SonarSource/ci-github-actions#244

@tomasz-tylenda-sonarsource
Copy link
Copy Markdown
Contributor Author

I think we should proceed with this workaround, while consider a more general fix for more repos.

@sonarqube-next
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha bot left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

🗣️ Give feedback

Copy link
Copy Markdown
Member

@alban-auzeill alban-auzeill left a comment

Choose a reason for hiding this comment

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

LGTM

@alban-auzeill alban-auzeill merged commit 6fb40a9 into master Apr 16, 2026
16 checks passed
@alban-auzeill alban-auzeill deleted the tt/its-cache-hack branch April 16, 2026 14:03
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