Skip to content

Conversation

@schneider10
Copy link
Contributor

When checking cache-hit, this action will return an empty string on no hit, not 'false'. Therefore the correct method is to now check for !=true (see: https://github.com/actions/cache#Skipping-steps-based-on-cache-hit)

Why:

This doc is out of date or sharing incorrect info for the latest cache action.

What's being changed:

The documented method to check for a cache hit.

Check off the following:

  • I have reviewed my changes in staging (look for "Automatically generated comment" and click Modified to view your latest changes).
  • For content changes, I have completed the self-review checklist.

Writer impact (This section is for GitHub staff members only):

  • This pull request impacts the contribution experience
    • I have added the 'writer impact' label
    • I have added a description and/or a video demo of the changes below (e.g. a "before and after video")

When checking cache-hit, this action will return an empty string on no hit, not 'false'. Therefore the correct method is to now check for !=true (see: https://github.com/actions/cache#Skipping-steps-based-on-cache-hit)
@welcome
Copy link

welcome bot commented Jun 10, 2022

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jun 10, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 10, 2022

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
actions/using-workflows/caching-dependencies-to-speed-up-workflows.md fpt
ghec
ghes@ 3.6 3.5
fpt
ghec
ghes@ 3.6 3.5

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server
ghae: GitHub AE

@janiceilene
Copy link
Contributor

@schneider10 Thanks so much for opening a PR! I'll get this triaged for review ⚡

@janiceilene janiceilene added actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Jun 10, 2022
@martin389 martin389 added the needs SME This proposal needs review from a subject matter expert label Jun 13, 2022
@github-actions
Copy link
Contributor

Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert 👀

@lucascosti
Copy link
Contributor

When checking cache-hit, this action will return an empty string on no hit, not 'false'.

👋 @N-Usha @bishal-pdMSFT Could you have a look at this and see if it might be a bug in the cache action? I've replicated the behavior here (with debug logging on).

In the action's code, it does look like a false value should be set for the output for a cache miss, and there does seem to be a test for this in the repo too.

@N-Usha
Copy link
Contributor

N-Usha commented Jun 21, 2022

Yes @lucascosti , the doc may need an update.. Including @aparna-ravindra who's verifying this from the code.

@aparna-ravindra
Copy link
Contributor

aparna-ravindra commented Jun 21, 2022

In the action's code, it does look like a false value should be set for the output for a cache miss, and there does seem to be a test for this in the repo too.

@lucascosti, Unfortunately, the method in the test case you referred is not used in the action. The value for cache-hit is set to false in three cases:

  1. Cache feature is not available (here).
  2. If there was a cache restored - but on one of the restore-keys and not the primary key (here)
  3. Any unhandled exception (here).

However, if no cache was restored (either on the primary key or the restore-keys), then the cache-hit output value is not set.
Therefore, the right way to test is to check for cache-hit != true as we see in the examples here

@lucascosti
Copy link
Contributor

lucascosti commented Jun 21, 2022

@lucascosti, Unfortunately, the method in the test case you referred is not used in the action. The value for cache-hit is set to false in three cases:

Thanks a lot for confirming this, @aparna-ravindra! 🙇‍♂️ My next question (possibly more for @N-Usha): is this behavior deliberate? If cache-hit is a boolean for determining if a cache hit on key happens, shouldn't it return false for any situation where there wasn't a cache hit on key?

I guess I'm trying to think of a case where returning a null value for when no cache was restored would be the desired/expected outcome. 🙃 I would have expected a null value returned for situations 1. (Cache feature is not available) and 3. (Unhandled exception) in the post above.

If it is deliberate, I'll take care of getting the docs updated (e.g. this section will also need updating) 👍

@aparna-ravindra
Copy link
Contributor

Given that there are two possible values (null and false) that indicate cache-miss, checking for cache-hit != true will address both cases. Hence, I vote for updating the doc and thereby keeping it consistent with the example in the actions/cache public repository as well.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 6, 2022

This is a gentle bump for the docs team that this PR is waiting for technical review.

@github-actions github-actions bot added the SME stale The request for an SME has staled label Jul 6, 2022
@jsoref
Copy link
Contributor

jsoref commented Jul 6, 2022

Sounds like this is related to actions/cache#717 / actions/cache#661 (comment)

@cmwilson21 cmwilson21 removed the SME stale The request for an SME has staled label Jul 7, 2022
@github-actions
Copy link
Contributor

This is a gentle bump for the docs team that this PR is waiting for technical review.

@github-actions github-actions bot added the SME stale The request for an SME has staled label Jul 14, 2022
@aparna-ravindra
Copy link
Contributor

@lucascosti Please feel free to ping if you need any more inputs from me.

@cmwilson21 cmwilson21 added SME reviewed An SME has reviewed this issue/PR and removed SME stale The request for an SME has staled needs SME This proposal needs review from a subject matter expert labels Jul 15, 2022
@aparna-ravindra
Copy link
Contributor

@lucascosti ,
we have a couple more requests (like this one) asking for doc update. How do we go about triaging this PR?

@lucascosti
Copy link
Contributor

@lucascosti , we have a couple more requests (like this one) asking for doc update. How do we go about triaging this PR?

Sorry, @aparna-ravindra; I've been on some extended leave and this one slipped through the cracks. I'll get this reviewed and merged. 👍

lucascosti
lucascosti previously approved these changes Aug 17, 2022
Copy link
Contributor

@lucascosti lucascosti left a comment

Choose a reason for hiding this comment

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

Although being able to match on a cache hit on a false result would also be ideal, these changes more accurately describe the action's current behavior. 👍

@lucascosti lucascosti enabled auto-merge (squash) August 17, 2022 04:39
@lucascosti lucascosti merged commit 5129108 into github:main Aug 17, 2022
@github-actions
Copy link
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

@bchen1029
Copy link

bchen1029 commented Aug 18, 2022

@lucascosti this PR help setting cache hit on false when no hit. I think this is ideal solution as you do. Could you help check this PR actions/cache#876 if you're free? really appreciate!

@lucascosti
Copy link
Contributor

Sorry, @bchen1029; the Actions engineering team will have to review those changes; I'm a docs writer and defer to them for any functionality changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

actions This issue or pull request should be reviewed by the docs actions team SME reviewed An SME has reviewed this issue/PR waiting for review Issue/PR is waiting for a writer's review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants