Compare commits

...

12 Commits

Author SHA1 Message Date
Stuart Leeks
54608e5696
Merge 783accdc1c into 8b402f58fb 2026-01-20 21:51:04 +00:00
Ryan Ghadimi
8b402f58fb
Merge pull request #1692 from GhadimiR/main
Bump @actions/cache to 5.0.3
2026-01-16 17:25:13 +00:00
Ryan Ghadimi
304ab5a070 license for httpclient 2026-01-16 13:30:00 +00:00
Ryan Ghadimi
609fc19e67 Update licensed record for cache 2026-01-16 12:28:12 +00:00
Ryan Ghadimi
b22231e43d Build 2026-01-16 11:42:17 +00:00
Ryan Ghadimi
93150cdfb3 Add PR link to releases 2026-01-16 11:39:29 +00:00
Ryan Ghadimi
9b8ca9f07e Bump actions/cache to 5.0.3 2026-01-16 11:35:54 +00:00
Stuart Leeks
783accdc1c lint/format 2025-05-08 17:01:34 +00:00
Stuart Leeks
6905c11681 Update docs 2025-05-08 16:58:15 +00:00
Stuart Leeks
c5c1c31345 npm run build 2025-05-08 16:51:59 +00:00
Stuart Leeks
91afe36e0a Update non-null state provider to also output primary/matched keys 2025-05-08 16:51:55 +00:00
Stuart Leeks
480d890516 Add cache-primary-key, cache-matched-key to main action.yml 2025-05-08 16:23:21 +00:00
15 changed files with 259 additions and 108 deletions

View File

@ -1,6 +1,6 @@
--- ---
name: "@actions/cache" name: "@actions/cache"
version: 5.0.1 version: 5.0.3
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

View File

@ -1,6 +1,6 @@
--- ---
name: "@actions/http-client" name: "@actions/http-client"
version: 3.0.0 version: 3.0.1
type: npm type: npm
summary: Actions Http Client summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client homepage: https://github.com/actions/toolkit/tree/main/packages/http-client

View File

@ -100,6 +100,8 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir
* `cache-hit` - A string value to indicate an exact match was found for the key. * `cache-hit` - A string value to indicate an exact match was found for the key.
* If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`. * If there's a cache hit, this will be 'true' or 'false' to indicate if there's an exact match for `key`.
* If there's a cache miss, this will be an empty string. * If there's a cache miss, this will be an empty string.
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output

View File

@ -2,6 +2,10 @@
## Changelog ## Changelog
### 5.0.2
- Bump `@actions/cache` to v5.0.3 [#1692](https://github.com/actions/cache/pull/1692)
### 5.0.1 ### 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) - Update `@azure/storage-blob` to `^12.29.1` via `@actions/cache@5.0.1` [#1685](https://github.com/actions/cache/pull/1685)

View File

@ -149,7 +149,7 @@ test("restore with cache found for key", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -173,8 +173,10 @@ test("restore with cache found for key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key); expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2); expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`); expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
@ -194,7 +196,7 @@ test("restore with cache found for restore key", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -218,8 +220,10 @@ test("restore with cache found for restore key", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey); expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2); expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}` `Cache restored from key: ${restoreKey}`
); );
@ -239,7 +243,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -260,7 +264,8 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0); expect(setOutputMock).toHaveBeenCalledTimes(1);
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(failedMock).toHaveBeenCalledWith( expect(failedMock).toHaveBeenCalledWith(
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}`
@ -282,7 +287,7 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -306,8 +311,10 @@ test("restore when fail on cache miss is enabled and primary key doesn't match r
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey); expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2); expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}` `Cache restored from key: ${restoreKey}`

View File

@ -112,7 +112,7 @@ test("restore on GHES with AC available ", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -133,8 +133,10 @@ test("restore on GHES with AC available ", async () => {
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`); expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
@ -334,7 +336,7 @@ test("restore with cache found for key", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -355,8 +357,10 @@ test("restore with cache found for key", async () => {
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`); expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0); expect(failedMock).toHaveBeenCalledTimes(0);
@ -376,7 +380,7 @@ test("restore with cache found for restore key", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -397,8 +401,10 @@ test("restore with cache found for restore key", async () => {
); );
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", restoreKey);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}` `Cache restored from key: ${restoreKey}`
); );
@ -417,7 +423,7 @@ test("restore with lookup-only set", async () => {
const infoMock = jest.spyOn(core, "info"); const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed"); const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState"); const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput"); const setOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest const restoreCacheMock = jest
.spyOn(cache, "restoreCache") .spyOn(cache, "restoreCache")
.mockImplementationOnce(() => { .mockImplementationOnce(() => {
@ -441,8 +447,10 @@ test("restore with lookup-only set", async () => {
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key); expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2); expect(stateMock).toHaveBeenCalledTimes(2);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(setOutputMock).toHaveBeenCalledTimes(3);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true"); expect(setOutputMock).toHaveBeenCalledWith("cache-hit", "true");
expect(setOutputMock).toHaveBeenCalledWith("cache-primary-key", key);
expect(setOutputMock).toHaveBeenCalledWith("cache-matched-key", key);
expect(infoMock).toHaveBeenCalledWith( expect(infoMock).toHaveBeenCalledWith(
`Cache found and can be restored from key: ${key}` `Cache found and can be restored from key: ${key}`

View File

@ -54,7 +54,7 @@ test("StateProvider saves states", async () => {
expect(cacheStateValue).toBe(cacheMatchedKey); expect(cacheStateValue).toBe(cacheMatchedKey);
expect(getStateMock).toHaveBeenCalledTimes(2); expect(getStateMock).toHaveBeenCalledTimes(2);
expect(saveStateMock).toHaveBeenCalledTimes(2); expect(saveStateMock).toHaveBeenCalledTimes(2);
expect(setOutputMock).toHaveBeenCalledTimes(0); expect(setOutputMock).toHaveBeenCalledTimes(2);
}); });
test("NullStateProvider saves outputs", async () => { test("NullStateProvider saves outputs", async () => {

View File

@ -37,6 +37,10 @@ inputs:
outputs: outputs:
cache-hit: cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key' description: 'A boolean value to indicate an exact match was found for the primary key'
cache-primary-key:
description: 'A resolved cache key for which cache match was attempted'
cache-matched-key:
description: 'Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys'
runs: runs:
using: 'node24' using: 'node24'
main: 'dist/restore/index.js' main: 'dist/restore/index.js'

View File

@ -2398,6 +2398,18 @@ class CacheServiceClient {
} }
errorMessage = `${errorMessage}: ${body.msg}`; errorMessage = `${errorMessage}: ${body.msg}`;
} }
// Handle rate limiting - don't retry, just warn and exit
// For more info, see https://docs.github.com/en/actions/reference/limits
if (statusCode === http_client_1.HttpCodes.TooManyRequests) {
const retryAfterHeader = response.message.headers['retry-after'];
if (retryAfterHeader) {
const parsedSeconds = parseInt(retryAfterHeader, 10);
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
(0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
}
}
throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`);
}
} }
catch (error) { catch (error) {
if (error instanceof SyntaxError) { if (error instanceof SyntaxError) {
@ -2406,6 +2418,9 @@ class CacheServiceClient {
if (error instanceof errors_1.UsageError) { if (error instanceof errors_1.UsageError) {
throw error; throw error;
} }
if (error instanceof errors_1.RateLimitError) {
throw error;
}
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
} }
@ -2438,8 +2453,7 @@ class CacheServiceClient {
http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.BadGateway,
http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.GatewayTimeout,
http_client_1.HttpCodes.InternalServerError, http_client_1.HttpCodes.InternalServerError,
http_client_1.HttpCodes.ServiceUnavailable, http_client_1.HttpCodes.ServiceUnavailable
http_client_1.HttpCodes.TooManyRequests
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);
} }
@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
class FilesNotFoundError extends Error { class FilesNotFoundError extends Error {
constructor(files = []) { constructor(files = []) {
let message = 'No files were found to upload'; let message = 'No files were found to upload';
@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => {
return false; return false;
return msg.includes('insufficient usage'); return msg.includes('insufficient usage');
}; };
class RateLimitError extends Error {
constructor(message) {
super(message);
this.name = 'RateLimitError';
}
}
exports.RateLimitError = RateLimitError;
//# sourceMappingURL=errors.js.map //# sourceMappingURL=errors.js.map
/***/ }), /***/ }),
@ -9902,7 +9923,7 @@ class HttpClient {
this._maxRetries = 1; this._maxRetries = 1;
this._keepAlive = false; this._keepAlive = false;
this._disposed = false; this._disposed = false;
this.userAgent = userAgent; this.userAgent = this._getUserAgentWithOrchestrationId(userAgent);
this.handlers = handlers || []; this.handlers = handlers || [];
this.requestOptions = requestOptions; this.requestOptions = requestOptions;
if (requestOptions) { if (requestOptions) {
@ -10382,6 +10403,17 @@ class HttpClient {
} }
return proxyAgent; return proxyAgent;
} }
_getUserAgentWithOrchestrationId(userAgent) {
const baseUserAgent = userAgent || 'actions/http-client';
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
if (orchId) {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
}
return baseUserAgent;
}
_performExponentialBackoff(retryNumber) { _performExponentialBackoff(retryNumber) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
@ -44243,21 +44275,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase { class StateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.setState = core.saveState; this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState; this.getState = core.getState;
} }
} }
exports.StateProvider = StateProvider; exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase { class NullStateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.stateToOutputMap = new Map([ this.setState = stateToOutput;
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => ""; this.getState = (key) => "";
} }
@ -87398,7 +87431,7 @@ function randomUUID() {
/***/ ((module) => { /***/ ((module) => {
"use strict"; "use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.0","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
/***/ }) /***/ })

59
dist/restore/index.js vendored
View File

@ -2398,6 +2398,18 @@ class CacheServiceClient {
} }
errorMessage = `${errorMessage}: ${body.msg}`; errorMessage = `${errorMessage}: ${body.msg}`;
} }
// Handle rate limiting - don't retry, just warn and exit
// For more info, see https://docs.github.com/en/actions/reference/limits
if (statusCode === http_client_1.HttpCodes.TooManyRequests) {
const retryAfterHeader = response.message.headers['retry-after'];
if (retryAfterHeader) {
const parsedSeconds = parseInt(retryAfterHeader, 10);
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
(0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
}
}
throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`);
}
} }
catch (error) { catch (error) {
if (error instanceof SyntaxError) { if (error instanceof SyntaxError) {
@ -2406,6 +2418,9 @@ class CacheServiceClient {
if (error instanceof errors_1.UsageError) { if (error instanceof errors_1.UsageError) {
throw error; throw error;
} }
if (error instanceof errors_1.RateLimitError) {
throw error;
}
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
} }
@ -2438,8 +2453,7 @@ class CacheServiceClient {
http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.BadGateway,
http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.GatewayTimeout,
http_client_1.HttpCodes.InternalServerError, http_client_1.HttpCodes.InternalServerError,
http_client_1.HttpCodes.ServiceUnavailable, http_client_1.HttpCodes.ServiceUnavailable
http_client_1.HttpCodes.TooManyRequests
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);
} }
@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
class FilesNotFoundError extends Error { class FilesNotFoundError extends Error {
constructor(files = []) { constructor(files = []) {
let message = 'No files were found to upload'; let message = 'No files were found to upload';
@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => {
return false; return false;
return msg.includes('insufficient usage'); return msg.includes('insufficient usage');
}; };
class RateLimitError extends Error {
constructor(message) {
super(message);
this.name = 'RateLimitError';
}
}
exports.RateLimitError = RateLimitError;
//# sourceMappingURL=errors.js.map //# sourceMappingURL=errors.js.map
/***/ }), /***/ }),
@ -9902,7 +9923,7 @@ class HttpClient {
this._maxRetries = 1; this._maxRetries = 1;
this._keepAlive = false; this._keepAlive = false;
this._disposed = false; this._disposed = false;
this.userAgent = userAgent; this.userAgent = this._getUserAgentWithOrchestrationId(userAgent);
this.handlers = handlers || []; this.handlers = handlers || [];
this.requestOptions = requestOptions; this.requestOptions = requestOptions;
if (requestOptions) { if (requestOptions) {
@ -10382,6 +10403,17 @@ class HttpClient {
} }
return proxyAgent; return proxyAgent;
} }
_getUserAgentWithOrchestrationId(userAgent) {
const baseUserAgent = userAgent || 'actions/http-client';
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
if (orchId) {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
}
return baseUserAgent;
}
_performExponentialBackoff(retryNumber) { _performExponentialBackoff(retryNumber) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
@ -44243,21 +44275,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase { class StateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.setState = core.saveState; this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState; this.getState = core.getState;
} }
} }
exports.StateProvider = StateProvider; exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase { class NullStateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.stateToOutputMap = new Map([ this.setState = stateToOutput;
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => ""; this.getState = (key) => "";
} }
@ -87398,7 +87431,7 @@ function randomUUID() {
/***/ ((module) => { /***/ ((module) => {
"use strict"; "use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.0","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
/***/ }) /***/ })

View File

@ -2398,6 +2398,18 @@ class CacheServiceClient {
} }
errorMessage = `${errorMessage}: ${body.msg}`; errorMessage = `${errorMessage}: ${body.msg}`;
} }
// Handle rate limiting - don't retry, just warn and exit
// For more info, see https://docs.github.com/en/actions/reference/limits
if (statusCode === http_client_1.HttpCodes.TooManyRequests) {
const retryAfterHeader = response.message.headers['retry-after'];
if (retryAfterHeader) {
const parsedSeconds = parseInt(retryAfterHeader, 10);
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
(0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
}
}
throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`);
}
} }
catch (error) { catch (error) {
if (error instanceof SyntaxError) { if (error instanceof SyntaxError) {
@ -2406,6 +2418,9 @@ class CacheServiceClient {
if (error instanceof errors_1.UsageError) { if (error instanceof errors_1.UsageError) {
throw error; throw error;
} }
if (error instanceof errors_1.RateLimitError) {
throw error;
}
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
} }
@ -2438,8 +2453,7 @@ class CacheServiceClient {
http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.BadGateway,
http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.GatewayTimeout,
http_client_1.HttpCodes.InternalServerError, http_client_1.HttpCodes.InternalServerError,
http_client_1.HttpCodes.ServiceUnavailable, http_client_1.HttpCodes.ServiceUnavailable
http_client_1.HttpCodes.TooManyRequests
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);
} }
@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
class FilesNotFoundError extends Error { class FilesNotFoundError extends Error {
constructor(files = []) { constructor(files = []) {
let message = 'No files were found to upload'; let message = 'No files were found to upload';
@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => {
return false; return false;
return msg.includes('insufficient usage'); return msg.includes('insufficient usage');
}; };
class RateLimitError extends Error {
constructor(message) {
super(message);
this.name = 'RateLimitError';
}
}
exports.RateLimitError = RateLimitError;
//# sourceMappingURL=errors.js.map //# sourceMappingURL=errors.js.map
/***/ }), /***/ }),
@ -9902,7 +9923,7 @@ class HttpClient {
this._maxRetries = 1; this._maxRetries = 1;
this._keepAlive = false; this._keepAlive = false;
this._disposed = false; this._disposed = false;
this.userAgent = userAgent; this.userAgent = this._getUserAgentWithOrchestrationId(userAgent);
this.handlers = handlers || []; this.handlers = handlers || [];
this.requestOptions = requestOptions; this.requestOptions = requestOptions;
if (requestOptions) { if (requestOptions) {
@ -10382,6 +10403,17 @@ class HttpClient {
} }
return proxyAgent; return proxyAgent;
} }
_getUserAgentWithOrchestrationId(userAgent) {
const baseUserAgent = userAgent || 'actions/http-client';
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
if (orchId) {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
}
return baseUserAgent;
}
_performExponentialBackoff(retryNumber) { _performExponentialBackoff(retryNumber) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
@ -44256,21 +44288,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase { class StateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.setState = core.saveState; this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState; this.getState = core.getState;
} }
} }
exports.StateProvider = StateProvider; exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase { class NullStateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.stateToOutputMap = new Map([ this.setState = stateToOutput;
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => ""; this.getState = (key) => "";
} }
@ -87411,7 +87444,7 @@ function randomUUID() {
/***/ ((module) => { /***/ ((module) => {
"use strict"; "use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.0","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
/***/ }) /***/ })

59
dist/save/index.js vendored
View File

@ -2398,6 +2398,18 @@ class CacheServiceClient {
} }
errorMessage = `${errorMessage}: ${body.msg}`; errorMessage = `${errorMessage}: ${body.msg}`;
} }
// Handle rate limiting - don't retry, just warn and exit
// For more info, see https://docs.github.com/en/actions/reference/limits
if (statusCode === http_client_1.HttpCodes.TooManyRequests) {
const retryAfterHeader = response.message.headers['retry-after'];
if (retryAfterHeader) {
const parsedSeconds = parseInt(retryAfterHeader, 10);
if (!isNaN(parsedSeconds) && parsedSeconds > 0) {
(0, core_1.warning)(`You've hit a rate limit, your rate limit will reset in ${parsedSeconds} seconds`);
}
}
throw new errors_1.RateLimitError(`Rate limited: ${errorMessage}`);
}
} }
catch (error) { catch (error) {
if (error instanceof SyntaxError) { if (error instanceof SyntaxError) {
@ -2406,6 +2418,9 @@ class CacheServiceClient {
if (error instanceof errors_1.UsageError) { if (error instanceof errors_1.UsageError) {
throw error; throw error;
} }
if (error instanceof errors_1.RateLimitError) {
throw error;
}
if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) { if (errors_1.NetworkError.isNetworkErrorCode(error === null || error === void 0 ? void 0 : error.code)) {
throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code); throw new errors_1.NetworkError(error === null || error === void 0 ? void 0 : error.code);
} }
@ -2438,8 +2453,7 @@ class CacheServiceClient {
http_client_1.HttpCodes.BadGateway, http_client_1.HttpCodes.BadGateway,
http_client_1.HttpCodes.GatewayTimeout, http_client_1.HttpCodes.GatewayTimeout,
http_client_1.HttpCodes.InternalServerError, http_client_1.HttpCodes.InternalServerError,
http_client_1.HttpCodes.ServiceUnavailable, http_client_1.HttpCodes.ServiceUnavailable
http_client_1.HttpCodes.TooManyRequests
]; ];
return retryableStatusCodes.includes(statusCode); return retryableStatusCodes.includes(statusCode);
} }
@ -2475,7 +2489,7 @@ function internalCacheTwirpClient(options) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0; exports.RateLimitError = exports.UsageError = exports.NetworkError = exports.GHESNotSupportedError = exports.CacheNotFoundError = exports.InvalidResponseError = exports.FilesNotFoundError = void 0;
class FilesNotFoundError extends Error { class FilesNotFoundError extends Error {
constructor(files = []) { constructor(files = []) {
let message = 'No files were found to upload'; let message = 'No files were found to upload';
@ -2542,6 +2556,13 @@ UsageError.isUsageErrorMessage = (msg) => {
return false; return false;
return msg.includes('insufficient usage'); return msg.includes('insufficient usage');
}; };
class RateLimitError extends Error {
constructor(message) {
super(message);
this.name = 'RateLimitError';
}
}
exports.RateLimitError = RateLimitError;
//# sourceMappingURL=errors.js.map //# sourceMappingURL=errors.js.map
/***/ }), /***/ }),
@ -9902,7 +9923,7 @@ class HttpClient {
this._maxRetries = 1; this._maxRetries = 1;
this._keepAlive = false; this._keepAlive = false;
this._disposed = false; this._disposed = false;
this.userAgent = userAgent; this.userAgent = this._getUserAgentWithOrchestrationId(userAgent);
this.handlers = handlers || []; this.handlers = handlers || [];
this.requestOptions = requestOptions; this.requestOptions = requestOptions;
if (requestOptions) { if (requestOptions) {
@ -10382,6 +10403,17 @@ class HttpClient {
} }
return proxyAgent; return proxyAgent;
} }
_getUserAgentWithOrchestrationId(userAgent) {
const baseUserAgent = userAgent || 'actions/http-client';
const orchId = process.env['ACTIONS_ORCHESTRATION_ID'];
if (orchId) {
// Sanitize the orchestration ID to ensure it contains only valid characters
// Valid characters: 0-9, a-z, _, -, .
const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_');
return `${baseUserAgent} actions_orchestration_id/${sanitizedId}`;
}
return baseUserAgent;
}
_performExponentialBackoff(retryNumber) { _performExponentialBackoff(retryNumber) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
@ -44256,21 +44288,22 @@ class StateProviderBase {
class StateProvider extends StateProviderBase { class StateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.setState = core.saveState; this.setState = (key, value) => { core.saveState(key, value); stateToOutput(key, value); };
this.getState = core.getState; this.getState = core.getState;
} }
} }
exports.StateProvider = StateProvider; exports.StateProvider = StateProvider;
const stateToOutputMap = new Map([
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
function stateToOutput(key, value) {
core.setOutput(stateToOutputMap.get(key), value);
}
class NullStateProvider extends StateProviderBase { class NullStateProvider extends StateProviderBase {
constructor() { constructor() {
super(...arguments); super(...arguments);
this.stateToOutputMap = new Map([ this.setState = stateToOutput;
[constants_1.State.CacheMatchedKey, constants_1.Outputs.CacheMatchedKey],
[constants_1.State.CachePrimaryKey, constants_1.Outputs.CachePrimaryKey]
]);
this.setState = (key, value) => {
core.setOutput(this.stateToOutputMap.get(key), value);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
this.getState = (key) => ""; this.getState = (key) => "";
} }
@ -87411,7 +87444,7 @@ function randomUUID() {
/***/ ((module) => { /***/ ((module) => {
"use strict"; "use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.0","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}'); module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^2.0.0","@actions/exec":"^2.0.0","@actions/glob":"^0.5.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.1","@actions/io":"^2.0.0","@azure/abort-controller":"^1.1.0","@azure/core-rest-pipeline":"^1.22.0","@azure/storage-blob":"^12.29.1","semver":"^6.3.1"},"devDependencies":{"@types/node":"^24.1.0","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
/***/ }) /***/ })

29
package-lock.json generated
View File

@ -1,15 +1,15 @@
{ {
"name": "cache", "name": "cache",
"version": "5.0.1", "version": "5.0.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cache", "name": "cache",
"version": "5.0.1", "version": "5.0.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^5.0.1", "@actions/cache": "^5.0.3",
"@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,15 +39,15 @@
} }
}, },
"node_modules/@actions/cache": { "node_modules/@actions/cache": {
"version": "5.0.1", "version": "5.0.3",
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.1.tgz", "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.0.3.tgz",
"integrity": "sha512-c+oH047Z2zmXLhjMZfEKjxZfv6Ou7T0sn5fhz6yupICXm5OOR47oZn5zxNO8MP7ttkxv5TOg3WsMrffri5Xhfw==", "integrity": "sha512-9joY8Oup+nIpksSBlkuf9/mltnhWx3lydk1tA2PVnXaxFLIIrKqrWDN2CZXlJ+PEErcBARKYn4mHiUCTyMh4Vg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^2.0.0", "@actions/core": "^2.0.0",
"@actions/exec": "^2.0.0", "@actions/exec": "^2.0.0",
"@actions/glob": "^0.5.0", "@actions/glob": "^0.5.0",
"@actions/http-client": "^3.0.0", "@actions/http-client": "^3.0.1",
"@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",
@ -121,9 +121,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/@actions/http-client": { "node_modules/@actions/http-client": {
"version": "3.0.0", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-3.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-3.0.1.tgz",
"integrity": "sha512-1s3tXAfVMSz9a4ZEBkXXRQD4QhY3+GAsWSbaYpeknPOKEeyRiU3lH+bHiLMZdo2x/fIeQ/hscL1wCkDLVM2DZQ==", "integrity": "sha512-SbGS8c/vySbNO3kjFgSW77n83C4MQx/Yoe+b1hAdpuvfHxnkHzDq2pWljUpAA56Si1Gae/7zjeZsV0CYjmLo/w==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"tunnel": "^0.0.6", "tunnel": "^0.0.6",
@ -1762,7 +1762,6 @@
"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",
@ -1797,7 +1796,6 @@
"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",
@ -2027,7 +2025,6 @@
"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"
}, },
@ -2480,7 +2477,6 @@
} }
], ],
"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",
@ -3185,7 +3181,6 @@
"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",
@ -3242,7 +3237,6 @@
"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"
}, },
@ -4995,7 +4989,6 @@
"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",
@ -6354,7 +6347,6 @@
"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"
}, },
@ -7472,7 +7464,6 @@
"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"

View File

@ -1,6 +1,6 @@
{ {
"name": "cache", "name": "cache",
"version": "5.0.1", "version": "5.0.2",
"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.1", "@actions/cache": "^5.0.3",
"@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"

View File

@ -28,19 +28,22 @@ class StateProviderBase implements IStateProvider {
} }
export class StateProvider extends StateProviderBase { export class StateProvider extends StateProviderBase {
setState = core.saveState; setState = (key: string, value: string) => {
core.saveState(key, value);
stateToOutput(key, value);
};
getState = core.getState; getState = core.getState;
} }
const stateToOutputMap = new Map<string, string>([
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
function stateToOutput(key: string, value: string) {
core.setOutput(stateToOutputMap.get(key) as string, value);
}
export class NullStateProvider extends StateProviderBase { export class NullStateProvider extends StateProviderBase {
stateToOutputMap = new Map<string, string>([ setState = stateToOutput;
[State.CacheMatchedKey, Outputs.CacheMatchedKey],
[State.CachePrimaryKey, Outputs.CachePrimaryKey]
]);
setState = (key: string, value: string) => {
core.setOutput(this.stateToOutputMap.get(key) as string, value);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
getState = (key: string) => ""; getState = (key: string) => "";
} }