Repository navigation
Cache Gradle dependencies in the Docker build so CI stops hitting Maven Central rate limits - #16
Merged
Merged
Conversation
CI's Docker job re-downloaded every dependency on each run: the BuildKit cache mount isn't exported to the GitHub Actions layer cache, and the build layer is invalidated by any source change. Twice that hit Maven Central's rate limit (HTTP 429) and failed the build. A new downloadDependencies task resolves every configuration; the Dockerfile runs it before copying src, so the layer changes only with the build files and is reused from the gha cache. The compile step then runs with --offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CI Docker job failed twice with
Received status code 429 from server: Too Many Requestsfrom Maven Central (most recently onmainafter #15, fixed by a re-run).Why
The test job already caches Gradle (
setup-gradle). The Docker job didn't, in practice: the Dockerfile kept Gradle's downloads in a BuildKit cache mount, which the GitHub Actions layer cache (cache-to: type=gha) doesn't save, and the build layer was invalidated by any source change. So every CI run downloaded Gradle and every dependency again.Change
build.gradle: adownloadDependenciestask that resolves every configuration (downloads all jars, compiles nothing).Dockerfile: runs it before copyingsrc, so dependencies sit in their own layer that changes only when the build files change. CI's existingtype=ghacache (mode=max) keeps that layer. The compile step then runs with--offline, which also proves nothing else is fetched.The workflow file is unchanged.
Verified locally
--offlinecompile succeeds.CACHEDand only the ~15 s compile runs../gradlew downloadDependencies testpasses with no deprecation warnings.The first CI run on this branch still downloads everything (filling the cache); runs after that reuse it until
build.gradlechanges.