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

If cache is not hist in restore, there is not cache-hit output #1

Closed
AGallouin opened this issue Apr 11, 2022 · 1 comment
Closed

Comments

@AGallouin
Copy link

AGallouin commented Apr 11, 2022

Hi !

Looking at the code, it seems that the branch managing the cache not hit in restore.ts doesn't set output before returning:

         if (!cacheKey) {
            const message = `Cache not found for input keys: ${[
                primaryKey,
                ...restoreKeys
            ].join(", ")}`;
            if (isCacheRequired()) {
                throw new Error(message);
            } else {
                core.info(message);
                // I expected to have an utils.setCacheHitOutput(false); here
                return false;
            }
        }

I may be missing something here, If right I can write you the PR.

Thanks !

@MartijnHols
Copy link
Owner

Hey, thanks for reporting your findings. Looking at the code, I see this originates from the original repo here: https://github.com/actions/cache/blob/8f1e2e02865c42348f9baddbbaafb1841dce610a/src/restore.ts#L33-L46

This probably works properly since most people use steps.cache.outputs.cache-hit != 'true' as a check rather than checking for false, and the default should be blank (falsey). Still for clarity I agree it would be better for that line to be in there. Are you still willing to make a PR for the change?

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

No branches or pull requests

2 participants