Skip to content

BUILD-8977 custom Gradle cache#76

Merged
mikolaj-matuszny-ext-sonarsource merged 2 commits intomasterfrom
feat/mmatuszny/8977-gradle-cache
Sep 5, 2025
Merged

BUILD-8977 custom Gradle cache#76
mikolaj-matuszny-ext-sonarsource merged 2 commits intomasterfrom
feat/mmatuszny/8977-gradle-cache

Conversation

@mikolaj-matuszny-ext-sonarsource
Copy link
Copy Markdown
Contributor

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource commented Sep 2, 2025

BUILD-8977

  • disabled caching mechanism built in setup-gradle - this is required but also has a slight downside of false information in job summary. With moving towards having dedicated setup-gradle action this should be resolved soon.
image
  1. Cache Key Generation

    • Based on SonarSource standard pattern used across Cirrus CI configurations:
      find -type f \( -name "*.gradle*" -or -name "gradle*.properties" \) | sort | xargs cat
    • GitHub Actions adaptation: Generates MD5 hash from all Gradle configuration files:
      • All *.gradle and *.gradle.kts files (matches *.gradle* pattern)
      • gradle/libs.versions.toml (version catalog)
      • gradle/wrapper/gradle-wrapper.properties (matches gradle*.properties pattern)
    • Key difference from Cirrus CI: Excludes gradle.properties (modified during build with unique version numbers)
    • Creates composite cache key: gradle-${{ runner.os }}-${{ github.workflow }}-${{ hash }}
  2. Cached Directories

    • ${{ env.GRADLE_USER_HOME }}/caches - Gradle build cache and dependencies
    • ${{ env.GRADLE_USER_HOME }}/wrapper - Gradle wrapper distributions
    • Custom paths via cache-paths input (optional)
  3. Cache Restore Strategy

    • Primary key: Full hash-based key for exact matches
    • Fallback keys: gradle-${{ runner.os }}-${{ github.workflow }}- for partial matches

This is based on CirrusCI usage as well as usage in teams that migrated to GitHub already.

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource force-pushed the feat/mmatuszny/8977-gradle-cache branch 2 times, most recently from 8566310 to 2cd9b51 Compare September 3, 2025 09:30
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource changed the title BUILD-8977 gradle cache BUILD-8977 custom Gradle cache Sep 3, 2025
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource marked this pull request as ready for review September 3, 2025 09:33
Comment thread build-gradle/action.yml Outdated
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.

Please specify in the Jira ticket and describe in the PR, the chosen implementation.
Did you find the previous custom usages in Cirrus CI?
There is need for

  • customization parameters in addition to the default values
    • custom path
    • custom key (based on custom script)
    • runner.os in the key?
    • github.workflow in the key (as in build-maven)

Comment thread build-gradle/action.yml Outdated
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Sep 5, 2025

🤖 Pull Request summary

This PR implements custom Gradle caching to replace the default setup-gradle caching mechanism.

• Adds two new inputs: cache-paths for additional cache directories and disable-caching toggle
• Disables built-in Gradle caching by setting cache-disabled: true in setup-gradle action
• Implements custom cache key generation using MD5 hashes of all Gradle build files
• Adds manual cache restoration step using SonarSource cache action with generated keys

Review focus: Verify the cache key generation logic covers all relevant Gradle files and that the fallback restore-keys pattern provides adequate cache hit rates.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource merged commit 6313c83 into master Sep 5, 2025
13 of 15 checks passed
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource deleted the feat/mmatuszny/8977-gradle-cache branch September 5, 2025 08:04
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.

3 participants