mirror of
https://github.com/actions/cache.git
synced 2025-03-31 10:26:35 +00:00
Code review
This commit is contained in:
parent
d57039cf5c
commit
84097c0606
7 changed files with 23 additions and 7 deletions
|
@ -396,6 +396,8 @@ test("restore with lookup-only set", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache would have been restored from key: ${key}`
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@ inputs:
|
|||
default: 'false'
|
||||
required: false
|
||||
lookup-only:
|
||||
description: 'Skip downloading cache. Only check if cache entry exists'
|
||||
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
||||
default: 'false'
|
||||
required: false
|
||||
outputs:
|
||||
|
|
7
dist/restore-only/index.js
vendored
7
dist/restore-only/index.js
vendored
|
@ -50520,7 +50520,12 @@ function restoreImpl(stateProvider) {
|
|||
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey);
|
||||
const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey);
|
||||
core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
if (lookupOnly) {
|
||||
core.info(`Cache would have been restored from key: ${cacheKey}`);
|
||||
}
|
||||
else {
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
return cacheKey;
|
||||
}
|
||||
catch (error) {
|
||||
|
|
7
dist/restore/index.js
vendored
7
dist/restore/index.js
vendored
|
@ -50520,7 +50520,12 @@ function restoreImpl(stateProvider) {
|
|||
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey);
|
||||
const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey);
|
||||
core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
if (lookupOnly) {
|
||||
core.info(`Cache would have been restored from key: ${cacheKey}`);
|
||||
}
|
||||
else {
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
return cacheKey;
|
||||
}
|
||||
catch (error) {
|
||||
|
|
|
@ -10,7 +10,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex
|
|||
* `path` - A list of files, directories, and wildcard patterns to restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
|
||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
||||
* `lookup-only` - Skip downloading cache. Only check if cache entry exists. Default: `false`
|
||||
* `lookup-only` - Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache. Default: `false`
|
||||
|
||||
### Outputs
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ inputs:
|
|||
default: 'false'
|
||||
required: false
|
||||
lookup-only:
|
||||
description: 'Skip downloading cache. Only check if cache entry exists'
|
||||
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
||||
default: 'false'
|
||||
required: false
|
||||
outputs:
|
||||
|
|
|
@ -70,7 +70,11 @@ async function restoreImpl(
|
|||
);
|
||||
|
||||
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
if (lookupOnly) {
|
||||
core.info(`Cache would have been restored from key: ${cacheKey}`);
|
||||
} else {
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
|
||||
return cacheKey;
|
||||
} catch (error: unknown) {
|
||||
|
|
Loading…
Add table
Reference in a new issue