Add read-only mode for dependency caching - #1169
Merged
brunoborges merged 2 commits intoJul 29, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b3f6f152-8ac4-4c29-b04a-acac8e100777
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a first-class “restore-only” caching mode to actions/setup-java so cache restores still happen, but cache saves (including wrapper caches) are skipped in the post step. This reduces duplicate cache uploads in PRs, merge queues, and fan-out matrix jobs while keeping a default-branch/seed job responsible for writing caches.
Changes:
- Introduces a new
cache-read-onlyinput (defaultfalse) and documents recommended workflow patterns. - Gates the post-job cache save in
cleanup-javawhencache-read-onlyis enabled, with an explicit log message. - Updates unit tests and the e2e cache workflow to exercise read-only restores; regenerates
dist/bundles.
Show a summary per file
| File | Description |
|---|---|
| src/constants.ts | Adds the cache-read-only input constant. |
| src/cleanup-java.ts | Skips cache saving in the post action when cache-read-only is true. |
| README.md | Documents cache-read-only and provides default-branch writer + seed/matrix patterns. |
| action.yml | Declares the new cache-read-only input with default false. |
| tests/cleanup-java.test.ts | Adds unit coverage ensuring cache saves are skipped in read-only mode and still occur when explicitly disabled. |
| .github/workflows/e2e-cache.yml | Runs restore jobs in read-only mode to validate restores without post-job saves. |
| dist/setup/index.js | Updates bundled constant for cache-read-only. |
| dist/cleanup/index.js | Updates bundled cleanup logic to honor cache-read-only. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/8 changed files
- Comments generated: 0
- Review effort level: Low
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.
Cache-enabled pull requests, merge queues, short-lived branches, and fan-out matrix jobs can waste post-job time and storage by uploading duplicate or temporary cache archives. This adds a restore-only mode so those jobs can consume reusable caches while a default-branch or seed job remains responsible for writes.
Changes
cache-read-onlyinput that defaults tofalse.Validation
npm run checkFixes: #1168