Skip to content

Add read-only mode for dependency caching - #1169

Merged
brunoborges merged 2 commits into
actions:mainfrom
brunoborges:brunoborges-add-read-only-cache-mode
Jul 29, 2026
Merged

brunoborges merged 2 commits into
actions:mainfrom
brunoborges:brunoborges-add-read-only-cache-mode

Conversation

@brunoborges

Copy link
Copy Markdown
Contributor

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

  • Add a cache-read-only input that defaults to false.
  • Preserve normal Maven, Gradle, sbt, and wrapper-cache restores while gating the post action before any cache save occurs.
  • Log clearly when cache persistence is skipped because read-only mode is enabled.
  • Cover all supported package managers in unit and end-to-end tests.
  • Document default-branch writer and seed-job/read-only matrix patterns.
  • Regenerate the checked-in action bundles.

Validation

  • npm run check
  • 1,191 unit tests passing

Fixes: #1168

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3f6f152-8ac4-4c29-b04a-acac8e100777
Copilot AI review requested due to automatic review settings July 29, 2026 08:48
@brunoborges
brunoborges requested a review from a team as a code owner July 29, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-only input (default false) and documents recommended workflow patterns.
  • Gates the post-job cache save in cleanup-java when cache-read-only is 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
@brunoborges
brunoborges merged commit 62f345f into actions:main Jul 29, 2026
79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants