mirror of
https://github.com/actions/cache.git
synced 2026-07-14 19:23:55 +08:00
Compare commits
14 Commits
v5.0.0
...
a975f6a8e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a975f6a8e3 | ||
|
|
b15dd68d6e | ||
|
|
5b9d385f6f | ||
|
|
e4df80e331 | ||
|
|
114dd526d5 | ||
|
|
6018dbe2dc | ||
|
|
9255dc7a25 | ||
|
|
8ff5423e8b | ||
|
|
9233019a15 | ||
|
|
b975f2bb84 | ||
|
|
d0a0e18134 | ||
|
|
74de208dcf | ||
|
|
ac7f1152ea | ||
|
|
b0f846b50b |
2
.licenses/npm/@actions/cache.dep.yml
generated
2
.licenses/npm/@actions/cache.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 5.0.0
|
version: 5.0.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions cache lib
|
summary: Actions cache lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
||||||
|
|||||||
2
.licenses/npm/fast-xml-parser.dep.yml
generated
2
.licenses/npm/fast-xml-parser.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: fast-xml-parser
|
name: fast-xml-parser
|
||||||
version: 5.3.2
|
version: 5.3.3
|
||||||
type: npm
|
type: npm
|
||||||
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
|
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
2
.licenses/npm/strnum.dep.yml
generated
2
.licenses/npm/strnum.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: strnum
|
name: strnum
|
||||||
version: 2.1.1
|
version: 2.1.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: Parse String to Number based on configuration
|
summary: Parse String to Number based on configuration
|
||||||
homepage:
|
homepage:
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir
|
|||||||
* `key` - An explicit key for a cache entry. See [creating a cache key](#creating-a-cache-key).
|
* `key` - An explicit key for a cache entry. See [creating a cache key](#creating-a-cache-key).
|
||||||
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||||
* `restore-keys` - An ordered multiline string listing the prefix-matched keys, that are used for restoring stale cache if no cache hit occurred for key.
|
* `restore-keys` - An ordered multiline string listing the prefix-matched keys, that are used for restoring stale cache if no cache hit occurred for key.
|
||||||
|
* `compression-level` - Compression level to use when creating cache archives (applies to the save step of the cache action). Use `0` for no compression and `9` for maximum compression. Defaults to the compression tool's standard level when unset.
|
||||||
* `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false`
|
* `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false`
|
||||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
||||||
* `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false`
|
* `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false`
|
||||||
@@ -359,7 +360,7 @@ We are taking the following steps to better direct requests related to GitHub Ac
|
|||||||
|
|
||||||
1. We will be directing questions and support requests to our [Community Discussions area](https://github.com/orgs/community/discussions/categories/actions)
|
1. We will be directing questions and support requests to our [Community Discussions area](https://github.com/orgs/community/discussions/categories/actions)
|
||||||
|
|
||||||
2. High Priority bugs can be reported through Community Discussions or you can report these to our support team https://support.github.com/contact/bug-report.
|
2. High Priority bugs can be reported through Community Discussions or you can report these to our support team <https://support.github.com/contact/bug-report>.
|
||||||
|
|
||||||
3. Security Issues should be handled as per our [security.md](SECURITY.md).
|
3. Security Issues should be handled as per our [security.md](SECURITY.md).
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### 5.0.1
|
||||||
|
|
||||||
|
- Update `@azure/storage-blob` to `^12.29.1` via `@actions/cache@5.0.1` [#1685](https://github.com/actions/cache/pull/1685)
|
||||||
|
|
||||||
### 5.0.0
|
### 5.0.0
|
||||||
|
|
||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as cache from "@actions/cache";
|
import * as cache from "@actions/cache";
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
import * as zlib from "zlib";
|
||||||
|
|
||||||
import { Events, RefKey } from "../src/constants";
|
import { Events, RefKey } from "../src/constants";
|
||||||
import * as actionUtils from "../src/utils/actionUtils";
|
import * as actionUtils from "../src/utils/actionUtils";
|
||||||
@@ -24,6 +25,11 @@ beforeEach(() => {
|
|||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
delete process.env["ZSTD_CLEVEL"];
|
||||||
|
delete process.env["GZIP"];
|
||||||
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
process.env = pristineEnv;
|
process.env = pristineEnv;
|
||||||
});
|
});
|
||||||
@@ -177,6 +183,61 @@ test("getInputAsInt returns undefined if input is invalid or NaN", () => {
|
|||||||
expect(actionUtils.getInputAsInt("foo")).toBeUndefined();
|
expect(actionUtils.getInputAsInt("foo")).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("getCompressionLevel returns undefined if input not set", () => {
|
||||||
|
expect(actionUtils.getCompressionLevel("undefined")).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getCompressionLevel returns value if input is valid", () => {
|
||||||
|
testUtils.setInput("foo", "9");
|
||||||
|
expect(actionUtils.getCompressionLevel("foo")).toBe(9);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getCompressionLevel allows zero for no compression", () => {
|
||||||
|
testUtils.setInput("foo", "0");
|
||||||
|
expect(actionUtils.getCompressionLevel("foo")).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getCompressionLevel returns undefined and warns for negative values", () => {
|
||||||
|
const infoMock = jest.spyOn(core, "info");
|
||||||
|
|
||||||
|
testUtils.setInput("foo", "-3");
|
||||||
|
expect(actionUtils.getCompressionLevel("foo")).toBeUndefined();
|
||||||
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
|
"[warning]Invalid compression-level provided: -3. Expected a value between 0 (no compression) and 9 (maximum compression)."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getCompressionLevel returns undefined and warns if input is too large", () => {
|
||||||
|
const infoMock = jest.spyOn(core, "info");
|
||||||
|
testUtils.setInput("foo", "11");
|
||||||
|
expect(actionUtils.getCompressionLevel("foo")).toBeUndefined();
|
||||||
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
|
"[warning]Invalid compression-level provided: 11. Expected a value between 0 (no compression) and 9 (maximum compression)."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("setCompressionLevel sets compression env vars", () => {
|
||||||
|
actionUtils.setCompressionLevel(7);
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBe("7");
|
||||||
|
expect(process.env["GZIP"]).toBe("-7");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("setCompressionLevel sets no-compression flag when zero", () => {
|
||||||
|
actionUtils.setCompressionLevel(0);
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBe("0");
|
||||||
|
expect(process.env["GZIP"]).toBe("-0");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("higher compression level produces smaller gzip output", () => {
|
||||||
|
const data = Buffer.alloc(8 * 1024, "A");
|
||||||
|
|
||||||
|
const level0 = zlib.gzipSync(data, { level: 0 });
|
||||||
|
const level9 = zlib.gzipSync(data, { level: 9 });
|
||||||
|
|
||||||
|
expect(level0.byteLength).toBeGreaterThan(level9.byteLength);
|
||||||
|
expect(level0.byteLength - level9.byteLength).toBeGreaterThan(1000);
|
||||||
|
});
|
||||||
|
|
||||||
test("getInputAsInt throws if required and value missing", () => {
|
test("getInputAsInt throws if required and value missing", () => {
|
||||||
expect(() =>
|
expect(() =>
|
||||||
actionUtils.getInputAsInt("undefined", { required: true })
|
actionUtils.getInputAsInt("undefined", { required: true })
|
||||||
|
|||||||
@@ -43,6 +43,22 @@ beforeAll(() => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "getCompressionLevel").mockImplementation(
|
||||||
|
(name, options) => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.getCompressionLevel(name, options);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "setCompressionLevel").mockImplementation(
|
||||||
|
compressionLevel => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.setCompressionLevel(compressionLevel);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||||
(key, cacheResult) => {
|
(key, cacheResult) => {
|
||||||
return jest
|
return jest
|
||||||
@@ -71,6 +87,8 @@ afterEach(() => {
|
|||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env[Events.Key];
|
delete process.env[Events.Key];
|
||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
|
delete process.env["ZSTD_CLEVEL"];
|
||||||
|
delete process.env["GZIP"];
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save with valid inputs uploads a cache", async () => {
|
test("save with valid inputs uploads a cache", async () => {
|
||||||
@@ -92,6 +110,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
const inputPath = "node_modules";
|
const inputPath = "node_modules";
|
||||||
testUtils.setInput(Inputs.Path, inputPath);
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "8");
|
||||||
|
|
||||||
const cacheId = 4;
|
const cacheId = 4;
|
||||||
const saveCacheMock = jest
|
const saveCacheMock = jest
|
||||||
@@ -102,6 +121,60 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
|
|
||||||
await saveRun();
|
await saveRun();
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBe("8");
|
||||||
|
expect(process.env["GZIP"]).toBe("-8");
|
||||||
|
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
[inputPath],
|
||||||
|
primaryKey,
|
||||||
|
{
|
||||||
|
uploadChunkSize: 4000000
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("negative compression level leaves env unset in combined flow", async () => {
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
const setCompressionLevelMock = jest.spyOn(
|
||||||
|
actionUtils,
|
||||||
|
"setCompressionLevel"
|
||||||
|
);
|
||||||
|
|
||||||
|
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
||||||
|
const savedCacheKey = "Linux-node-";
|
||||||
|
|
||||||
|
jest.spyOn(core, "getState")
|
||||||
|
// Cache Entry State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return primaryKey;
|
||||||
|
})
|
||||||
|
// Cache Key State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return savedCacheKey;
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputPath = "node_modules";
|
||||||
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "-5");
|
||||||
|
|
||||||
|
const cacheId = 4;
|
||||||
|
const saveCacheMock = jest
|
||||||
|
.spyOn(cache, "saveCache")
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return Promise.resolve(cacheId);
|
||||||
|
});
|
||||||
|
|
||||||
|
await saveRun();
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBeUndefined();
|
||||||
|
expect(process.env["GZIP"]).toBeUndefined();
|
||||||
|
expect(setCompressionLevelMock).not.toHaveBeenCalled();
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
[inputPath],
|
[inputPath],
|
||||||
|
|||||||
@@ -40,6 +40,22 @@ beforeAll(() => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "getCompressionLevel").mockImplementation(
|
||||||
|
(name, options) => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.getCompressionLevel(name, options);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "setCompressionLevel").mockImplementation(
|
||||||
|
compressionLevel => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.setCompressionLevel(compressionLevel);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||||
(key, cacheResult) => {
|
(key, cacheResult) => {
|
||||||
return jest
|
return jest
|
||||||
@@ -69,6 +85,8 @@ afterEach(() => {
|
|||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env[Events.Key];
|
delete process.env[Events.Key];
|
||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
|
delete process.env["ZSTD_CLEVEL"];
|
||||||
|
delete process.env["GZIP"];
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save with invalid event outputs warning", async () => {
|
test("save with invalid event outputs warning", async () => {
|
||||||
@@ -406,3 +424,151 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
|
|
||||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("save applies compression level when provided", async () => {
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
|
||||||
|
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
||||||
|
const savedCacheKey = "Linux-node-";
|
||||||
|
|
||||||
|
jest.spyOn(core, "getState")
|
||||||
|
// Cache Entry State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return savedCacheKey;
|
||||||
|
})
|
||||||
|
// Cache Key State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return primaryKey;
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputPath = "node_modules";
|
||||||
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "9");
|
||||||
|
|
||||||
|
const cacheId = 4;
|
||||||
|
const saveCacheMock = jest
|
||||||
|
.spyOn(cache, "saveCache")
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return Promise.resolve(cacheId);
|
||||||
|
});
|
||||||
|
|
||||||
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBe("9");
|
||||||
|
expect(process.env["GZIP"]).toBe("-9");
|
||||||
|
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
[inputPath],
|
||||||
|
primaryKey,
|
||||||
|
{
|
||||||
|
uploadChunkSize: 4000000
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("save skips setting compression when value is out of range", async () => {
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
const setCompressionLevelMock = jest.spyOn(
|
||||||
|
actionUtils,
|
||||||
|
"setCompressionLevel"
|
||||||
|
);
|
||||||
|
|
||||||
|
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
||||||
|
const savedCacheKey = "Linux-node-";
|
||||||
|
|
||||||
|
jest.spyOn(core, "getState")
|
||||||
|
// Cache Entry State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return savedCacheKey;
|
||||||
|
})
|
||||||
|
// Cache Key State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return primaryKey;
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputPath = "node_modules";
|
||||||
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "99");
|
||||||
|
|
||||||
|
const cacheId = 4;
|
||||||
|
const saveCacheMock = jest
|
||||||
|
.spyOn(cache, "saveCache")
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return Promise.resolve(cacheId);
|
||||||
|
});
|
||||||
|
|
||||||
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBeUndefined();
|
||||||
|
expect(process.env["GZIP"]).toBeUndefined();
|
||||||
|
expect(setCompressionLevelMock).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
[inputPath],
|
||||||
|
primaryKey,
|
||||||
|
{
|
||||||
|
uploadChunkSize: 4000000
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("save skips setting compression when value is negative", async () => {
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
const setCompressionLevelMock = jest.spyOn(
|
||||||
|
actionUtils,
|
||||||
|
"setCompressionLevel"
|
||||||
|
);
|
||||||
|
|
||||||
|
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
||||||
|
const savedCacheKey = "Linux-node-";
|
||||||
|
|
||||||
|
jest.spyOn(core, "getState")
|
||||||
|
// Cache Entry State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return savedCacheKey;
|
||||||
|
})
|
||||||
|
// Cache Key State
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return primaryKey;
|
||||||
|
});
|
||||||
|
|
||||||
|
const inputPath = "node_modules";
|
||||||
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "-1");
|
||||||
|
|
||||||
|
const cacheId = 4;
|
||||||
|
const saveCacheMock = jest
|
||||||
|
.spyOn(cache, "saveCache")
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return Promise.resolve(cacheId);
|
||||||
|
});
|
||||||
|
|
||||||
|
await saveImpl(new StateProvider());
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBeUndefined();
|
||||||
|
expect(process.env["GZIP"]).toBeUndefined();
|
||||||
|
expect(setCompressionLevelMock).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
[inputPath],
|
||||||
|
primaryKey,
|
||||||
|
{
|
||||||
|
uploadChunkSize: 4000000
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|||||||
@@ -43,6 +43,22 @@ beforeAll(() => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "getCompressionLevel").mockImplementation(
|
||||||
|
(name, options) => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.getCompressionLevel(name, options);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "setCompressionLevel").mockImplementation(
|
||||||
|
compressionLevel => {
|
||||||
|
return jest
|
||||||
|
.requireActual("../src/utils/actionUtils")
|
||||||
|
.setCompressionLevel(compressionLevel);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||||
(key, cacheResult) => {
|
(key, cacheResult) => {
|
||||||
return jest
|
return jest
|
||||||
@@ -71,6 +87,8 @@ afterEach(() => {
|
|||||||
testUtils.clearInputs();
|
testUtils.clearInputs();
|
||||||
delete process.env[Events.Key];
|
delete process.env[Events.Key];
|
||||||
delete process.env[RefKey];
|
delete process.env[RefKey];
|
||||||
|
delete process.env["ZSTD_CLEVEL"];
|
||||||
|
delete process.env["GZIP"];
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save with valid inputs uploads a cache", async () => {
|
test("save with valid inputs uploads a cache", async () => {
|
||||||
@@ -82,6 +100,7 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
testUtils.setInput(Inputs.Key, primaryKey);
|
testUtils.setInput(Inputs.Key, primaryKey);
|
||||||
testUtils.setInput(Inputs.Path, inputPath);
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "0");
|
||||||
|
|
||||||
const cacheId = 4;
|
const cacheId = 4;
|
||||||
const saveCacheMock = jest
|
const saveCacheMock = jest
|
||||||
@@ -92,6 +111,45 @@ test("save with valid inputs uploads a cache", async () => {
|
|||||||
|
|
||||||
await saveOnlyRun();
|
await saveOnlyRun();
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBe("0");
|
||||||
|
expect(process.env["GZIP"]).toBe("-0");
|
||||||
|
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
|
[inputPath],
|
||||||
|
primaryKey,
|
||||||
|
{
|
||||||
|
uploadChunkSize: 4000000
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("negative compression level does not set env vars", async () => {
|
||||||
|
const failedMock = jest.spyOn(core, "setFailed");
|
||||||
|
|
||||||
|
const primaryKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";
|
||||||
|
|
||||||
|
const inputPath = "node_modules";
|
||||||
|
testUtils.setInput(Inputs.Key, primaryKey);
|
||||||
|
testUtils.setInput(Inputs.Path, inputPath);
|
||||||
|
testUtils.setInput(Inputs.UploadChunkSize, "4000000");
|
||||||
|
testUtils.setInput(Inputs.CompressionLevel, "-2");
|
||||||
|
|
||||||
|
const cacheId = 4;
|
||||||
|
const saveCacheMock = jest
|
||||||
|
.spyOn(cache, "saveCache")
|
||||||
|
.mockImplementationOnce(() => {
|
||||||
|
return Promise.resolve(cacheId);
|
||||||
|
});
|
||||||
|
|
||||||
|
await saveOnlyRun();
|
||||||
|
|
||||||
|
expect(process.env["ZSTD_CLEVEL"]).toBeUndefined();
|
||||||
|
expect(process.env["GZIP"]).toBeUndefined();
|
||||||
|
|
||||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||||
[inputPath],
|
[inputPath],
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ inputs:
|
|||||||
upload-chunk-size:
|
upload-chunk-size:
|
||||||
description: 'The chunk size used to split up large files during upload, in bytes'
|
description: 'The chunk size used to split up large files during upload, in bytes'
|
||||||
required: false
|
required: false
|
||||||
|
compression-level:
|
||||||
|
description: 'Compression level used when creating cache archives (save step only). Set 0 for no compression and 9 for maximum compression. Defaults to the compression tool defaults when unset'
|
||||||
|
required: false
|
||||||
enableCrossOsArchive:
|
enableCrossOsArchive:
|
||||||
description: 'An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms'
|
description: 'An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|||||||
314
dist/restore-only/index.js
vendored
314
dist/restore-only/index.js
vendored
File diff suppressed because one or more lines are too long
314
dist/restore/index.js
vendored
314
dist/restore/index.js
vendored
File diff suppressed because one or more lines are too long
318
dist/save-only/index.js
vendored
318
dist/save-only/index.js
vendored
File diff suppressed because one or more lines are too long
318
dist/save/index.js
vendored
318
dist/save/index.js
vendored
File diff suppressed because one or more lines are too long
41
package-lock.json
generated
41
package-lock.json
generated
@@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^5.0.0",
|
"@actions/cache": "^5.0.1",
|
||||||
"@actions/core": "^2.0.0",
|
"@actions/core": "^2.0.0",
|
||||||
"@actions/exec": "^2.0.0",
|
"@actions/exec": "^2.0.0",
|
||||||
"@actions/io": "^2.0.0"
|
"@actions/io": "^2.0.0"
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.1.tgz",
|
||||||
"integrity": "sha512-BZNTNrj2+x+INgAuA/Qi6mjS0AWwPqsbGU3MALrqIK9pH9aNdVPuKZNJHrKi/VDA/DE2voH1N4ZbLPT2fWQJxg==",
|
"integrity": "sha512-c+oH047Z2zmXLhjMZfEKjxZfv6Ou7T0sn5fhz6yupICXm5OOR47oZn5zxNO8MP7ttkxv5TOg3WsMrffri5Xhfw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^2.0.0",
|
"@actions/core": "^2.0.0",
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"@actions/io": "^2.0.0",
|
"@actions/io": "^2.0.0",
|
||||||
"@azure/abort-controller": "^1.1.0",
|
"@azure/abort-controller": "^1.1.0",
|
||||||
"@azure/core-rest-pipeline": "^1.22.0",
|
"@azure/core-rest-pipeline": "^1.22.0",
|
||||||
"@azure/storage-blob": "^12.13.0",
|
"@azure/storage-blob": "^12.29.1",
|
||||||
"@protobuf-ts/runtime-rpc": "^2.11.1",
|
"@protobuf-ts/runtime-rpc": "^2.11.1",
|
||||||
"semver": "^6.3.1"
|
"semver": "^6.3.1"
|
||||||
}
|
}
|
||||||
@@ -1762,6 +1762,7 @@
|
|||||||
"integrity": "sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==",
|
"integrity": "sha512-94EQTWZ40mzBc42ATNIBimBEDltSJ9RQHCC8vc/PDbxi4k8dVwUAv4o98dk50M1zB+JGFxp43FP7f8+FP8R6Sw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/regexpp": "^4.10.0",
|
"@eslint-community/regexpp": "^4.10.0",
|
||||||
"@typescript-eslint/scope-manager": "7.18.0",
|
"@typescript-eslint/scope-manager": "7.18.0",
|
||||||
@@ -1796,6 +1797,7 @@
|
|||||||
"integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
|
"integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "7.18.0",
|
"@typescript-eslint/scope-manager": "7.18.0",
|
||||||
"@typescript-eslint/types": "7.18.0",
|
"@typescript-eslint/types": "7.18.0",
|
||||||
@@ -2025,6 +2027,7 @@
|
|||||||
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -2425,9 +2428,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.9.6",
|
"version": "2.9.7",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.7.tgz",
|
||||||
"integrity": "sha512-v9BVVpOTLB59C9E7aSnmIF8h7qRsFpx+A2nugVMTszEOMcfjlZMsXRm4LF23I3Z9AJxc8ANpIvzbzONoX9VJlg==",
|
"integrity": "sha512-k9xFKplee6KIio3IDbwj+uaCLpqzOwakOgmqzPezM0sFJlFKcg30vk2wOiAJtkTSfx0SSQDSe8q+mWA/fSH5Zg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -2477,6 +2480,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.9.0",
|
"baseline-browser-mapping": "^2.9.0",
|
||||||
"caniuse-lite": "^1.0.30001759",
|
"caniuse-lite": "^1.0.30001759",
|
||||||
@@ -3181,6 +3185,7 @@
|
|||||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.2.0",
|
"@eslint-community/eslint-utils": "^4.2.0",
|
||||||
"@eslint-community/regexpp": "^4.6.1",
|
"@eslint-community/regexpp": "^4.6.1",
|
||||||
@@ -3237,6 +3242,7 @@
|
|||||||
"integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
|
"integrity": "sha512-iI1f+D2ViGn+uvv5HuHVUamg8ll4tN+JRHGc6IJi4TP9Kl976C57fzPXgseXNs8v0iA8aSJpHsTWjDb9QJamGQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"eslint-config-prettier": "bin/cli.js"
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
},
|
},
|
||||||
@@ -3786,9 +3792,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/fast-xml-parser": {
|
"node_modules/fast-xml-parser": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.3.3.tgz",
|
||||||
"integrity": "sha512-n8v8b6p4Z1sMgqRmqLJm3awW4NX7NkaKPfb3uJIBTSH7Pdvufi3PQ3/lJLQrvxcMYl7JI2jnDO90siPEpD8JBA==",
|
"integrity": "sha512-2O3dkPAAC6JavuMm8+4+pgTk+5hoAs+CjZ+sWcQLkX9+/tHRuTkQh/Oaifr8qDmZ8iEHb771Ea6G8CdwkrgvYA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -4989,6 +4995,7 @@
|
|||||||
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/core": "^29.7.0",
|
"@jest/core": "^29.7.0",
|
||||||
"@jest/types": "^29.6.3",
|
"@jest/types": "^29.6.3",
|
||||||
@@ -6347,6 +6354,7 @@
|
|||||||
"integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==",
|
"integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
},
|
},
|
||||||
@@ -7083,9 +7091,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/strnum": {
|
"node_modules/strnum": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.1.2.tgz",
|
||||||
"integrity": "sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==",
|
"integrity": "sha512-l63NF9y/cLROq/yqKXSLtcMeeyOfnSQlfMSlzFt/K73oIaD8DGaQWd7Z34X9GPiKqP5rbSh84Hl4bOlLcjiSrQ==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -7464,6 +7472,7 @@
|
|||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache",
|
"name": "cache",
|
||||||
"version": "5.0.0",
|
"version": "5.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Cache dependencies and build outputs",
|
"description": "Cache dependencies and build outputs",
|
||||||
"main": "dist/restore/index.js",
|
"main": "dist/restore/index.js",
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^5.0.0",
|
"@actions/cache": "^5.0.1",
|
||||||
"@actions/core": "^2.0.0",
|
"@actions/core": "^2.0.0",
|
||||||
"@actions/exec": "^2.0.0",
|
"@actions/exec": "^2.0.0",
|
||||||
"@actions/io": "^2.0.0"
|
"@actions/io": "^2.0.0"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ The save action saves a cache. It works similarly to the `cache` action except t
|
|||||||
* `key` - An explicit key for a cache entry. See [creating a cache key](../README.md#creating-a-cache-key).
|
* `key` - An explicit key for a cache entry. See [creating a cache key](../README.md#creating-a-cache-key).
|
||||||
* `path` - A list of files, directories, and wildcard patterns to cache. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
* `path` - A list of files, directories, and wildcard patterns to cache. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||||
* `upload-chunk-size` - The chunk size used to split up large files during upload, in bytes
|
* `upload-chunk-size` - The chunk size used to split up large files during upload, in bytes
|
||||||
|
* `compression-level` - Compression level to use when creating cache archives (save-only action). Use `0` for no compression and `9` for maximum compression. Defaults to the compression tool's standard level when unset.
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
@@ -16,7 +17,6 @@ This action has no outputs.
|
|||||||
|
|
||||||
## Use cases
|
## Use cases
|
||||||
|
|
||||||
|
|
||||||
### Only save cache
|
### Only save cache
|
||||||
|
|
||||||
If you are using separate jobs for generating common artifacts and sharing them across jobs, this action will take care of your cache saving needs.
|
If you are using separate jobs for generating common artifacts and sharing them across jobs, this action will take care of your cache saving needs.
|
||||||
@@ -54,6 +54,7 @@ with:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Case 1 - Where a user would want to reuse the key as it is
|
#### Case 1 - Where a user would want to reuse the key as it is
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: actions/cache/save@v4
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ inputs:
|
|||||||
upload-chunk-size:
|
upload-chunk-size:
|
||||||
description: 'The chunk size used to split up large files during upload, in bytes'
|
description: 'The chunk size used to split up large files during upload, in bytes'
|
||||||
required: false
|
required: false
|
||||||
|
compression-level:
|
||||||
|
description: 'Compression level used when creating cache archives (save-only action). Set 0 for no compression and 9 for maximum compression. Defaults to the compression tool defaults when unset'
|
||||||
|
required: false
|
||||||
enableCrossOsArchive:
|
enableCrossOsArchive:
|
||||||
description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
|
description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export enum Inputs {
|
|||||||
Path = "path", // Input for cache, restore, save action
|
Path = "path", // Input for cache, restore, save action
|
||||||
RestoreKeys = "restore-keys", // Input for cache, restore action
|
RestoreKeys = "restore-keys", // Input for cache, restore action
|
||||||
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
||||||
|
CompressionLevel = "compression-level", // Input for cache, save action
|
||||||
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
||||||
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
|
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
|
||||||
LookupOnly = "lookup-only" // Input for cache, restore action
|
LookupOnly = "lookup-only" // Input for cache, restore action
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ export async function saveImpl(
|
|||||||
|
|
||||||
if (!utils.isValidEvent()) {
|
if (!utils.isValidEvent()) {
|
||||||
utils.logWarning(
|
utils.logWarning(
|
||||||
`Event Validation Error: The event type ${
|
`Event Validation Error: The event type ${process.env[Events.Key]
|
||||||
process.env[Events.Key]
|
|
||||||
} is not supported because it's not tied to a branch or tag ref.`
|
} is not supported because it's not tied to a branch or tag ref.`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -62,6 +61,14 @@ export async function saveImpl(
|
|||||||
Inputs.EnableCrossOsArchive
|
Inputs.EnableCrossOsArchive
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const compressionLevel = utils.getCompressionLevel(
|
||||||
|
Inputs.CompressionLevel
|
||||||
|
);
|
||||||
|
|
||||||
|
if (compressionLevel !== undefined) {
|
||||||
|
utils.setCompressionLevel(compressionLevel);
|
||||||
|
}
|
||||||
|
|
||||||
cacheId = await cache.saveCache(
|
cacheId = await cache.saveCache(
|
||||||
cachePaths,
|
cachePaths,
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
|||||||
@@ -58,6 +58,38 @@ export function getInputAsInt(
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCompressionLevel(
|
||||||
|
name: string,
|
||||||
|
options?: core.InputOptions
|
||||||
|
): number | undefined {
|
||||||
|
const rawValue = core.getInput(name, options);
|
||||||
|
|
||||||
|
if (rawValue === "") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const compressionLevel = parseInt(rawValue, 10);
|
||||||
|
|
||||||
|
if (
|
||||||
|
isNaN(compressionLevel) ||
|
||||||
|
compressionLevel < 0 ||
|
||||||
|
compressionLevel > 9
|
||||||
|
) {
|
||||||
|
logWarning(
|
||||||
|
`Invalid compression-level provided: ${rawValue}. Expected a value between 0 (no compression) and 9 (maximum compression).`
|
||||||
|
);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return compressionLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCompressionLevel(compressionLevel: number): void {
|
||||||
|
const level = compressionLevel.toString();
|
||||||
|
process.env["ZSTD_CLEVEL"] = level;
|
||||||
|
process.env["GZIP"] = `-${level}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function getInputAsBool(
|
export function getInputAsBool(
|
||||||
name: string,
|
name: string,
|
||||||
options?: core.InputOptions
|
options?: core.InputOptions
|
||||||
|
|||||||
Reference in New Issue
Block a user