From 6018dbe2dcdbe3e95acece126f7980bf8943742d Mon Sep 17 00:00:00 2001 From: StephenHodgson Date: Sat, 13 Dec 2025 16:00:25 -0500 Subject: [PATCH] add compression-level inputs --- README.md | 9 +- __tests__/actionUtils.test.ts | 51 ++++++ __tests__/save.test.ts | 22 +++ __tests__/saveImpl.test.ts | 112 ++++++++++++ __tests__/saveOnly.test.ts | 22 +++ action.yml | 3 + dist/restore-only/index.js | 307 +++++++++++++++++---------------- dist/restore/index.js | 307 +++++++++++++++++---------------- dist/save-only/index.js | 311 ++++++++++++++++++---------------- dist/save/index.js | 311 ++++++++++++++++++---------------- save/README.md | 3 +- save/action.yml | 3 + src/constants.ts | 1 + src/saveImpl.ts | 11 +- src/utils/actionUtils.ts | 26 +++ 15 files changed, 916 insertions(+), 583 deletions(-) diff --git a/README.md b/README.md index 7e49684..3e7f52b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ If you do not upgrade, all workflow runs using any of the deprecated [actions/ca Upgrading to the recommended versions will not break your workflows. -> **Additionally, if you are managing your own GitHub runners, you must update your runner version to `2.231.0` or newer to ensure compatibility with the new cache service.** +> **Additionally, if you are managing your own GitHub runners, you must update your runner version to `2.231.0` or newer to ensure compatibility with the new cache service.** > Failure to update both the action version and your runner version may result in workflow failures after the migration date. Read more about the change & access the migration guide: [reference to the announcement](https://github.com/actions/cache/discussions/1510). @@ -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). * `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. +* `compression-level` - Compression level to use when creating cache archives. 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` * `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` @@ -351,7 +352,7 @@ Please note that Windows environment variables (like `%LocalAppData%`) will NOT ## Note -Thank you for your interest in this GitHub repo, however, right now we are not taking contributions. +Thank you for your interest in this GitHub repo, however, right now we are not taking contributions. We continue to focus our resources on strategic areas that help our customers be successful while making developers' lives easier. While GitHub Actions remains a key part of this vision, we are allocating resources towards other areas of Actions and are not taking contributions to this repository at this time. The GitHub public roadmap is the best place to follow along for any updates on features we’re working on and what stage they’re in. @@ -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) -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 . 3. Security Issues should be handled as per our [security.md](SECURITY.md). @@ -369,4 +370,4 @@ You are welcome to still raise bugs in this repo. ## License -The scripts and documentation in this project are released under the [MIT License](LICENSE) \ No newline at end of file +The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/__tests__/actionUtils.test.ts b/__tests__/actionUtils.test.ts index c2e6823..4dc9d0c 100644 --- a/__tests__/actionUtils.test.ts +++ b/__tests__/actionUtils.test.ts @@ -1,5 +1,6 @@ import * as cache from "@actions/cache"; import * as core from "@actions/core"; +import * as zlib from "zlib"; import { Events, RefKey } from "../src/constants"; import * as actionUtils from "../src/utils/actionUtils"; @@ -24,6 +25,11 @@ beforeEach(() => { delete process.env[RefKey]; }); +afterEach(() => { + delete process.env["ZSTD_CLEVEL"]; + delete process.env["GZIP"]; +}); + afterAll(() => { process.env = pristineEnv; }); @@ -177,6 +183,51 @@ test("getInputAsInt returns undefined if input is invalid or NaN", () => { 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 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", () => { expect(() => actionUtils.getInputAsInt("undefined", { required: true }) diff --git a/__tests__/save.test.ts b/__tests__/save.test.ts index 4678c43..f444df3 100644 --- a/__tests__/save.test.ts +++ b/__tests__/save.test.ts @@ -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( (key, cacheResult) => { return jest @@ -71,6 +87,8 @@ afterEach(() => { testUtils.clearInputs(); delete process.env[Events.Key]; delete process.env[RefKey]; + delete process.env["ZSTD_CLEVEL"]; + delete process.env["GZIP"]; }); 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"; testUtils.setInput(Inputs.Path, inputPath); testUtils.setInput(Inputs.UploadChunkSize, "4000000"); + testUtils.setInput(Inputs.CompressionLevel, "8"); const cacheId = 4; const saveCacheMock = jest @@ -102,6 +121,9 @@ test("save with valid inputs uploads a cache", async () => { await saveRun(); + expect(process.env["ZSTD_CLEVEL"]).toBe("8"); + expect(process.env["GZIP"]).toBe("-8"); + expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], diff --git a/__tests__/saveImpl.test.ts b/__tests__/saveImpl.test.ts index ad154f6..f91a215 100644 --- a/__tests__/saveImpl.test.ts +++ b/__tests__/saveImpl.test.ts @@ -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( (key, cacheResult) => { return jest @@ -69,6 +85,8 @@ afterEach(() => { testUtils.clearInputs(); delete process.env[Events.Key]; delete process.env[RefKey]; + delete process.env["ZSTD_CLEVEL"]; + delete process.env["GZIP"]; }); test("save with invalid event outputs warning", async () => { @@ -406,3 +424,97 @@ test("save with valid inputs uploads a cache", async () => { 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); +}); diff --git a/__tests__/saveOnly.test.ts b/__tests__/saveOnly.test.ts index 0437739..6ac2358 100644 --- a/__tests__/saveOnly.test.ts +++ b/__tests__/saveOnly.test.ts @@ -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( (key, cacheResult) => { return jest @@ -71,6 +87,8 @@ afterEach(() => { testUtils.clearInputs(); delete process.env[Events.Key]; delete process.env[RefKey]; + delete process.env["ZSTD_CLEVEL"]; + delete process.env["GZIP"]; }); 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.Path, inputPath); testUtils.setInput(Inputs.UploadChunkSize, "4000000"); + testUtils.setInput(Inputs.CompressionLevel, "0"); const cacheId = 4; const saveCacheMock = jest @@ -92,6 +111,9 @@ test("save with valid inputs uploads a cache", async () => { await saveOnlyRun(); + expect(process.env["ZSTD_CLEVEL"]).toBe("0"); + expect(process.env["GZIP"]).toBe("-0"); + expect(saveCacheMock).toHaveBeenCalledTimes(1); expect(saveCacheMock).toHaveBeenCalledWith( [inputPath], diff --git a/action.yml b/action.yml index 2606455..16b359b 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,9 @@ inputs: upload-chunk-size: description: 'The chunk size used to split up large files during upload, in bytes' required: false + compression-level: + description: 'Compression level used when creating cache archives. Set 0 for no compression and 9 for maximum compression. Defaults to the compression tool defaults when unset' + required: false 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' default: 'false' diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index d7ae08e..b4d40a2 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -44019,6 +44019,7 @@ var Inputs; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; + Inputs["CompressionLevel"] = "compression-level"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action @@ -44312,6 +44313,8 @@ exports.logWarning = logWarning; exports.isValidEvent = isValidEvent; exports.getInputAsArray = getInputAsArray; exports.getInputAsInt = getInputAsInt; +exports.getCompressionLevel = getCompressionLevel; +exports.setCompressionLevel = setCompressionLevel; exports.getInputAsBool = getInputAsBool; exports.isCacheFeatureAvailable = isCacheFeatureAvailable; const cache = __importStar(__nccwpck_require__(5116)); @@ -44354,6 +44357,22 @@ function getInputAsInt(name, options) { } return value; } +function getCompressionLevel(name, options) { + const compressionLevel = getInputAsInt(name, options); + if (compressionLevel === undefined) { + return undefined; + } + if (compressionLevel > 9) { + logWarning(`Invalid compression-level provided: ${compressionLevel}. Expected a value between 0 (no compression) and 9 (maximum compression).`); + return undefined; + } + return compressionLevel; +} +function setCompressionLevel(compressionLevel) { + const level = compressionLevel.toString(); + process.env["ZSTD_CLEVEL"] = level; + process.env["GZIP"] = `-${level}`; +} function getInputAsBool(name, options) { const result = core.getInput(name, options); return result.toLowerCase() === "true"; @@ -59264,6 +59283,24 @@ exports.UserDelegationKeyCredential = UserDelegationKeyCredential; /***/ }), +/***/ 83627: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.KnownEncryptionAlgorithmType = void 0; +/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ +var KnownEncryptionAlgorithmType; +(function (KnownEncryptionAlgorithmType) { + KnownEncryptionAlgorithmType["AES256"] = "AES256"; +})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); +//# sourceMappingURL=generatedModels.js.map + +/***/ }), + /***/ 30247: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -69536,6 +69573,132 @@ exports.listType = { /***/ }), +/***/ 56635: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=appendBlob.js.map + +/***/ }), + +/***/ 68355: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blob.js.map + +/***/ }), + +/***/ 17188: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blockBlob.js.map + +/***/ }), + +/***/ 15337: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=container.js.map + +/***/ }), + +/***/ 82354: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +const tslib_1 = __nccwpck_require__(61860); +tslib_1.__exportStar(__nccwpck_require__(26865), exports); +tslib_1.__exportStar(__nccwpck_require__(15337), exports); +tslib_1.__exportStar(__nccwpck_require__(68355), exports); +tslib_1.__exportStar(__nccwpck_require__(14400), exports); +tslib_1.__exportStar(__nccwpck_require__(56635), exports); +tslib_1.__exportStar(__nccwpck_require__(17188), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 14400: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=pageBlob.js.map + +/***/ }), + +/***/ 26865: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=service.js.map + +/***/ }), + /***/ 40535: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72741,132 +72904,6 @@ const filterBlobsOperationSpec = { /***/ }), -/***/ 56635: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=appendBlob.js.map - -/***/ }), - -/***/ 68355: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blob.js.map - -/***/ }), - -/***/ 17188: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blockBlob.js.map - -/***/ }), - -/***/ 15337: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=container.js.map - -/***/ }), - -/***/ 82354: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -const tslib_1 = __nccwpck_require__(61860); -tslib_1.__exportStar(__nccwpck_require__(26865), exports); -tslib_1.__exportStar(__nccwpck_require__(15337), exports); -tslib_1.__exportStar(__nccwpck_require__(68355), exports); -tslib_1.__exportStar(__nccwpck_require__(14400), exports); -tslib_1.__exportStar(__nccwpck_require__(56635), exports); -tslib_1.__exportStar(__nccwpck_require__(17188), exports); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 14400: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=pageBlob.js.map - -/***/ }), - -/***/ 26865: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=service.js.map - -/***/ }), - /***/ 5313: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72940,24 +72977,6 @@ exports.StorageClient = StorageClient; /***/ }), -/***/ 83627: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.KnownEncryptionAlgorithmType = void 0; -/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ -var KnownEncryptionAlgorithmType; -(function (KnownEncryptionAlgorithmType) { - KnownEncryptionAlgorithmType["AES256"] = "AES256"; -})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); -//# sourceMappingURL=generatedModels.js.map - -/***/ }), - /***/ 71400: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { diff --git a/dist/restore/index.js b/dist/restore/index.js index 05ec1f9..4d2597a 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -44019,6 +44019,7 @@ var Inputs; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; + Inputs["CompressionLevel"] = "compression-level"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action @@ -44312,6 +44313,8 @@ exports.logWarning = logWarning; exports.isValidEvent = isValidEvent; exports.getInputAsArray = getInputAsArray; exports.getInputAsInt = getInputAsInt; +exports.getCompressionLevel = getCompressionLevel; +exports.setCompressionLevel = setCompressionLevel; exports.getInputAsBool = getInputAsBool; exports.isCacheFeatureAvailable = isCacheFeatureAvailable; const cache = __importStar(__nccwpck_require__(5116)); @@ -44354,6 +44357,22 @@ function getInputAsInt(name, options) { } return value; } +function getCompressionLevel(name, options) { + const compressionLevel = getInputAsInt(name, options); + if (compressionLevel === undefined) { + return undefined; + } + if (compressionLevel > 9) { + logWarning(`Invalid compression-level provided: ${compressionLevel}. Expected a value between 0 (no compression) and 9 (maximum compression).`); + return undefined; + } + return compressionLevel; +} +function setCompressionLevel(compressionLevel) { + const level = compressionLevel.toString(); + process.env["ZSTD_CLEVEL"] = level; + process.env["GZIP"] = `-${level}`; +} function getInputAsBool(name, options) { const result = core.getInput(name, options); return result.toLowerCase() === "true"; @@ -59264,6 +59283,24 @@ exports.UserDelegationKeyCredential = UserDelegationKeyCredential; /***/ }), +/***/ 83627: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.KnownEncryptionAlgorithmType = void 0; +/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ +var KnownEncryptionAlgorithmType; +(function (KnownEncryptionAlgorithmType) { + KnownEncryptionAlgorithmType["AES256"] = "AES256"; +})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); +//# sourceMappingURL=generatedModels.js.map + +/***/ }), + /***/ 30247: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -69536,6 +69573,132 @@ exports.listType = { /***/ }), +/***/ 56635: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=appendBlob.js.map + +/***/ }), + +/***/ 68355: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blob.js.map + +/***/ }), + +/***/ 17188: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blockBlob.js.map + +/***/ }), + +/***/ 15337: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=container.js.map + +/***/ }), + +/***/ 82354: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +const tslib_1 = __nccwpck_require__(61860); +tslib_1.__exportStar(__nccwpck_require__(26865), exports); +tslib_1.__exportStar(__nccwpck_require__(15337), exports); +tslib_1.__exportStar(__nccwpck_require__(68355), exports); +tslib_1.__exportStar(__nccwpck_require__(14400), exports); +tslib_1.__exportStar(__nccwpck_require__(56635), exports); +tslib_1.__exportStar(__nccwpck_require__(17188), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 14400: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=pageBlob.js.map + +/***/ }), + +/***/ 26865: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=service.js.map + +/***/ }), + /***/ 40535: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72741,132 +72904,6 @@ const filterBlobsOperationSpec = { /***/ }), -/***/ 56635: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=appendBlob.js.map - -/***/ }), - -/***/ 68355: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blob.js.map - -/***/ }), - -/***/ 17188: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blockBlob.js.map - -/***/ }), - -/***/ 15337: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=container.js.map - -/***/ }), - -/***/ 82354: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -const tslib_1 = __nccwpck_require__(61860); -tslib_1.__exportStar(__nccwpck_require__(26865), exports); -tslib_1.__exportStar(__nccwpck_require__(15337), exports); -tslib_1.__exportStar(__nccwpck_require__(68355), exports); -tslib_1.__exportStar(__nccwpck_require__(14400), exports); -tslib_1.__exportStar(__nccwpck_require__(56635), exports); -tslib_1.__exportStar(__nccwpck_require__(17188), exports); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 14400: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=pageBlob.js.map - -/***/ }), - -/***/ 26865: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=service.js.map - -/***/ }), - /***/ 5313: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72940,24 +72977,6 @@ exports.StorageClient = StorageClient; /***/ }), -/***/ 83627: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.KnownEncryptionAlgorithmType = void 0; -/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ -var KnownEncryptionAlgorithmType; -(function (KnownEncryptionAlgorithmType) { - KnownEncryptionAlgorithmType["AES256"] = "AES256"; -})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); -//# sourceMappingURL=generatedModels.js.map - -/***/ }), - /***/ 71400: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { diff --git a/dist/save-only/index.js b/dist/save-only/index.js index 4ede622..ff41959 100644 --- a/dist/save-only/index.js +++ b/dist/save-only/index.js @@ -44019,6 +44019,7 @@ var Inputs; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; + Inputs["CompressionLevel"] = "compression-level"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action @@ -44135,6 +44136,10 @@ function saveImpl(stateProvider) { required: true }); const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); + const compressionLevel = utils.getCompressionLevel(constants_1.Inputs.CompressionLevel); + if (compressionLevel !== undefined) { + utils.setCompressionLevel(compressionLevel); + } cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive); if (cacheId != -1) { core.info(`Cache saved with key: ${primaryKey}`); @@ -44325,6 +44330,8 @@ exports.logWarning = logWarning; exports.isValidEvent = isValidEvent; exports.getInputAsArray = getInputAsArray; exports.getInputAsInt = getInputAsInt; +exports.getCompressionLevel = getCompressionLevel; +exports.setCompressionLevel = setCompressionLevel; exports.getInputAsBool = getInputAsBool; exports.isCacheFeatureAvailable = isCacheFeatureAvailable; const cache = __importStar(__nccwpck_require__(5116)); @@ -44367,6 +44374,22 @@ function getInputAsInt(name, options) { } return value; } +function getCompressionLevel(name, options) { + const compressionLevel = getInputAsInt(name, options); + if (compressionLevel === undefined) { + return undefined; + } + if (compressionLevel > 9) { + logWarning(`Invalid compression-level provided: ${compressionLevel}. Expected a value between 0 (no compression) and 9 (maximum compression).`); + return undefined; + } + return compressionLevel; +} +function setCompressionLevel(compressionLevel) { + const level = compressionLevel.toString(); + process.env["ZSTD_CLEVEL"] = level; + process.env["GZIP"] = `-${level}`; +} function getInputAsBool(name, options) { const result = core.getInput(name, options); return result.toLowerCase() === "true"; @@ -59277,6 +59300,24 @@ exports.UserDelegationKeyCredential = UserDelegationKeyCredential; /***/ }), +/***/ 83627: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.KnownEncryptionAlgorithmType = void 0; +/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ +var KnownEncryptionAlgorithmType; +(function (KnownEncryptionAlgorithmType) { + KnownEncryptionAlgorithmType["AES256"] = "AES256"; +})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); +//# sourceMappingURL=generatedModels.js.map + +/***/ }), + /***/ 30247: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -69549,6 +69590,132 @@ exports.listType = { /***/ }), +/***/ 56635: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=appendBlob.js.map + +/***/ }), + +/***/ 68355: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blob.js.map + +/***/ }), + +/***/ 17188: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blockBlob.js.map + +/***/ }), + +/***/ 15337: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=container.js.map + +/***/ }), + +/***/ 82354: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +const tslib_1 = __nccwpck_require__(61860); +tslib_1.__exportStar(__nccwpck_require__(26865), exports); +tslib_1.__exportStar(__nccwpck_require__(15337), exports); +tslib_1.__exportStar(__nccwpck_require__(68355), exports); +tslib_1.__exportStar(__nccwpck_require__(14400), exports); +tslib_1.__exportStar(__nccwpck_require__(56635), exports); +tslib_1.__exportStar(__nccwpck_require__(17188), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 14400: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=pageBlob.js.map + +/***/ }), + +/***/ 26865: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=service.js.map + +/***/ }), + /***/ 40535: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72754,132 +72921,6 @@ const filterBlobsOperationSpec = { /***/ }), -/***/ 56635: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=appendBlob.js.map - -/***/ }), - -/***/ 68355: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blob.js.map - -/***/ }), - -/***/ 17188: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blockBlob.js.map - -/***/ }), - -/***/ 15337: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=container.js.map - -/***/ }), - -/***/ 82354: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -const tslib_1 = __nccwpck_require__(61860); -tslib_1.__exportStar(__nccwpck_require__(26865), exports); -tslib_1.__exportStar(__nccwpck_require__(15337), exports); -tslib_1.__exportStar(__nccwpck_require__(68355), exports); -tslib_1.__exportStar(__nccwpck_require__(14400), exports); -tslib_1.__exportStar(__nccwpck_require__(56635), exports); -tslib_1.__exportStar(__nccwpck_require__(17188), exports); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 14400: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=pageBlob.js.map - -/***/ }), - -/***/ 26865: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=service.js.map - -/***/ }), - /***/ 5313: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72953,24 +72994,6 @@ exports.StorageClient = StorageClient; /***/ }), -/***/ 83627: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.KnownEncryptionAlgorithmType = void 0; -/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ -var KnownEncryptionAlgorithmType; -(function (KnownEncryptionAlgorithmType) { - KnownEncryptionAlgorithmType["AES256"] = "AES256"; -})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); -//# sourceMappingURL=generatedModels.js.map - -/***/ }), - /***/ 71400: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { diff --git a/dist/save/index.js b/dist/save/index.js index 4b444e7..d5a1c98 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -44019,6 +44019,7 @@ var Inputs; Inputs["Path"] = "path"; Inputs["RestoreKeys"] = "restore-keys"; Inputs["UploadChunkSize"] = "upload-chunk-size"; + Inputs["CompressionLevel"] = "compression-level"; Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; Inputs["FailOnCacheMiss"] = "fail-on-cache-miss"; Inputs["LookupOnly"] = "lookup-only"; // Input for cache, restore action @@ -44135,6 +44136,10 @@ function saveImpl(stateProvider) { required: true }); const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); + const compressionLevel = utils.getCompressionLevel(constants_1.Inputs.CompressionLevel); + if (compressionLevel !== undefined) { + utils.setCompressionLevel(compressionLevel); + } cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive); if (cacheId != -1) { core.info(`Cache saved with key: ${primaryKey}`); @@ -44325,6 +44330,8 @@ exports.logWarning = logWarning; exports.isValidEvent = isValidEvent; exports.getInputAsArray = getInputAsArray; exports.getInputAsInt = getInputAsInt; +exports.getCompressionLevel = getCompressionLevel; +exports.setCompressionLevel = setCompressionLevel; exports.getInputAsBool = getInputAsBool; exports.isCacheFeatureAvailable = isCacheFeatureAvailable; const cache = __importStar(__nccwpck_require__(5116)); @@ -44367,6 +44374,22 @@ function getInputAsInt(name, options) { } return value; } +function getCompressionLevel(name, options) { + const compressionLevel = getInputAsInt(name, options); + if (compressionLevel === undefined) { + return undefined; + } + if (compressionLevel > 9) { + logWarning(`Invalid compression-level provided: ${compressionLevel}. Expected a value between 0 (no compression) and 9 (maximum compression).`); + return undefined; + } + return compressionLevel; +} +function setCompressionLevel(compressionLevel) { + const level = compressionLevel.toString(); + process.env["ZSTD_CLEVEL"] = level; + process.env["GZIP"] = `-${level}`; +} function getInputAsBool(name, options) { const result = core.getInput(name, options); return result.toLowerCase() === "true"; @@ -59277,6 +59300,24 @@ exports.UserDelegationKeyCredential = UserDelegationKeyCredential; /***/ }), +/***/ 83627: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.KnownEncryptionAlgorithmType = void 0; +/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ +var KnownEncryptionAlgorithmType; +(function (KnownEncryptionAlgorithmType) { + KnownEncryptionAlgorithmType["AES256"] = "AES256"; +})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); +//# sourceMappingURL=generatedModels.js.map + +/***/ }), + /***/ 30247: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -69549,6 +69590,132 @@ exports.listType = { /***/ }), +/***/ 56635: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=appendBlob.js.map + +/***/ }), + +/***/ 68355: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blob.js.map + +/***/ }), + +/***/ 17188: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=blockBlob.js.map + +/***/ }), + +/***/ 15337: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=container.js.map + +/***/ }), + +/***/ 82354: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +const tslib_1 = __nccwpck_require__(61860); +tslib_1.__exportStar(__nccwpck_require__(26865), exports); +tslib_1.__exportStar(__nccwpck_require__(15337), exports); +tslib_1.__exportStar(__nccwpck_require__(68355), exports); +tslib_1.__exportStar(__nccwpck_require__(14400), exports); +tslib_1.__exportStar(__nccwpck_require__(56635), exports); +tslib_1.__exportStar(__nccwpck_require__(17188), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 14400: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=pageBlob.js.map + +/***/ }), + +/***/ 26865: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=service.js.map + +/***/ }), + /***/ 40535: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72754,132 +72921,6 @@ const filterBlobsOperationSpec = { /***/ }), -/***/ 56635: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=appendBlob.js.map - -/***/ }), - -/***/ 68355: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blob.js.map - -/***/ }), - -/***/ 17188: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=blockBlob.js.map - -/***/ }), - -/***/ 15337: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=container.js.map - -/***/ }), - -/***/ 82354: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -const tslib_1 = __nccwpck_require__(61860); -tslib_1.__exportStar(__nccwpck_require__(26865), exports); -tslib_1.__exportStar(__nccwpck_require__(15337), exports); -tslib_1.__exportStar(__nccwpck_require__(68355), exports); -tslib_1.__exportStar(__nccwpck_require__(14400), exports); -tslib_1.__exportStar(__nccwpck_require__(56635), exports); -tslib_1.__exportStar(__nccwpck_require__(17188), exports); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 14400: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=pageBlob.js.map - -/***/ }), - -/***/ 26865: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -//# sourceMappingURL=service.js.map - -/***/ }), - /***/ 5313: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -72953,24 +72994,6 @@ exports.StorageClient = StorageClient; /***/ }), -/***/ 83627: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.KnownEncryptionAlgorithmType = void 0; -/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */ -var KnownEncryptionAlgorithmType; -(function (KnownEncryptionAlgorithmType) { - KnownEncryptionAlgorithmType["AES256"] = "AES256"; -})(KnownEncryptionAlgorithmType || (exports.KnownEncryptionAlgorithmType = KnownEncryptionAlgorithmType = {})); -//# sourceMappingURL=generatedModels.js.map - -/***/ }), - /***/ 71400: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { diff --git a/save/README.md b/save/README.md index dc45c38..3d9913d 100644 --- a/save/README.md +++ b/save/README.md @@ -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). * `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 +* `compression-level` - Compression level to use when creating cache archives. Use `0` for no compression and `9` for maximum compression. Defaults to the compression tool's standard level when unset. ### Outputs @@ -16,7 +17,6 @@ This action has no outputs. ## Use cases - ### 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. @@ -54,6 +54,7 @@ with: ``` #### Case 1 - Where a user would want to reuse the key as it is + ```yaml uses: actions/cache/save@v4 with: diff --git a/save/action.yml b/save/action.yml index 1b95184..fccc95e 100644 --- a/save/action.yml +++ b/save/action.yml @@ -11,6 +11,9 @@ inputs: upload-chunk-size: description: 'The chunk size used to split up large files during upload, in bytes' required: false + compression-level: + description: 'Compression level used when creating cache archives. Set 0 for no compression and 9 for maximum compression. Defaults to the compression tool defaults when unset' + required: false enableCrossOsArchive: description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms' default: 'false' diff --git a/src/constants.ts b/src/constants.ts index 0158ae0..9a73686 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,6 +3,7 @@ export enum Inputs { Path = "path", // Input for cache, restore, save action RestoreKeys = "restore-keys", // Input for cache, restore 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 FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action LookupOnly = "lookup-only" // Input for cache, restore action diff --git a/src/saveImpl.ts b/src/saveImpl.ts index 4e5c312..32c1856 100644 --- a/src/saveImpl.ts +++ b/src/saveImpl.ts @@ -25,8 +25,7 @@ export async function saveImpl( if (!utils.isValidEvent()) { utils.logWarning( - `Event Validation Error: The event type ${ - process.env[Events.Key] + `Event Validation Error: The event type ${process.env[Events.Key] } is not supported because it's not tied to a branch or tag ref.` ); return; @@ -62,6 +61,14 @@ export async function saveImpl( Inputs.EnableCrossOsArchive ); + const compressionLevel = utils.getCompressionLevel( + Inputs.CompressionLevel + ); + + if (compressionLevel !== undefined) { + utils.setCompressionLevel(compressionLevel); + } + cacheId = await cache.saveCache( cachePaths, primaryKey, diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index 260d4fd..6d1de9c 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -58,6 +58,32 @@ export function getInputAsInt( return value; } +export function getCompressionLevel( + name: string, + options?: core.InputOptions +): number | undefined { + const compressionLevel = getInputAsInt(name, options); + + if (compressionLevel === undefined) { + return undefined; + } + + if (compressionLevel > 9) { + logWarning( + `Invalid compression-level provided: ${compressionLevel}. 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( name: string, options?: core.InputOptions