mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-30 23:59:16 +01:00
Some cleanup
This commit is contained in:
parent
9c5a42a7c9
commit
01d96636a0
7 changed files with 18 additions and 61395 deletions
|
@ -366,7 +366,7 @@ test("restore with enabling save on any failure feature", async () => {
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Fail restore with strict restore enabled when primary key not found", async () => {
|
test("Fail restore when fail on cache miss is enabled and primary key not found", async () => {
|
||||||
const path = "node_modules";
|
const path = "node_modules";
|
||||||
const key = "node-test";
|
const key = "node-test";
|
||||||
const restoreKey = "node-";
|
const restoreKey = "node-";
|
||||||
|
@ -395,12 +395,12 @@ test("Fail restore with strict restore enabled when primary key not found", asyn
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
|
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
expect(failedMock).toHaveBeenCalledWith(
|
expect(failedMock).toHaveBeenCalledWith(
|
||||||
`Cache with the given input key ${key} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
|
`Cache with the given input key ${key} is not found, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`
|
||||||
);
|
);
|
||||||
expect(failedMock).toHaveBeenCalledTimes(1);
|
expect(failedMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Fail restore with strict restore enabled when primary key doesn't match restored key", async () => {
|
test("Fail restore when fail on cache miss is enabled and primary key doesn't match restored key", async () => {
|
||||||
const path = "node_modules";
|
const path = "node_modules";
|
||||||
const key = "node-test";
|
const key = "node-test";
|
||||||
const restoreKey = "node-";
|
const restoreKey = "node-";
|
||||||
|
@ -430,7 +430,7 @@ test("Fail restore with strict restore enabled when primary key doesn't match re
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
|
||||||
|
|
||||||
expect(failedMock).toHaveBeenCalledWith(
|
expect(failedMock).toHaveBeenCalledWith(
|
||||||
`Restored cache key doesn't match the given input key ${key}, hence exiting the workflow as the strict-restore requirement is not met.`
|
`Restored cache key doesn't match the given input key ${key}, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`
|
||||||
);
|
);
|
||||||
expect(failedMock).toHaveBeenCalledTimes(1);
|
expect(failedMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
61377
dist/restore-only/index.js
vendored
61377
dist/restore-only/index.js
vendored
File diff suppressed because one or more lines are too long
10
dist/restore/index.js
vendored
10
dist/restore/index.js
vendored
|
@ -4971,7 +4971,7 @@ var Inputs;
|
||||||
Inputs["Path"] = "path";
|
Inputs["Path"] = "path";
|
||||||
Inputs["RestoreKeys"] = "restore-keys";
|
Inputs["RestoreKeys"] = "restore-keys";
|
||||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||||
Inputs["StrictRestore"] = "strict-restore";
|
Inputs["FailOnCacheMiss"] = "fail-on-cache-miss";
|
||||||
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
||||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
|
@ -49022,8 +49022,8 @@ function run() {
|
||||||
core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to true, the cache will be saved despite of any failure in the build.`);
|
core.info(`Input Variable ${constants_1.Variables.SaveCacheOnAnyFailure} is set to true, the cache will be saved despite of any failure in the build.`);
|
||||||
}
|
}
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
if (core.getBooleanInput(constants_1.Inputs.StrictRestore) == true) {
|
if (core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||||
throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`);
|
throw new Error(`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`);
|
||||||
}
|
}
|
||||||
core.info(`Cache not found for input keys: ${[
|
core.info(`Cache not found for input keys: ${[
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
@ -49036,8 +49036,8 @@ function run() {
|
||||||
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
||||||
utils.setCacheHitOutput(isExactKeyMatch);
|
utils.setCacheHitOutput(isExactKeyMatch);
|
||||||
if (!isExactKeyMatch &&
|
if (!isExactKeyMatch &&
|
||||||
core.getBooleanInput(constants_1.Inputs.StrictRestore) == true) {
|
core.getBooleanInput(constants_1.Inputs.FailOnCacheMiss) == true) {
|
||||||
throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`);
|
throw new Error(`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`);
|
||||||
}
|
}
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
}
|
}
|
||||||
|
|
2
dist/save/index.js
vendored
2
dist/save/index.js
vendored
|
@ -4971,7 +4971,7 @@ var Inputs;
|
||||||
Inputs["Path"] = "path";
|
Inputs["Path"] = "path";
|
||||||
Inputs["RestoreKeys"] = "restore-keys";
|
Inputs["RestoreKeys"] = "restore-keys";
|
||||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||||
Inputs["StrictRestore"] = "strict-restore";
|
Inputs["FailOnCacheMiss"] = "fail-on-cache-miss";
|
||||||
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
||||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
|
|
|
@ -3,7 +3,7 @@ export enum Inputs {
|
||||||
Path = "path",
|
Path = "path",
|
||||||
RestoreKeys = "restore-keys",
|
RestoreKeys = "restore-keys",
|
||||||
UploadChunkSize = "upload-chunk-size",
|
UploadChunkSize = "upload-chunk-size",
|
||||||
StrictRestore = "strict-restore",
|
FailOnCacheMiss = "fail-on-cache-miss",
|
||||||
SaveOnAnyFailure = "save-on-any-failure"
|
SaveOnAnyFailure = "save-on-any-failure"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ async function run(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cacheKey) {
|
if (!cacheKey) {
|
||||||
if (core.getBooleanInput(Inputs.StrictRestore) == true) {
|
if (core.getBooleanInput(Inputs.FailOnCacheMiss) == true) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the strict-restore requirement is not met.`
|
`Cache with the given input key ${primaryKey} is not found, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
core.info(
|
core.info(
|
||||||
|
@ -69,10 +69,10 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isExactKeyMatch &&
|
!isExactKeyMatch &&
|
||||||
core.getBooleanInput(Inputs.StrictRestore) == true
|
core.getBooleanInput(Inputs.FailOnCacheMiss) == true
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the strict-restore requirement is not met.`
|
`Restored cache key doesn't match the given input key ${primaryKey}, hence exiting the workflow as the fail-on-cache-miss requirement is not met.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
core.info(`Cache restored from key: ${cacheKey}`);
|
core.info(`Cache restored from key: ${cacheKey}`);
|
||||||
|
|
|
@ -21,10 +21,10 @@ export function setInputs(input: CacheInput): void {
|
||||||
setInput(Inputs.Path, input.path);
|
setInput(Inputs.Path, input.path);
|
||||||
setInput(Inputs.Key, input.key);
|
setInput(Inputs.Key, input.key);
|
||||||
setInput(Inputs.SaveOnAnyFailure, "false");
|
setInput(Inputs.SaveOnAnyFailure, "false");
|
||||||
setInput(Inputs.StrictRestore, "false");
|
setInput(Inputs.FailOnCacheMiss, "false");
|
||||||
input.restoreKeys &&
|
input.restoreKeys &&
|
||||||
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
||||||
input.strictRestore && setInput(Inputs.StrictRestore, input.strictRestore);
|
input.strictRestore && setInput(Inputs.FailOnCacheMiss, input.strictRestore);
|
||||||
input.saveOnAnyFailure &&
|
input.saveOnAnyFailure &&
|
||||||
setInput(Inputs.SaveOnAnyFailure, input.saveOnAnyFailure);
|
setInput(Inputs.SaveOnAnyFailure, input.saveOnAnyFailure);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export function clearInputs(): void {
|
||||||
delete process.env[getInputName(Inputs.Path)];
|
delete process.env[getInputName(Inputs.Path)];
|
||||||
delete process.env[getInputName(Inputs.Key)];
|
delete process.env[getInputName(Inputs.Key)];
|
||||||
delete process.env[getInputName(Inputs.RestoreKeys)];
|
delete process.env[getInputName(Inputs.RestoreKeys)];
|
||||||
delete process.env[getInputName(Inputs.StrictRestore)];
|
delete process.env[getInputName(Inputs.FailOnCacheMiss)];
|
||||||
delete process.env[getInputName(Inputs.SaveOnAnyFailure)];
|
delete process.env[getInputName(Inputs.SaveOnAnyFailure)];
|
||||||
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue