make CI dependency caching actually work (branch-keyed jar cache)#15935
make CI dependency caching actually work (branch-keyed jar cache)#15935jdaugherty wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts the repository’s GitHub Actions workflows to make dependency caching effective across release branches and reduce CI failures during transient repository outages by introducing an explicit, branch-keyed Gradle dependency cache and replacing an ineffective per-SHA Maven cache with artifact hand-off.
Changes:
- Replace per-SHA
~/.m2/repositorycaching in the Groovy joint workflow withupload-artifact/download-artifactfor the locally built Groovy snapshot. - Disable
setup-gradle’s built-in caching and add an explicitactions/cachestep for downloaded Gradle dependency jars and wrapper distributions keyed by branch and dependency inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/groovy-joint-workflow.yml | Removes per-SHA Maven cache and uses artifacts to share locally built Groovy between jobs; disables Gradle action caching. |
| .github/workflows/gradle.yml | Adds explicit branch-keyed caching for ~/.gradle/caches/modules-2 and ~/.gradle/wrapper and disables setup-gradle caching across jobs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: "🗄️ Restore dependency jar cache" | ||
| uses: actions/cache@v4 | ||
| with: | ||
| # Cache only downloaded dependency jars and wrapper distributions, never Grails build outputs. | ||
| # Keyed by branch version so each release branch maintains its own warm cache. |
1ff64c7 to
9e381f5
Compare
|
FYI:the alternative to this PR is to adopt the commerical gradle cache, but the licensing terms may prevent this. |
actions/download-artifact has no v7.0.1 release (its version line jumped from v7.0.0 to v8.x). Pin download-artifact to v8.0.1 and upload-artifact to v7.0.1 by SHA, matching gradle.yml.
✅ All tests passed ✅🏷️ Commit: 71208cf Learn more about TestLens at testlens.app. |
fix: make CI dependency caching actually work (branch-keyed jar cache)
Description
CI builds regularly fail when
repo.grails.orghas an outage, because every job downloads its full dependency set from scratch on every run — e.g. this run, whereBuild Grails-Core (macos-latest, 21)failed with502 Bad Gatewaydownloadinggroovy-console/groovy-swingjars duringcompileGroovy.Investigation showed that although
setup-gradlecaching is configured, no Gradle caches exist for this repository at all:setup-gradleonly writes caches on the repository's default branch (8.0.x). All7.xbranch and PR builds runcache-read-only: true, and GitHub's cache scoping only lets them restore from their own branch or the default branch — so the7.xbranches never have a warm cache.groovy-joint-workflow, which cached~/.m2/repositoryunder a per-SHA key (cache-local-maven-${{ github.sha }}). A per-SHA key can never be re-used across runs, so this added a new ~60 MB dead entry on every commit (89 entries at the time of writing), evicting anything useful.This PR fixes both:
.github/workflows/groovy-joint-workflow.yml— remove caching entirely:build_groovyjob to thebuild_grailsjob. It is now passed viaupload-artifact/download-artifact(only~/.m2/repository/org/apache/groovy,retention-days: 1), which is the correct mechanism for job-to-job transfer and does not consume the cache quota.cache-disabled: trueon thesetup-gradlesteps — this workflow rebuilds Groovy each run, so a Gradle home cache is not useful..github/workflows/gradle.yml— explicit, branch-keyed dependency-jar cache:cache-disabled: trueon allsetup-gradlesteps, replacing the action's automatic Gradle-home caching (which was silently doing nothing on7.x, and would also cache build outputs).actions/cachestep covering only downloaded dependency jars and wrapper distributions (~/.gradle/caches/modules-2,~/.gradle/wrapper) — never Grails build outputs.gradle-deps-<os>-${{ github.base_ref || github.ref_name }}-<hash of dependencies.gradle + gradle-wrapper.properties>, with a matchingrestore-keysprefix. Pushes to7.0.xseed the cache; PRs targeting7.0.xrestore it. PRs that don't change dependency files get an exact cache hit and skip saving, so PR runs don't pollute the quota.With a warm cache, a transient
repo.grails.orgoutage no longer fails the build, and dependency download time is removed from every job.Follow-up (separate PRs): delete the stale
cache-local-maven-*cache entries so the new caches have room immediately, and add amavenCentral()fallback inGrailsRepoSettingsPluginso a repository outage cannot fail even a cold-cache build.Contributor Checklist
Please review the following checklist before submitting your pull request. Pull requests that do not meet these requirements may be closed without review.
Issue and Scope
repo.grails.orgoutages combined with dependency caching that was configured but never effective.7.0.x): Bug fixes only. No new features or API changes.7.1.x): New features are welcome, but breaking existing APIs must be avoided.8.0.x): Reserved for major changes. Breaking API changes are permitted.7.0.xto be merged forward through7.1.x/7.2.x/8.0.x.Code Quality
./gradlew build --rerun-tasks../gradlew codeStyleand resolved any violations. See Code Style for details.Licensing and Attribution
Documentation