Skip to content
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

Cache key output #717

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Cache key output #717

wants to merge 2 commits into from

Conversation

jsoref
Copy link
Contributor

@jsoref jsoref commented Jan 23, 2022

This addresses #661 (comment)

@jsoref jsoref requested a review from a team as a code owner January 23, 2022 19:08
@jsoref
Copy link
Contributor Author

jsoref commented Jan 23, 2022

Fwiw, jsoref@edb9b28 shows tests pass for this commit

@@ -6,7 +6,8 @@ export enum Inputs {
}

export enum Outputs {
CacheHit = "cache-hit"
CacheHit = "cache-hit",
CacheKey = "cache-key"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to name it cache-matched-key to keep it aligned with the corresponding state being set.
Not sure if it is allowed to have state and output with same id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will use whatever people request. But, I'd like to avoid updates unless people agree on direction.

@@ -102,7 +102,8 @@ test("setOutputAndState with exact match to set cache-hit output and state", ()
actionUtils.setOutputAndState(key, cacheKey);

expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
expect(setOutputMock).toHaveBeenCalledTimes(1);
expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheKey, key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it match to cacheKey?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shrug, key and cacheKey are the same.

@bishal-pdMSFT
Copy link
Contributor

@vsvipul please take a look

@jsoref jsoref force-pushed the cache-key-output branch from edb9b28 to dde36b3 Compare March 7, 2022 13:56
@jsoref
Copy link
Contributor Author

jsoref commented Mar 7, 2022

I spent some more time on this, it appears that the @actions/cache method doesn't actually provide enough information.

This new flavor does yield enough information, although admittedly it's more expensive. -- For fallback cases, it will retrieve the cache item twice, and it makes n additional cache queries. I could skip the doubled cache retrieval by changing the primary call to not include fallback items.

It'd be nicer if there was some easy way to figure out from the cache which item was providing the answer.

@jsoref
Copy link
Contributor Author

jsoref commented Aug 17, 2022

@lucascosti: I don't suppose you could look into this?

I mentioned it in github/docs#18524

If someone is willing to review, I'm happy to update.

@lucascosti
Copy link
Contributor

Sorry, @jsoref, because these are code changes, the Actions engineers must review this (cc @aparna-ravindra)

@arminrosu
Copy link

@jsoref @lucascosti any chance we can revive this PR? If there's work to be done, I'm willing to take it over, just need to know what you need to get it merged.

@jsoref
Copy link
Contributor Author

jsoref commented Jan 24, 2023

I'm happy to update, but only if someone will commit to reviewing it and @vsvipul / @bishal-pdMSFT seem to have just dropped the hot-potato.

Copy link

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

What is this PR trying to achieve?

} else {
let i: number;
for (i = 0; i < restoreKeys.length - 1; i++) {
const fallbackCacheKey = await cache.restoreCache(

Choose a reason for hiding this comment

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

Why are you calling restoreCache again?
See line 36: it is already called with the restore keys, so how can this succeed?

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.

6 participants