Skip to content

Commit d117871

Browse files
authored
Add 'cache-hit' as output
1 parent 041bafb commit d117871

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

Diff for: __tests__/cache-restore.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ describe('cache-restore', () => {
140140
expect(infoSpy).not.toHaveBeenCalledWith(
141141
`${packageManager} cache is not found`
142142
);
143+
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
143144
}
144145
);
145146
});
@@ -167,6 +168,7 @@ describe('cache-restore', () => {
167168
expect(infoSpy).toHaveBeenCalledWith(
168169
`${packageManager} cache is not found`
169170
);
171+
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
170172
}
171173
);
172174
});

Diff for: action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ inputs:
2929
version:
3030
description: 'Deprecated. Use node-version instead. Will not be supported after October 1, 2019'
3131
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use node-version instead'
32+
outputs:
33+
cache-hit:
34+
description: 'A boolean value to indicate if a cache was hit'
3235
runs:
3336
using: 'node12'
3437
main: 'dist/setup/index.js'

Diff for: dist/setup/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -44674,6 +44674,7 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0
4467444674
core.debug(`primary key is ${primaryKey}`);
4467544675
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
4467644676
const cacheKey = yield cache.restoreCache([cachePath], primaryKey);
44677+
core.setOutput('cache-hit', Boolean(cacheKey));
4467744678
if (!cacheKey) {
4467844679
core.info(`${packageManager} cache is not found`);
4467944680
return;

Diff for: src/cache-restore.ts

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const restoreCache = async (
4242
core.saveState(State.CachePrimaryKey, primaryKey);
4343

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

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

0 commit comments

Comments
 (0)