feat: Introduced restore-only flag#1743
Open
gmazzo wants to merge 1 commit into
Open
Conversation
4e5d7b7 to
832f315
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a restore-only input to the main actions/cache action to support “restore but don’t save” scenarios (e.g., avoid overwriting caches on non-default branches).
Changes:
- Introduces new
restore-onlyinput in action metadata and README. - Adds
Inputs.RestoreOnlyconstant and test utilities support for the new input. - Updates save implementation and adds a unit test intending to ensure save is skipped when
restore-onlyis set.
Reviewed changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/testUtils.ts | Adds test input wiring/cleanup for restore-only. |
| src/saveImpl.ts | Adds restore-only handling in the post-save implementation. |
| src/constants.ts | Introduces Inputs.RestoreOnly. |
| tests/saveImpl.test.ts | Adds a test for restore-only behavior. |
| action.yml | Exposes restore-only as an action input. |
| README.md | Documents the new restore-only option and an example expression. |
| dist/save/index.js | Updates compiled save bundle for the new input/behavior. |
| dist/save-only/index.js | Updates compiled save-only bundle for the new input/behavior. |
| dist/restore/index.js | Updates compiled restore bundle enum to include the new input. |
| dist/restore-only/index.js | Updates compiled restore-only bundle enum to include the new input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
832f315 to
063fc74
Compare
b9a2cb5 to
e58227c
Compare
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.
Introduces controlling when to save the cache with a flag.
Description
Introduces a new
restore-onlyflag into the main@actions/cache. If set, the action will download the cache, but it will skip its saving at the post actions phase.Fixes #1730
Motivation and Context
It's true that we do have the
@actions/cache/restoreand@actions/cache/saveactions, but this change serves a new unsupported use-case: "only feed the cache given a condition".This use case is a generalisation of the one I'm interesting on to support, which is "only feed the cache at the default branch". A topic you raise at force-deletion-of-caches-overriding-default-cache-eviction-policy. After carefully reviewing the setup options for the action, we concluded there is no straight forward way (currently) to achieve this.
The change will also allow us to align our ad-hocs
@actions/cachewith the defaultgradle/actions/setup-gradle's behavior, where itscache-read-only(defaulting to${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}) behaves the same.Right now, to support our use case, we have been forced to create an internal wrapper
compositeaction that runs@actions/cache/restoreor@actions/cachebased on this condition.@actions/cache/saveis not fully suitable for the use case, because it does not runs as a post action.How Has This Been Tested?
A dedicated unit test was added to the
saveImpl.test.tssuite.Test PR in the fork running CI: gmazzo#1
Types of changes
Checklist: