Skip to content

feat: setup-gradle and setup-graalvm keep the configuration cache between the runs of a job - #65

Merged
zigzago merged 3 commits into
mainfrom
feat/setup-gradle-configuration-cache
Dec 1, 2026
Merged

zigzago merged 3 commits into
mainfrom
feat/setup-gradle-configuration-cache

Conversation

@zigzago

@zigzago zigzago commented Dec 1, 2026

Copy link
Copy Markdown
Member

Why

gradle/actions/setup-gradle restores the configuration cache only when the Gradle User Home cache matches its key exactly. That key holds the commit SHA, so a new commit always gets a restore-key hit, and the configuration cache is never reused: every CI run logs Calculating task graph as no cached configuration is available for tasks: …, on pull requests and on the default branch alike (seen in motis-mcp-app).

What

When cache-encryption-key is given (the entries are encrypted with it, so it must stay the same from run to run), setup-gradle and setup-graalvm now cache .gradle/configuration-cache:

  • key gradle-configuration-cache-v1|<os>-<arch>|<workflow>|<job>|java-<version>|<sha>, restored from the latest entry with the same prefix;
  • written like the Gradle cache: with actions/cache when cache-read-only is not 'true' (default branch), with actions/cache/restore otherwise (pull requests);
  • new input configuration-cache, 'true' by default, to opt out.

Gradle reuses a restored entry only when the fingerprint of the configuration inputs (build scripts, files and environment read at configuration time) is unchanged, and computes the configuration again otherwise, so a stale entry is never used.

Limits

  • The path is .gradle/configuration-cache in the working directory: a build whose root is elsewhere is not cached.
  • Matrix legs of the same job with the same OS and Java version share a key: the first one to finish saves it.
  • No test in ci.yml: it would need the encryption key. To check it, use the action from this branch in a repository with GRADLE_ENCRYPTION_KEY: the second commit on the default branch should log Reusing configuration cache.

…ween the runs of a job

setup-gradle restores the configuration cache only on an exact match of the
Gradle User Home cache, whose key holds the commit: a new commit never reuses it.
The configuration cache directory is now restored from the latest entry of the
same job, and written like the Gradle cache (on the default branch only).
Gradle reuses an entry only when the fingerprint of its inputs is unchanged.
Opt out with configuration-cache: 'false'.
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@zigzago

zigzago commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Checked in Litote/motis-mcp-app#244 (closed): run 46643887282 saved the entry, run 46644396967 on the next commit restored it and logged Reusing configuration cache.

@zigzago
zigzago merged commit b5681b2 into main Dec 1, 2026
27 checks passed
@zigzago
zigzago deleted the feat/setup-gradle-configuration-cache branch December 1, 2026 12:42
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