mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-16 15:41:15 +01:00
Always output explicit "false" to prevent hijacking
This commit is contained in:
parent
7214f3c546
commit
f04cc738d7
4 changed files with 17 additions and 14 deletions
|
@ -177,7 +177,7 @@ test("restore with cache found for key", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
||||
|
@ -226,7 +226,7 @@ test("restore with cache found for restore key", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache restored from key: ${restoreKey}`
|
||||
|
@ -271,7 +271,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
|
@ -322,7 +322,7 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
|
|
|
@ -83,7 +83,7 @@ test("restore without AC available should no-op", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -103,7 +103,7 @@ test("restore on GHES without AC available should no-op", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -145,7 +145,7 @@ test("restore on GHES with AC available ", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
||||
|
@ -371,7 +371,7 @@ test("restore with cache found for key", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
||||
|
@ -417,7 +417,7 @@ test("restore with cache found for restore key", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache restored from key: ${restoreKey}`
|
||||
|
@ -465,7 +465,7 @@ test("restore with lookup-only set", async () => {
|
|||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||
"save-always-d18d746b9",
|
||||
""
|
||||
"false"
|
||||
);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
|
|
|
@ -86,7 +86,7 @@ test("restore with no cache found", async () => {
|
|||
);
|
||||
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "");
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "false");
|
||||
expect(outputMock).toHaveBeenCalledTimes(2);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
|
@ -170,7 +170,7 @@ test("restore with cache found for key", async () => {
|
|||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "");
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "false");
|
||||
|
||||
expect(outputMock).toHaveBeenCalledTimes(4);
|
||||
|
||||
|
@ -214,7 +214,7 @@ test("restore with cache found for restore key", async () => {
|
|||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "");
|
||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "false");
|
||||
|
||||
expect(outputMock).toHaveBeenCalledTimes(4);
|
||||
|
||||
|
|
|
@ -13,7 +13,10 @@ export async function restoreImpl(
|
|||
stateProvider: IStateProvider,
|
||||
earlyExit?: boolean | undefined
|
||||
): Promise<string | undefined> {
|
||||
core.setOutput(Outputs.SaveAlways, core.getInput(Inputs.SaveAlways));
|
||||
core.setOutput(
|
||||
Outputs.SaveAlways,
|
||||
core.getInput(Inputs.SaveAlways) || "false"
|
||||
);
|
||||
|
||||
try {
|
||||
if (!utils.isCacheFeatureAvailable()) {
|
||||
|
|
Loading…
Reference in a new issue