gradle / gradle/actions

ReserveCacheError: Unable to reserve cache with key <cache-key>

Open
#722 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
340
Forks
117
Avg merge
1d 9h
Merged PRs (30d)
11

Description

When using a reusable build inside a matrix workflow, only one of the jobs is able to write its cache.

example:

```yaml
# .github/workflows/main.yaml

on:
push: [main]

jobs:
build-android:
strategy:
matrix:
app-name:
- app1
- app2
uses: ./.github/workflows/reusable-build.yaml
with:
app-name: ${{ matrix.app-name }}
```

```yaml
# .github/workflows/reusable-build.yaml

on:
workflow_call:
inputs:
app-name:
required: true
type: string
jobs:
build:
steps:

# ...

- uses: gradle/actions/setup-gradle@v4

# ... build
```

In the example above, one of the gradle steps will successfully write its cache, but the other fails with error

```
Failed to save cache entry with path '' and key: : ReserveCacheError: Unable to reserve cache with key , another job may be creating this cache.
```

Both jobs have the same key. Edit: the cache key doesn't include anything for the matrix context (eg `gradle-home-v1|Linux-X64|build[ef6094c74d56794d327380021ca7a151]-2baefdce1c4b89355ff1a945a35e960b6289568f`)

Contributor guide

Open the contributing guide

Research direction

Reproduce the matrix workflow from .github/workflows/main.yaml and .github/workflows/reusable-build.yaml, focusing on the gradle/actions/setup-gradle@v4 step. Compare the cache keys and reservation behavior across the matrix jobs. Done means the cause of the conflicting cache writes is confirmed and covered by an agreed fix, regression test, or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions
Domain
build-system, ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.