Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache cleanup does not clean cache entries for newly released Gradle versions #436

Open
bigdaz opened this issue Nov 12, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@bigdaz
Copy link
Member

bigdaz commented Nov 12, 2024

Gradle User Home cache cleanup requires Gradle 8.11 to execute.

  • If a version >= 8.11 is found on the PATH, then this version is used for cache-cleanup.
  • If no version is found on PATH (or an older version) then 8.11 will be downloaded and used.

If a Gradle Wrapper build runs with a newer version of Gradle (eg Gradle 8.11.1), then it will generate Gradle User Home content that will not be removed by cache cleanup running with Gradle 8.11.
For example, transform outputs are stored under ~/.gradle/caches/<gradle-version>/transforms, and caches/8.12/transforms will not be removed by cache-cleanup running with Gradle 8.11. This can result in ever-growing cache entry sizes.

To workaround this issue, ensure that there is a version of Gradle available on the PATH, and that this version is at least as new as any version used to run Gradle Wrapper builds.

uses: gradle/actions/setup-gradle@v4
with:
  gradle-version: "8.11.1" # Set to the newest version of Gradle used to build

Fixing this (without reverting to the old behaviour of always installing the latest Gradle) will involve detecting the newest Gradle version executed for a Job, and ensuring that cleanup is executed with at least that Gradle version.

@stefan-rademacher-tk
Copy link

Hi. We suffer from this bug in a different way: We use the setup-gradle action on GitHub Enterprise Server, within our corporate network. All our Gradle Wrapper configurations point to a Gradle Distribution, that is hosted within our network, since downloading from services.gradle.org is extremly slow (or fails with timeouts), due to virus scanning in our proxy server.

Unfortunately, we cannot configure the download url for this action, as we can for the Gradle Wrapper.

@bigdaz
Copy link
Member Author

bigdaz commented Jan 14, 2025

@stefan-rademacher-tk Thanks for reporting. Your problem is slightly different and the proposed fix for this issue may not help you.
To clarify, the proposed fix would detect the correct version to use for cache cleanup, but would not remove the need to download this version from services.gradle.org.

To address your issue I can see 2 possible improvements to the action:

  1. Allow the download URL to be configured for the setup-gradle action when downloading Gradle distributions
  2. Reuse the existing wrapper distribution download for cache cleanup. Currently these distributions are only used for Gradle wrapper executions.

Can you please raise a separate issue for your use case? Specifically you'd like to avoid downloading Gradle from services.gradle.org for cache cleanup operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants