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

Add 'cache-hit' as output #327

Merged
merged 1 commit into from Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions __tests__/cache-restore.test.ts
Expand Up @@ -140,6 +140,7 @@ describe('cache-restore', () => {
expect(infoSpy).not.toHaveBeenCalledWith(
`${packageManager} cache is not found`
);
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
}
);
});
Expand Down Expand Up @@ -167,6 +168,7 @@ describe('cache-restore', () => {
expect(infoSpy).toHaveBeenCalledWith(
`${packageManager} cache is not found`
);
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
}
);
});
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -29,6 +29,9 @@ inputs:
version:
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use node-version instead'
outputs:
cache-hit:
description: 'A boolean value to indicate if a cache was hit'
runs:
using: 'node12'
main: 'dist/setup/index.js'
Expand Down
1 change: 1 addition & 0 deletions dist/setup/index.js
Expand Up @@ -44674,6 +44674,7 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
core.debug(`primary key is ${primaryKey}`);
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
core.setOutput('cache-hit', Boolean(cacheKey));
if (!cacheKey) {
core.info(`${packageManager} cache is not found`);
return;
Expand Down
1 change: 1 addition & 0 deletions src/cache-restore.ts
Expand Up @@ -42,6 +42,7 @@ export const restoreCache = async (
core.saveState(State.CachePrimaryKey, primaryKey);

const cacheKey = await cache.restoreCache([cachePath], primaryKey);
core.setOutput('cache-hit', Boolean(cacheKey));

if (!cacheKey) {
core.info(`${packageManager} cache is not found`);
Expand Down