mirror of
https://github.com/actions/cache.git
synced 2025-06-21 17:15:20 +08:00

* add logic to not save state in restore step when setting `reeval` to true * create infrastructure to set `Inputs.Reeval` input variable within tests * `Inputs.Reeval` set to false for all save & restore tests
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { Inputs } from "../constants";
|
|
|
|
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
|
|
function getInputName(name: string): string {
|
|
return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
|
|
}
|
|
|
|
export function setInput(name: string, value: string): void {
|
|
process.env[getInputName(name)] = value;
|
|
}
|
|
|
|
interface CacheInput {
|
|
path: string;
|
|
key: string;
|
|
// onlyRestore: string;
|
|
// reeval: string;
|
|
restoreKeys?: string[];
|
|
}
|
|
|
|
export function setInputs(input: CacheInput): void {
|
|
setInput(Inputs.Path, input.path);
|
|
setInput(Inputs.Key, input.key);
|
|
// setInput(Inputs.OnlyRestore, input.onlyRestore);
|
|
// setInput(Inputs.Reeval, input.reeval);
|
|
input.restoreKeys &&
|
|
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
|
}
|
|
|
|
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.UploadChunkSize)];
|
|
delete process.env[getInputName(Inputs.OnlyRestore)];
|
|
delete process.env[getInputName(Inputs.Reeval)];
|
|
}
|