Skip to content

feat: add cache-save-if input to control cache saving#4

Closed
Boshen wants to merge 1 commit intomainfrom
feat/cache-save-if
Closed

feat: add cache-save-if input to control cache saving#4
Boshen wants to merge 1 commit intomainfrom
feat/cache-save-if

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Mar 12, 2026

Summary

  • Add cache-save-if input (default "true") that controls whether the cache is saved in the post phase
  • When false, cache is only restored but never saved — useful for matrix jobs or limiting cache writes to specific branches
  • Gates saveCache() call on both inputs.cache and inputs.cacheSaveIf

🤖 Generated with Claude Code

Allow users to disable cache saving while still restoring caches.
This is useful for matrix jobs or limiting cache writes to specific branches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 12, 2026 04:41
@Boshen
Copy link
Member Author

Boshen commented Mar 12, 2026

I need this to cache only on main branch.

@Boshen
Copy link
Member Author

Boshen commented Mar 12, 2026

oh wait this thing always read cache

@Boshen Boshen closed this Mar 12, 2026
@Boshen Boshen deleted the feat/cache-save-if branch March 12, 2026 04:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new GitHub Action input, cache-save-if, to control whether dependency caches are saved during the post phase (while still allowing cache restore during the main phase when caching is enabled).

Changes:

  • Added cacheSaveIf to the Inputs type and wired it into input parsing (cache-save-if).
  • Updated post-phase behavior to only call saveCache() when both cache and cacheSaveIf are true.
  • Updated action.yml and rebuilt dist/index.mjs to include the new input and logic.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types.ts Extends the Inputs interface with the new cacheSaveIf boolean.
src/inputs.ts Reads the new cache-save-if boolean input into Inputs.
src/inputs.test.ts Updates expected input shape to include cacheSaveIf.
src/index.ts Gates cache saving in runPost() on inputs.cache && inputs.cacheSaveIf.
dist/index.mjs Rebuilt bundle reflecting the new input and save gating.
action.yml Declares cache-save-if input (default true) and documents behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@@ -54,7 +54,7 @@ async function printViteVersion(): Promise<void> {

async function runPost(inputs: Inputs): Promise<void> {
// Save cache if enabled
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The comment says cache is saved “if enabled”, but saving is now additionally gated by inputs.cacheSaveIf. Please update the comment to reflect the actual condition (cache enabled AND cache-save-if true) so the post-phase behavior is clear.

Suggested change
// Save cache if enabled
// Save cache if enabled and the cache-save-if condition is true

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 32
runInstall: [],
cache: false,
cacheDependencyPath: undefined,
cacheSaveIf: false,
});
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This test sets getBooleanInput to always return false, so it won’t catch regressions where getInputs() reads the wrong boolean input name (e.g. a typo in cache-save-if). Consider adding a focused test that makes getBooleanInput return true only for "cache-save-if" (and/or asserts it was called with that name) and then verifies inputs.cacheSaveIf is true.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants