actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.36k stars 1.16k forks source link

Fix cache-hit output when cache missed #1404

Open fchimpan opened 1 month ago

fchimpan commented 1 month ago

Description

fix https://github.com/actions/cache/issues/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:

fchimpan commented 1 month ago

Hi, @bethanyj28 I would like to request a reviewer for this pull request. If you are not the reviewer, could you please recommend a suitable reviewer?

Thank you very much!

fchimpan commented 2 weeks ago

@joshmgross I would like to request a reviewer for this pull request. If you are not the reviewer, could you please recommend a suitable reviewer?

Thank you very much!

fchimpan commented 1 week ago

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 This PR test : https://github.com/fchimpan/cache-pr-1404-test/actions/runs/9606621624 Please see cache-miss job's Check outputs step.

fchimpan commented 1 week ago

Hi @joshmgross , I’ve made the necessary changes. Could you please review the code?

Thank you!