mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-02 04:57:46 +02:00
Small improvements
This commit is contained in:
parent
a5631aba37
commit
64ae8e04f8
5 changed files with 10 additions and 15 deletions
|
@ -214,7 +214,7 @@ test("Fail restore when fail on cache miss is enabled and primary key not found"
|
|||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey],
|
||||
failOnCacheMiss: true
|
||||
failOnCacheMiss: "true"
|
||||
});
|
||||
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
|
@ -248,7 +248,7 @@ test("Fail restore when fail on cache miss is enabled and primary key doesn't ma
|
|||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey],
|
||||
failOnCacheMiss: true
|
||||
failOnCacheMiss: "true"
|
||||
});
|
||||
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
|
|
5
dist/restore-only/index.js
vendored
5
dist/restore-only/index.js
vendored
|
@ -50498,7 +50498,7 @@ function restoreImpl(stateProvider) {
|
|||
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
|
||||
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive);
|
||||
if (!cacheKey) {
|
||||
if (core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||
if (core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
|
||||
}
|
||||
core.info(`Cache not found for input keys: ${[
|
||||
|
@ -50511,8 +50511,7 @@ 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());
|
||||
if (!isExactKeyMatch &&
|
||||
core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||
if (!isExactKeyMatch && core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(`Restored cache key doesn't match the given input key. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
|
||||
}
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
|
|
5
dist/restore/index.js
vendored
5
dist/restore/index.js
vendored
|
@ -50498,7 +50498,7 @@ function restoreImpl(stateProvider) {
|
|||
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
|
||||
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive);
|
||||
if (!cacheKey) {
|
||||
if (core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||
if (core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
|
||||
}
|
||||
core.info(`Cache not found for input keys: ${[
|
||||
|
@ -50511,8 +50511,7 @@ 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());
|
||||
if (!isExactKeyMatch &&
|
||||
core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||
if (!isExactKeyMatch && core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(`Restored cache key doesn't match the given input key. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
|
||||
}
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
|
|
|
@ -44,7 +44,7 @@ async function restoreImpl(
|
|||
);
|
||||
|
||||
if (!cacheKey) {
|
||||
if (core.getBooleanInput(Inputs.FailOnCacheMiss) == true) {
|
||||
if (core.getBooleanInput(Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(
|
||||
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
|
||||
);
|
||||
|
@ -68,10 +68,7 @@ async function restoreImpl(
|
|||
);
|
||||
|
||||
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
|
||||
if (
|
||||
!isExactKeyMatch &&
|
||||
core.getBooleanInput(Inputs.FailOnCacheMiss) == true
|
||||
) {
|
||||
if (!isExactKeyMatch && core.getBooleanInput(Inputs.FailOnCacheMiss)) {
|
||||
throw new Error(
|
||||
`Restored cache key doesn't match the given input key. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ interface CacheInput {
|
|||
key: string;
|
||||
restoreKeys?: string[];
|
||||
enableCrossOsArchive?: boolean;
|
||||
failOnCacheMiss?: boolean;
|
||||
failOnCacheMiss?: string;
|
||||
}
|
||||
|
||||
export function setInputs(input: CacheInput): void {
|
||||
|
@ -29,7 +29,7 @@ export function setInputs(input: CacheInput): void {
|
|||
input.enableCrossOsArchive.toString()
|
||||
);
|
||||
input.failOnCacheMiss &&
|
||||
setInput(Inputs.FailOnCacheMiss, String(input.failOnCacheMiss));
|
||||
setInput(Inputs.FailOnCacheMiss, input.failOnCacheMiss);
|
||||
}
|
||||
|
||||
export function clearInputs(): void {
|
||||
|
|
Loading…
Add table
Reference in a new issue