gradle / gradle/actions

Basic cache provider never caches the configuration cache

Closed
#1,076 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
340
Forks
118
Avg merge
1d 9h
Merged PRs (30d)
11

Description

Hi, and thanks for setup-gradle.

With cache-provider: basic, the configuration cache never survives between jobs. On a fresh GitHub-hosted runner with the basic cache restored, a build with org.gradle.configuration-cache=true still logs:

Calculating task graph as no cached configuration is available for tasks: build

From the code this looks expected: both restore() and save() derive their paths from getCachePaths(), which only covers Gradle User Home:

https://github.com/gradle/actions/blob/9c971963bec38e04b3d30dcc455b5382be2fdbfb/sources/src/cache-service-basic.ts#L156-L158

function getCachePaths(gradleUserHome: string): string[] {
    return [path.join(gradleUserHome, 'caches'), path.join(gradleUserHome, 'wrapper')]
}

The Basic Caching docs describe the same two directories. The configuration cache, though, lives in the project cache directory<checkout>/.gradle/configuration-cache (Gradle 9.7.1). I verified it on a runner: the entry directories (<hash>, <uuid>) appear under .gradle/configuration-cache/, while find ~/.gradle -iname '*configuration-cache*' finds nothing.

Since every hosted job starts from a fresh checkout, the entry can never be restored: ~/.gradle/caches (including build-cache-1) is shared, but configuration isn't — even when consecutive jobs run the exact same command on the same commit. We know --project-cache-dir can relocate the project cache dir into Gradle User Home as a workaround, but it's surprising to have to configure that in every workflow.

So, two questions:

  1. Is this by design — i.e. the basic provider intentionally keeping project-scoped state out of scope for it? In general, are there reasons why one wouldn't want to restore the Gradle configuration cache?
  2. If not, could the action start caching .gradle/configuration-cache in the basic provider's cached paths?

If you don't want to go for it, a documented limitation in the Basic Caching section would also be fine.

Happy to test a change or open the PR if you're interested.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sources/src/cache-service-basic.ts at getCachePaths(), then trace how restore() and save() consume its paths. Check the Basic Caching section in docs/setup-gradle.md and verify whether adding the project configuration-cache path is appropriate; done means the configuration cache survives between jobs or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
build-system, ci-cd
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.