mirror of
https://github.com/actions/cache.git
synced 2024-11-15 18:13:52 +08:00
Some cleanup
This commit is contained in:
parent
9c5a42a7c9
commit
01d96636a0
@ -366,7 +366,7 @@ test("restore with enabling save on any failure feature", async () => {
|
||||
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 key = "node-test";
|
||||
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(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);
|
||||
});
|
||||
|
||||
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 key = "node-test";
|
||||
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(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);
|
||||
});
|
||||
|
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["RestoreKeys"] = "restore-keys";
|
||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||
Inputs["StrictRestore"] = "strict-restore";
|
||||
Inputs["FailOnCacheMiss"] = "fail-on-cache-miss";
|
||||
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||
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.`);
|
||||
}
|
||||
if (!cacheKey) {
|
||||
if (core.getBooleanInput(constants_1.Inputs.StrictRestore) == 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.`);
|
||||
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 fail-on-cache-miss requirement is not met.`);
|
||||
}
|
||||
core.info(`Cache not found for input keys: ${[
|
||||
primaryKey,
|
||||
@ -49036,8 +49036,8 @@ function run() {
|
||||
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
|
||||
utils.setCacheHitOutput(isExactKeyMatch);
|
||||
if (!isExactKeyMatch &&
|
||||
core.getBooleanInput(constants_1.Inputs.StrictRestore) == 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.`);
|
||||
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 fail-on-cache-miss requirement is not met.`);
|
||||
}
|
||||
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["RestoreKeys"] = "restore-keys";
|
||||
Inputs["UploadChunkSize"] = "upload-chunk-size";
|
||||
Inputs["StrictRestore"] = "strict-restore";
|
||||
Inputs["FailOnCacheMiss"] = "fail-on-cache-miss";
|
||||
Inputs["SaveOnAnyFailure"] = "save-on-any-failure";
|
||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||
var Outputs;
|
||||
|
@ -3,7 +3,7 @@ export enum Inputs {
|
||||
Path = "path",
|
||||
RestoreKeys = "restore-keys",
|
||||
UploadChunkSize = "upload-chunk-size",
|
||||
StrictRestore = "strict-restore",
|
||||
FailOnCacheMiss = "fail-on-cache-miss",
|
||||
SaveOnAnyFailure = "save-on-any-failure"
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
if (!cacheKey) {
|
||||
if (core.getBooleanInput(Inputs.StrictRestore) == true) {
|
||||
if (core.getBooleanInput(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.`
|
||||
`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(
|
||||
@ -69,10 +69,10 @@ async function run(): Promise<void> {
|
||||
|
||||
if (
|
||||
!isExactKeyMatch &&
|
||||
core.getBooleanInput(Inputs.StrictRestore) == true
|
||||
core.getBooleanInput(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.`
|
||||
`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}`);
|
||||
|
@ -21,10 +21,10 @@ export function setInputs(input: CacheInput): void {
|
||||
setInput(Inputs.Path, input.path);
|
||||
setInput(Inputs.Key, input.key);
|
||||
setInput(Inputs.SaveOnAnyFailure, "false");
|
||||
setInput(Inputs.StrictRestore, "false");
|
||||
setInput(Inputs.FailOnCacheMiss, "false");
|
||||
input.restoreKeys &&
|
||||
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
||||
input.strictRestore && setInput(Inputs.StrictRestore, input.strictRestore);
|
||||
input.strictRestore && setInput(Inputs.FailOnCacheMiss, input.strictRestore);
|
||||
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.Key)];
|
||||
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.UploadChunkSize)];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user