mirror of
https://gitea.com/actions/cache.git
synced 2024-11-23 04:42:28 +08:00
Always output explicit "false" to prevent hijacking
This commit is contained in:
parent
f908277314
commit
727a4d2137
|
@ -177,7 +177,7 @@ test("restore with cache found for key", async () => {
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
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("cache-hit", "false");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: ${restoreKey}`
|
`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).toHaveBeenCalledTimes(1);
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(failedMock).toHaveBeenCalledWith(
|
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("cache-hit", "false");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
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("cache-hit", "false");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"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("cache-hit", "false");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"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("cache-hit", "true");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
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("cache-hit", "true");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
|
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("cache-hit", "false");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: ${restoreKey}`
|
`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("cache-hit", "true");
|
||||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
expect(setCacheHitOutputMock).toHaveBeenCalledWith(
|
||||||
"save-always-d18d746b9",
|
"save-always-d18d746b9",
|
||||||
""
|
"false"
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
|
|
|
@ -86,7 +86,7 @@ test("restore with no cache found", async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
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(outputMock).toHaveBeenCalledTimes(2);
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
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-primary-key", key);
|
||||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
|
expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||||
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", key);
|
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", key);
|
||||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "");
|
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "false");
|
||||||
|
|
||||||
expect(outputMock).toHaveBeenCalledTimes(4);
|
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-primary-key", key);
|
||||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
|
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||||
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
|
expect(outputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
|
||||||
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "");
|
expect(outputMock).toHaveBeenCalledWith("save-always-d18d746b9", "false");
|
||||||
|
|
||||||
expect(outputMock).toHaveBeenCalledTimes(4);
|
expect(outputMock).toHaveBeenCalledTimes(4);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,10 @@ import * as utils from "./utils/actionUtils";
|
||||||
export async function restoreImpl(
|
export async function restoreImpl(
|
||||||
stateProvider: IStateProvider
|
stateProvider: IStateProvider
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
core.setOutput(Outputs.SaveAlways, core.getInput(Inputs.SaveAlways));
|
core.setOutput(
|
||||||
|
Outputs.SaveAlways,
|
||||||
|
core.getInput(Inputs.SaveAlways) || "false"
|
||||||
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!utils.isCacheFeatureAvailable()) {
|
if (!utils.isCacheFeatureAvailable()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user