mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2026-08-27 20:44:57 -04:00
chore(deps): bump @actions/cache to 5.2.0
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
924ae3a1cd
commit
e5ac8080d8
4 changed files with 215 additions and 25 deletions
109
dist/cache-save/index.js
vendored
109
dist/cache-save/index.js
vendored
|
|
@ -49,7 +49,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.FinalizeCacheError = exports.CacheWriteDeniedError = exports.CACHE_WRITE_DENIED_PREFIX = exports.ReserveCacheError = exports.ValidationError = void 0;
|
||||
exports.FinalizeCacheError = exports.CacheReadDeniedError = exports.CACHE_READ_DENIED_PREFIX = exports.CacheWriteDeniedError = exports.CACHE_WRITE_DENIED_PREFIX = exports.ReserveCacheError = exports.ValidationError = void 0;
|
||||
exports.isFeatureAvailable = isFeatureAvailable;
|
||||
exports.restoreCache = restoreCache;
|
||||
exports.saveCache = saveCache;
|
||||
|
|
@ -61,6 +61,7 @@ const cacheTwirpClient = __importStar(__nccwpck_require__(96819));
|
|||
const config_1 = __nccwpck_require__(17606);
|
||||
const tar_1 = __nccwpck_require__(95321);
|
||||
const http_client_1 = __nccwpck_require__(54844);
|
||||
const constants_1 = __nccwpck_require__(58287);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
|
|
@ -97,6 +98,20 @@ class CacheWriteDeniedError extends ReserveCacheError {
|
|||
}
|
||||
}
|
||||
exports.CacheWriteDeniedError = CacheWriteDeniedError;
|
||||
// Re-exported from constants so consumers keep referencing it here; the shared
|
||||
// value also drives detection in cacheHttpClient without duplicating the string.
|
||||
exports.CACHE_READ_DENIED_PREFIX = constants_1.CacheReadDeniedMessagePrefix;
|
||||
// Raised when the cache backend denies a download URL because the run's token
|
||||
// has no readable cache scopes. Caching is best-effort, so restoreCache logs a
|
||||
// warning and reports a cache miss rather than rethrowing this.
|
||||
class CacheReadDeniedError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'CacheReadDeniedError';
|
||||
Object.setPrototypeOf(this, CacheReadDeniedError.prototype);
|
||||
}
|
||||
}
|
||||
exports.CacheReadDeniedError = CacheReadDeniedError;
|
||||
class FinalizeCacheError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
|
|
@ -152,6 +167,12 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
|
||||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||||
checkPaths(paths);
|
||||
const cacheMode = (0, config_1.getCacheMode)();
|
||||
if (!(0, config_1.isCacheReadable)(cacheMode)) {
|
||||
core.info(`Cache restore skipped: the effective cache-mode '${cacheMode}' does not permit reads.`);
|
||||
core.debug(`Skipped restore for paths [${paths.join(', ')}] with primary key '${primaryKey}'.`);
|
||||
return undefined;
|
||||
}
|
||||
switch (cacheServiceVersion) {
|
||||
case 'v2':
|
||||
return yield restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
|
||||
|
|
@ -173,6 +194,7 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
*/
|
||||
function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
var _a;
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
|
|
@ -187,10 +209,26 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
let archivePath = '';
|
||||
try {
|
||||
// path are needed to compute version
|
||||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||
let cacheEntry;
|
||||
try {
|
||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||
compressionMethod,
|
||||
enableCrossOsArchive
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
// The v1 artifact cache service returns HTTP 403 with a
|
||||
// `cache read denied:` body when the run's token has no readable cache
|
||||
// scopes. getCacheEntry lives in a dependency-free internal module and
|
||||
// cannot import CacheReadDeniedError without a circular dependency, so it
|
||||
// only surfaces the raw denial message; we classify it into the typed
|
||||
// error here so the outer catch and consumers can dispatch on it.
|
||||
const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
|
||||
if (errorMessage.includes(exports.CACHE_READ_DENIED_PREFIX)) {
|
||||
throw new CacheReadDeniedError(errorMessage);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||||
// Cache not found
|
||||
return undefined;
|
||||
|
|
@ -219,7 +257,9 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
}
|
||||
else {
|
||||
// warn on cache restore failure and continue build
|
||||
// Log server errors (5xx) as errors, all other errors as warnings
|
||||
// Log server errors (5xx) as errors, all other errors as warnings.
|
||||
// A read denied by policy (CacheReadDeniedError) is not an HttpClientError
|
||||
// so it falls here and is warned, treated as a cache miss.
|
||||
if (typedError instanceof http_client_1.HttpClientError &&
|
||||
typeof typedError.statusCode === 'number' &&
|
||||
typedError.statusCode >= 500) {
|
||||
|
|
@ -254,6 +294,7 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
*/
|
||||
function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
var _a;
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
|
|
@ -275,7 +316,20 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
restoreKeys,
|
||||
version: utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive)
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
let response;
|
||||
try {
|
||||
response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
}
|
||||
catch (error) {
|
||||
// The receiver returns twirp PermissionDenied (403) when the run's token
|
||||
// has no readable cache scopes. The client wraps that 403, so the stable
|
||||
// prefix is embedded in the message rather than leading it.
|
||||
const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
|
||||
if (errorMessage.includes(exports.CACHE_READ_DENIED_PREFIX)) {
|
||||
throw new CacheReadDeniedError(errorMessage);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!response.ok) {
|
||||
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
|
|
@ -311,7 +365,9 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
}
|
||||
else {
|
||||
// Supress all non-validation cache related errors because caching should be optional
|
||||
// Log server errors (5xx) as errors, all other errors as warnings
|
||||
// Log server errors (5xx) as errors, all other errors as warnings.
|
||||
// A read denied by policy (CacheReadDeniedError) is not an HttpClientError
|
||||
// so it falls here and is warned, treated as a cache miss.
|
||||
if (typedError instanceof http_client_1.HttpClientError &&
|
||||
typeof typedError.statusCode === 'number' &&
|
||||
typedError.statusCode >= 500) {
|
||||
|
|
@ -350,6 +406,12 @@ function saveCache(paths_1, key_1, options_1) {
|
|||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||||
checkPaths(paths);
|
||||
checkKey(key);
|
||||
const cacheMode = (0, config_1.getCacheMode)();
|
||||
if (!(0, config_1.isCacheWritable)(cacheMode)) {
|
||||
core.info(`Cache save skipped: the effective cache-mode '${cacheMode}' does not permit writes.`);
|
||||
core.debug(`Skipped save for paths [${paths.join(', ')}] with key '${key}'.`);
|
||||
return -1;
|
||||
}
|
||||
switch (cacheServiceVersion) {
|
||||
case 'v2':
|
||||
return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
|
||||
|
|
@ -1264,6 +1326,7 @@ const downloadUtils_1 = __nccwpck_require__(75067);
|
|||
const options_1 = __nccwpck_require__(98356);
|
||||
const requestUtils_1 = __nccwpck_require__(32846);
|
||||
const config_1 = __nccwpck_require__(17606);
|
||||
const constants_1 = __nccwpck_require__(58287);
|
||||
const user_agent_1 = __nccwpck_require__(41899);
|
||||
function getCacheApiUrl(resource) {
|
||||
const baseUrl = (0, config_1.getCacheServiceURL)();
|
||||
|
|
@ -1292,6 +1355,7 @@ function createHttpClient() {
|
|||
}
|
||||
function getCacheEntry(keys, paths, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const httpClient = createHttpClient();
|
||||
const version = utils.getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
|
||||
const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
|
||||
|
|
@ -1305,6 +1369,12 @@ function getCacheEntry(keys, paths, options) {
|
|||
return null;
|
||||
}
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(response.statusCode)) {
|
||||
// Only surface the receiver's body for a `cache read denied:` policy denial
|
||||
// so callers can dispatch on it; keep the generic message otherwise.
|
||||
const errorMessage = (_a = response.error) === null || _a === void 0 ? void 0 : _a.message;
|
||||
if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.includes(constants_1.CacheReadDeniedMessagePrefix)) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
throw new Error(`Cache service responded with ${response.statusCode}`);
|
||||
}
|
||||
const cacheResult = response.result;
|
||||
|
|
@ -1713,6 +1783,9 @@ function getRuntimeToken() {
|
|||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isGhes = isGhes;
|
||||
exports.getCacheServiceVersion = getCacheServiceVersion;
|
||||
exports.getCacheMode = getCacheMode;
|
||||
exports.isCacheReadable = isCacheReadable;
|
||||
exports.isCacheWritable = isCacheWritable;
|
||||
exports.getCacheServiceURL = getCacheServiceURL;
|
||||
function isGhes() {
|
||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||
|
|
@ -1729,6 +1802,24 @@ function getCacheServiceVersion() {
|
|||
return 'v1';
|
||||
return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1';
|
||||
}
|
||||
// The cache-mode lattice: readable = {read, write}, writable = {write,
|
||||
// write-only}, none = neither.
|
||||
const KNOWN_CACHE_MODES = ['none', 'read', 'write', 'write-only'];
|
||||
// The effective cache-mode exported by the runner, or '' when not set.
|
||||
function getCacheMode() {
|
||||
return (process.env['ACTIONS_CACHE_MODE'] || '').trim().toLowerCase();
|
||||
}
|
||||
// Unset or unrecognized modes are permissive so behavior matches today.
|
||||
function isCacheReadable(mode) {
|
||||
if (!KNOWN_CACHE_MODES.includes(mode))
|
||||
return true;
|
||||
return mode === 'read' || mode === 'write';
|
||||
}
|
||||
function isCacheWritable(mode) {
|
||||
if (!KNOWN_CACHE_MODES.includes(mode))
|
||||
return true;
|
||||
return mode === 'write' || mode === 'write-only';
|
||||
}
|
||||
function getCacheServiceURL() {
|
||||
const version = getCacheServiceVersion();
|
||||
// Based on the version of the cache service, we will determine which
|
||||
|
|
@ -1754,7 +1845,7 @@ function getCacheServiceURL() {
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
||||
exports.CacheReadDeniedMessagePrefix = exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
||||
var CacheFilename;
|
||||
(function (CacheFilename) {
|
||||
CacheFilename["Gzip"] = "cache.tgz";
|
||||
|
|
@ -1788,6 +1879,10 @@ exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System
|
|||
exports.TarFilename = 'cache.tar';
|
||||
exports.ManifestFilename = 'manifest.txt';
|
||||
exports.CacheFileSizeLimit = 10 * Math.pow(1024, 3); // 10GiB per repository
|
||||
// Prefix the cache backend embeds in a read-denial message (v2 twirp
|
||||
// GetCacheEntryDownloadURL error or the GHES v1 `_apis/artifactcache` 403 body).
|
||||
// Shared so cache.ts and cacheHttpClient.ts match the same contract value.
|
||||
exports.CacheReadDeniedMessagePrefix = 'cache read denied:';
|
||||
//# sourceMappingURL=constants.js.map
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -88230,7 +88325,7 @@ function randomUUID() {
|
|||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.1.0","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.1","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.2","@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.2.0","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.1","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.2","@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"}}');
|
||||
|
||||
/***/ })
|
||||
|
||||
|
|
|
|||
109
dist/setup/index.js
vendored
109
dist/setup/index.js
vendored
|
|
@ -49,7 +49,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.FinalizeCacheError = exports.CacheWriteDeniedError = exports.CACHE_WRITE_DENIED_PREFIX = exports.ReserveCacheError = exports.ValidationError = void 0;
|
||||
exports.FinalizeCacheError = exports.CacheReadDeniedError = exports.CACHE_READ_DENIED_PREFIX = exports.CacheWriteDeniedError = exports.CACHE_WRITE_DENIED_PREFIX = exports.ReserveCacheError = exports.ValidationError = void 0;
|
||||
exports.isFeatureAvailable = isFeatureAvailable;
|
||||
exports.restoreCache = restoreCache;
|
||||
exports.saveCache = saveCache;
|
||||
|
|
@ -61,6 +61,7 @@ const cacheTwirpClient = __importStar(__nccwpck_require__(96819));
|
|||
const config_1 = __nccwpck_require__(17606);
|
||||
const tar_1 = __nccwpck_require__(95321);
|
||||
const http_client_1 = __nccwpck_require__(54844);
|
||||
const constants_1 = __nccwpck_require__(58287);
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
|
|
@ -97,6 +98,20 @@ class CacheWriteDeniedError extends ReserveCacheError {
|
|||
}
|
||||
}
|
||||
exports.CacheWriteDeniedError = CacheWriteDeniedError;
|
||||
// Re-exported from constants so consumers keep referencing it here; the shared
|
||||
// value also drives detection in cacheHttpClient without duplicating the string.
|
||||
exports.CACHE_READ_DENIED_PREFIX = constants_1.CacheReadDeniedMessagePrefix;
|
||||
// Raised when the cache backend denies a download URL because the run's token
|
||||
// has no readable cache scopes. Caching is best-effort, so restoreCache logs a
|
||||
// warning and reports a cache miss rather than rethrowing this.
|
||||
class CacheReadDeniedError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'CacheReadDeniedError';
|
||||
Object.setPrototypeOf(this, CacheReadDeniedError.prototype);
|
||||
}
|
||||
}
|
||||
exports.CacheReadDeniedError = CacheReadDeniedError;
|
||||
class FinalizeCacheError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
|
|
@ -152,6 +167,12 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
|
||||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||||
checkPaths(paths);
|
||||
const cacheMode = (0, config_1.getCacheMode)();
|
||||
if (!(0, config_1.isCacheReadable)(cacheMode)) {
|
||||
core.info(`Cache restore skipped: the effective cache-mode '${cacheMode}' does not permit reads.`);
|
||||
core.debug(`Skipped restore for paths [${paths.join(', ')}] with primary key '${primaryKey}'.`);
|
||||
return undefined;
|
||||
}
|
||||
switch (cacheServiceVersion) {
|
||||
case 'v2':
|
||||
return yield restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
|
||||
|
|
@ -173,6 +194,7 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
*/
|
||||
function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
var _a;
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
|
|
@ -187,10 +209,26 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
let archivePath = '';
|
||||
try {
|
||||
// path are needed to compute version
|
||||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||
let cacheEntry;
|
||||
try {
|
||||
cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||
compressionMethod,
|
||||
enableCrossOsArchive
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
// The v1 artifact cache service returns HTTP 403 with a
|
||||
// `cache read denied:` body when the run's token has no readable cache
|
||||
// scopes. getCacheEntry lives in a dependency-free internal module and
|
||||
// cannot import CacheReadDeniedError without a circular dependency, so it
|
||||
// only surfaces the raw denial message; we classify it into the typed
|
||||
// error here so the outer catch and consumers can dispatch on it.
|
||||
const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
|
||||
if (errorMessage.includes(exports.CACHE_READ_DENIED_PREFIX)) {
|
||||
throw new CacheReadDeniedError(errorMessage);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||||
// Cache not found
|
||||
return undefined;
|
||||
|
|
@ -219,7 +257,9 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
}
|
||||
else {
|
||||
// warn on cache restore failure and continue build
|
||||
// Log server errors (5xx) as errors, all other errors as warnings
|
||||
// Log server errors (5xx) as errors, all other errors as warnings.
|
||||
// A read denied by policy (CacheReadDeniedError) is not an HttpClientError
|
||||
// so it falls here and is warned, treated as a cache miss.
|
||||
if (typedError instanceof http_client_1.HttpClientError &&
|
||||
typeof typedError.statusCode === 'number' &&
|
||||
typedError.statusCode >= 500) {
|
||||
|
|
@ -254,6 +294,7 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
*/
|
||||
function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
|
||||
var _a;
|
||||
// Override UploadOptions to force the use of Azure
|
||||
options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
|
||||
restoreKeys = restoreKeys || [];
|
||||
|
|
@ -275,7 +316,20 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
restoreKeys,
|
||||
version: utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive)
|
||||
};
|
||||
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
let response;
|
||||
try {
|
||||
response = yield twirpClient.GetCacheEntryDownloadURL(request);
|
||||
}
|
||||
catch (error) {
|
||||
// The receiver returns twirp PermissionDenied (403) when the run's token
|
||||
// has no readable cache scopes. The client wraps that 403, so the stable
|
||||
// prefix is embedded in the message rather than leading it.
|
||||
const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
|
||||
if (errorMessage.includes(exports.CACHE_READ_DENIED_PREFIX)) {
|
||||
throw new CacheReadDeniedError(errorMessage);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
if (!response.ok) {
|
||||
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
|
||||
return undefined;
|
||||
|
|
@ -311,7 +365,9 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
|
|||
}
|
||||
else {
|
||||
// Supress all non-validation cache related errors because caching should be optional
|
||||
// Log server errors (5xx) as errors, all other errors as warnings
|
||||
// Log server errors (5xx) as errors, all other errors as warnings.
|
||||
// A read denied by policy (CacheReadDeniedError) is not an HttpClientError
|
||||
// so it falls here and is warned, treated as a cache miss.
|
||||
if (typedError instanceof http_client_1.HttpClientError &&
|
||||
typeof typedError.statusCode === 'number' &&
|
||||
typedError.statusCode >= 500) {
|
||||
|
|
@ -350,6 +406,12 @@ function saveCache(paths_1, key_1, options_1) {
|
|||
core.debug(`Cache service version: ${cacheServiceVersion}`);
|
||||
checkPaths(paths);
|
||||
checkKey(key);
|
||||
const cacheMode = (0, config_1.getCacheMode)();
|
||||
if (!(0, config_1.isCacheWritable)(cacheMode)) {
|
||||
core.info(`Cache save skipped: the effective cache-mode '${cacheMode}' does not permit writes.`);
|
||||
core.debug(`Skipped save for paths [${paths.join(', ')}] with key '${key}'.`);
|
||||
return -1;
|
||||
}
|
||||
switch (cacheServiceVersion) {
|
||||
case 'v2':
|
||||
return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
|
||||
|
|
@ -1264,6 +1326,7 @@ const downloadUtils_1 = __nccwpck_require__(75067);
|
|||
const options_1 = __nccwpck_require__(98356);
|
||||
const requestUtils_1 = __nccwpck_require__(32846);
|
||||
const config_1 = __nccwpck_require__(17606);
|
||||
const constants_1 = __nccwpck_require__(58287);
|
||||
const user_agent_1 = __nccwpck_require__(41899);
|
||||
function getCacheApiUrl(resource) {
|
||||
const baseUrl = (0, config_1.getCacheServiceURL)();
|
||||
|
|
@ -1292,6 +1355,7 @@ function createHttpClient() {
|
|||
}
|
||||
function getCacheEntry(keys, paths, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const httpClient = createHttpClient();
|
||||
const version = utils.getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
|
||||
const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
|
||||
|
|
@ -1305,6 +1369,12 @@ function getCacheEntry(keys, paths, options) {
|
|||
return null;
|
||||
}
|
||||
if (!(0, requestUtils_1.isSuccessStatusCode)(response.statusCode)) {
|
||||
// Only surface the receiver's body for a `cache read denied:` policy denial
|
||||
// so callers can dispatch on it; keep the generic message otherwise.
|
||||
const errorMessage = (_a = response.error) === null || _a === void 0 ? void 0 : _a.message;
|
||||
if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.includes(constants_1.CacheReadDeniedMessagePrefix)) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
throw new Error(`Cache service responded with ${response.statusCode}`);
|
||||
}
|
||||
const cacheResult = response.result;
|
||||
|
|
@ -1713,6 +1783,9 @@ function getRuntimeToken() {
|
|||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isGhes = isGhes;
|
||||
exports.getCacheServiceVersion = getCacheServiceVersion;
|
||||
exports.getCacheMode = getCacheMode;
|
||||
exports.isCacheReadable = isCacheReadable;
|
||||
exports.isCacheWritable = isCacheWritable;
|
||||
exports.getCacheServiceURL = getCacheServiceURL;
|
||||
function isGhes() {
|
||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||
|
|
@ -1729,6 +1802,24 @@ function getCacheServiceVersion() {
|
|||
return 'v1';
|
||||
return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1';
|
||||
}
|
||||
// The cache-mode lattice: readable = {read, write}, writable = {write,
|
||||
// write-only}, none = neither.
|
||||
const KNOWN_CACHE_MODES = ['none', 'read', 'write', 'write-only'];
|
||||
// The effective cache-mode exported by the runner, or '' when not set.
|
||||
function getCacheMode() {
|
||||
return (process.env['ACTIONS_CACHE_MODE'] || '').trim().toLowerCase();
|
||||
}
|
||||
// Unset or unrecognized modes are permissive so behavior matches today.
|
||||
function isCacheReadable(mode) {
|
||||
if (!KNOWN_CACHE_MODES.includes(mode))
|
||||
return true;
|
||||
return mode === 'read' || mode === 'write';
|
||||
}
|
||||
function isCacheWritable(mode) {
|
||||
if (!KNOWN_CACHE_MODES.includes(mode))
|
||||
return true;
|
||||
return mode === 'write' || mode === 'write-only';
|
||||
}
|
||||
function getCacheServiceURL() {
|
||||
const version = getCacheServiceVersion();
|
||||
// Based on the version of the cache service, we will determine which
|
||||
|
|
@ -1754,7 +1845,7 @@ function getCacheServiceURL() {
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
||||
exports.CacheReadDeniedMessagePrefix = exports.CacheFileSizeLimit = exports.ManifestFilename = exports.TarFilename = exports.SystemTarPathOnWindows = exports.GnuTarPathOnWindows = exports.SocketTimeout = exports.DefaultRetryDelay = exports.DefaultRetryAttempts = exports.ArchiveToolType = exports.CompressionMethod = exports.CacheFilename = void 0;
|
||||
var CacheFilename;
|
||||
(function (CacheFilename) {
|
||||
CacheFilename["Gzip"] = "cache.tgz";
|
||||
|
|
@ -1788,6 +1879,10 @@ exports.SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System
|
|||
exports.TarFilename = 'cache.tar';
|
||||
exports.ManifestFilename = 'manifest.txt';
|
||||
exports.CacheFileSizeLimit = 10 * Math.pow(1024, 3); // 10GiB per repository
|
||||
// Prefix the cache backend embeds in a read-denial message (v2 twirp
|
||||
// GetCacheEntryDownloadURL error or the GHES v1 `_apis/artifactcache` 403 body).
|
||||
// Shared so cache.ts and cacheHttpClient.ts match the same contract value.
|
||||
exports.CacheReadDeniedMessagePrefix = 'cache read denied:';
|
||||
//# sourceMappingURL=constants.js.map
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -94442,7 +94537,7 @@ function randomUUID() {
|
|||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"5.1.0","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.1","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.2","@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.2.0","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.1","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^3.0.2","@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"}}');
|
||||
|
||||
/***/ })
|
||||
|
||||
|
|
|
|||
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -9,7 +9,7 @@
|
|||
"version": "6.5.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^5.1.0",
|
||||
"@actions/cache": "^5.2.0",
|
||||
"@actions/core": "^2.0.3",
|
||||
"@actions/exec": "^2.0.0",
|
||||
"@actions/glob": "^0.5.1",
|
||||
|
|
@ -41,9 +41,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@actions/cache": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.1.0.tgz",
|
||||
"integrity": "sha512-kTIj4YPrjjRPKSGlj7f8eq+Pijoy/SKBEbJcAwNsQTFGEF29NGqj1mqD02/PmhV6r4bRAixycexAWpmUJ2aCwg==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-5.2.0.tgz",
|
||||
"integrity": "sha512-1R1Oc8cuDNCygsIP7gLiKLGCymOw/k5FkGQkXZFcLz6/RWyMImkfP0dZX6kjA9SRAmANcKNocI2XrsIaZ1it8w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^2.0.0",
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^5.1.0",
|
||||
"@actions/cache": "^5.2.0",
|
||||
"@actions/core": "^2.0.3",
|
||||
"@actions/exec": "^2.0.0",
|
||||
"@actions/glob": "^0.5.1",
|
||||
|
|
|
|||
Loading…
Reference in a new issue