1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-06-07 14:50:24 +02:00

Changes after rebase

This commit is contained in:
Marc Mueller 2023-01-08 11:03:38 +01:00
parent 64ae8e04f8
commit ec9f13e3be
7 changed files with 34 additions and 20 deletions

View file

@ -34,6 +34,7 @@ async function restoreImpl(
const enableCrossOsArchive = utils.getInputAsBool(
Inputs.EnableCrossOsArchive
);
const failOnCacheMiss = utils.getInputAsBool(Inputs.FailOnCacheMiss);
const cacheKey = await cache.restoreCache(
cachePaths,
@ -44,7 +45,7 @@ async function restoreImpl(
);
if (!cacheKey) {
if (core.getBooleanInput(Inputs.FailOnCacheMiss)) {
if (failOnCacheMiss) {
throw new Error(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
);
@ -68,7 +69,7 @@ async function restoreImpl(
);
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
if (!isExactKeyMatch && core.getBooleanInput(Inputs.FailOnCacheMiss)) {
if (!isExactKeyMatch && 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}`
);

View file

@ -14,13 +14,12 @@ interface CacheInput {
key: string;
restoreKeys?: string[];
enableCrossOsArchive?: boolean;
failOnCacheMiss?: string;
failOnCacheMiss?: boolean;
}
export function setInputs(input: CacheInput): void {
setInput(Inputs.Path, input.path);
setInput(Inputs.Key, input.key);
setInput(Inputs.FailOnCacheMiss, "false");
input.restoreKeys &&
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
input.enableCrossOsArchive !== undefined &&
@ -28,15 +27,15 @@ export function setInputs(input: CacheInput): void {
Inputs.EnableCrossOsArchive,
input.enableCrossOsArchive.toString()
);
input.failOnCacheMiss &&
setInput(Inputs.FailOnCacheMiss, input.failOnCacheMiss);
input.failOnCacheMiss !== undefined &&
setInput(Inputs.FailOnCacheMiss, input.failOnCacheMiss.toString());
}
export function clearInputs(): void {
delete process.env[getInputName(Inputs.Path)];
delete process.env[getInputName(Inputs.Key)];
delete process.env[getInputName(Inputs.RestoreKeys)];
delete process.env[getInputName(Inputs.FailOnCacheMiss)];
delete process.env[getInputName(Inputs.UploadChunkSize)];
delete process.env[getInputName(Inputs.EnableCrossOsArchive)];
delete process.env[getInputName(Inputs.FailOnCacheMiss)];
}