Skip to content

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

Open
tomasz-tylenda-sonarsource wants to merge 1 commit intomasterfrom
tt/its-cache-hack
Open

SONARJAVA-6253 Ensure integration tests do not share cache#5568
tomasz-tylenda-sonarsource wants to merge 1 commit 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

sonar-review-alpha bot commented Apr 13, 2026

Summary

This PR ensures that separate integration test jobs don't share Maven caches by introducing a unique cache key per job. A new GitHub Action writes a file (just_for_cache_key_calculation/pom.xml) with job-specific content (job name and matrix variables) before Maven runs. Since GitHub's cache key includes the content hash of files in the cache path, each job now gets a distinct cache, preventing cross-job cache pollution.

What reviewers should know

How it works:

  • New reusable action at .github/actions/write-file/ — a simple utility that writes content to a file
  • Added to 6 integration test jobs in the build workflow (ruling, plugin, qa, qa-plugin, license-check, plugin-check)
  • The file is written with unique per-job content: either ${{ github.job }} alone or ${{ github.job }}-${{ matrix variables }}
  • This file becomes part of Maven's cache scope, so different jobs naturally get different caches

For reviewers:

  • The approach is non-obvious but clever — it exploits how GitHub's cache hashing works rather than using explicit cache keys
  • The file path just_for_cache_key_calculation/ makes the intent clear: it exists purely for cache separation, not as a real project file
  • No changes to job logic or Maven configuration — this is purely a cache isolation mechanism
  • All instances follow the same pattern; review one or two to understand them all

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@sonarqube-next
Copy link
Copy Markdown

Copy link
Copy Markdown

@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! ✅

Clean, focused change with no bugs. The approach of writing a unique-content file to influence Maven's cache hash is correct and each job is properly distinguished — non-matrix jobs by github.job, matrix jobs by github.job + matrix variables. Using env vars in the composite action (FILE_PATH, CONTENT) correctly avoids shell injection risks.

🗣️ Give feedback

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

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

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.

1 participant