-
Notifications
You must be signed in to change notification settings - Fork 833
Add cache-write input for read-only cache mode #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,12 @@ async function removePrivateKeyFromKeychain() { | |
| * @returns Promise that will be resolved when the save process finishes | ||
| */ | ||
| async function saveCache() { | ||
| const cacheWriteEnabled = core.getInput('cache-write'); | ||
| if (cacheWriteEnabled === 'false') { | ||
| core.info('Cache write is disabled (read-only mode). Skipping cache save.'); | ||
| return Promise.resolve(); | ||
| } | ||
|
Comment on lines
+28
to
+32
|
||
|
|
||
| const jobStatus = isJobStatusSuccess(); | ||
| const cache = core.getInput(constants.INPUT_CACHE); | ||
| return jobStatus && cache ? save(cache) : Promise.resolve(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The codebase has an established
getBooleanInput()utility insrc/util.tsthat handles case-insensitive comparison (via.toUpperCase() === 'TRUE'). It's used for all other boolean inputs:check-latestinsetup-java.ts:30,overwrite-settingsinauth.ts:20andtoolchains.ts:30.Using raw string comparison
=== 'false'here is fragile — it won't match'False'or'FALSE', which users might reasonably pass. This should usegetBooleanInputfromsrc/util.tsinstead, with the logic inverted (skip save when the result isfalse).Additionally, the input name
'cache-write'is hardcoded as a string literal, whereas the codebase convention is to define input name constants insrc/constants.ts(e.g.,INPUT_CACHE,INPUT_CACHE_DEPENDENCY_PATHat line 20-21). A constant likeINPUT_CACHE_WRITEshould be added there and used here.