-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix cache-hit output when cache missed #1404
Conversation
Hi, @bethanyj28 Thank you very much! |
@joshmgross Thank you very much! |
src/restoreImpl.ts
Outdated
@@ -62,7 +62,7 @@ export async function restoreImpl( | |||
...restoreKeys | |||
].join(", ")}` | |||
); | |||
|
|||
core.setOutput(Outputs.CacheHit, false.toString()); |
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.
Should we set this output before the if (failOnCacheMiss)
case above?
That would ensure it's set even if fail-on-cache-miss
is true.
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.
Hi, @joshmgross
Thanks for your response.
Indeed, since it applies even in the case of exceptions, it seems good to output before failOnCacheMiss
. What do you think?
6f5b5ee
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.
Thanks @fchimpan!
Looks like the dist/
is out of date - could you re-run npm run build
?
https://github.com/actions/cache/actions/runs/9599939755/job/26475812160?pr=1404
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.
Thanks @joshmgross !
8addae5
I have pushed the dist.
I tested the implementation of this PR by actually using it. As expected, it was confirmed that ‘false’ is returned when the cache is not found. v4 test : https://github.com/fchimpan/cache-pr-1404-test/actions/runs/9606621627 |
Hi @joshmgross , Thank you! |
* fix: cache-hit output * fix: Output chache hit timing * fix: Output chache hit timing --------- Co-authored-by: Josh Gross <joshmgross@github.com>
Comment: The ternary logic which this patch removes was a useful (but -granted- undocumented and broken) API to detect whether
The correct way to get the same check seems to be |
I think it would have been better to change the documentation. This was a major breaking change. |
Before landing this type of change, it would be useful to check how it is used: |
This was a major change and should have been released as such. The change in return value cause several critical steps in our workflows to be skipped and caused them all to fail. I understand that this behavior has technically a bug, but given how long it returned empty values this should have been considered valid behavior and taken into account. This change could have potentially disrupted development for my whole team had I not caught it before going on vacation. We rely heavily on actions from this organization because we perceive them be stable and professionally maintained. |
The readme says that The string |
In that sense the API was inconsistent with the docs already before. |
Then the readme correction proposed in #1263 is still relevant, even though the description of this PR says that it is meant to fix the implementation instead of having to clarify the readme (the PR of course needs to be adapted to account for the change done here) |
This broke our CI. |
This basically broke all of my composite actions. |
👋 I will work on reverting this change |
Description
fix #1334
According to the README, if the cache was not found, the output should be
'false'
. However, it actually returned an empty string. This seems to be due to the behavior of GitHub Actions to return an empty string if the output is not defined. Please see these conversations.I would like to change the code to return
'false'
when the cache is not found, per the README.Motivation and Context
In PR #1263, a README correction is suggested. This is a great initiative, thank you. However, to avoid confusion, how about changing the implementation instead?
How Has This Been Tested?
The issue was caused by not defining an output for
cache-hit
when the cache was not found, and then returning. Therefore, I will set the output before returning.Screenshots (if appropriate):
Types of changes
Checklist: