+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 97 additions & 20 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.ReserveCacheError = exports.ValidationError = void 0;
exports.saveCache = exports.restoreCache = exports.isFeatureAvailable = exports.FinalizeCacheError = exports.ReserveCacheError = exports.ValidationError = void 0;
const core = __importStar(__nccwpck_require__(7484));
const path = __importStar(__nccwpck_require__(6928));
const utils = __importStar(__nccwpck_require__(680));
const cacheHttpClient = __importStar(__nccwpck_require__(5552));
const cacheTwirpClient = __importStar(__nccwpck_require__(6819));
const config_1 = __nccwpck_require__(7606);
const tar_1 = __nccwpck_require__(5321);
const constants_1 = __nccwpck_require__(8287);
const http_client_1 = __nccwpck_require__(4844);
class ValidationError extends Error {
constructor(message) {
super(message);
Expand All @@ -550,6 +550,14 @@ class ReserveCacheError extends Error {
}
}
exports.ReserveCacheError = ReserveCacheError;
class FinalizeCacheError extends Error {
constructor(message) {
super(message);
this.name = 'FinalizeCacheError';
Object.setPrototypeOf(this, FinalizeCacheError.prototype);
}
}
exports.FinalizeCacheError = FinalizeCacheError;
function checkPaths(paths) {
if (!paths || paths.length === 0) {
throw new ValidationError(`Path Validation Error: At least one directory or file path is required`);
Expand All @@ -570,7 +578,17 @@ function checkKey(key) {
* @returns boolean return true if Actions cache service feature is available, otherwise false
*/
function isFeatureAvailable() {
return !!process.env['ACTIONS_CACHE_URL'];
const cacheServiceVersion = (0, config_1.getCacheServiceVersion)();
// Check availability based on cache service version
switch (cacheServiceVersion) {
case 'v2':
// For v2, we need ACTIONS_RESULTS_URL
return !!process.env['ACTIONS_RESULTS_URL'];
case 'v1':
default:
// For v1, we only need ACTIONS_CACHE_URL
return !!process.env['ACTIONS_CACHE_URL'];
}
}
exports.isFeatureAvailable = isFeatureAvailable;
/**
Expand Down Expand Up @@ -655,8 +673,16 @@ function restoreCacheV1(paths, primaryKey, restoreKeys, options, enableCrossOsAr
throw error;
}
else {
// Supress all non-validation cache related errors because caching should be optional
core.warning(`Failed to restore: ${error.message}`);
// warn on cache restore failure and continue build
// Log server errors (5xx) as errors, all other errors as warnings
if (typedError instanceof http_client_1.HttpClientError &&
typeof typedError.statusCode === 'number' &&
typedError.statusCode >= 500) {
core.error(`Failed to restore: ${error.message}`);
}
else {
core.warning(`Failed to restore: ${error.message}`);
}
}
}
finally {
Expand Down Expand Up @@ -709,7 +735,13 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
return undefined;
}
core.info(`Cache hit for: ${request.key}`);
const isRestoreKeyMatch = request.key !== response.matchedKey;
if (isRestoreKeyMatch) {
core.info(`Cache hit for restore-key: ${response.matchedKey}`);
}
else {
core.info(`Cache hit for: ${response.matchedKey}`);
}
if (options === null || options === void 0 ? void 0 : options.lookupOnly) {
core.info('Lookup only - skipping download');
return response.matchedKey;
Expand All @@ -734,7 +766,15 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
}
else {
// Supress all non-validation cache related errors because caching should be optional
core.warning(`Failed to restore: ${error.message}`);
// Log server errors (5xx) as errors, all other errors as warnings
if (typedError instanceof http_client_1.HttpClientError &&
typeof typedError.statusCode === 'number' &&
typedError.statusCode >= 500) {
core.error(`Failed to restore: ${error.message}`);
}
else {
core.warning(`Failed to restore: ${error.message}`);
}
}
}
finally {
Expand Down Expand Up @@ -837,7 +877,15 @@ function saveCacheV1(paths, key, options, enableCrossOsArchive = false) {
core.info(`Failed to save: ${typedError.message}`);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
// Log server errors (5xx) as errors, all other errors as warnings
if (typedError instanceof http_client_1.HttpClientError &&
typeof typedError.statusCode === 'number' &&
typedError.statusCode >= 500) {
core.error(`Failed to save: ${typedError.message}`);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
}
}
}
finally {
Expand Down Expand Up @@ -886,10 +934,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
}
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
core.debug(`File Size: ${archiveFileSize}`);
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) {
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
}
// Set the archive size in the options, will be used to display the upload progress
options.archiveSizeBytes = archiveFileSize;
core.debug('Reserving Cache');
Expand All @@ -902,7 +946,10 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
try {
const response = yield twirpClient.CreateCacheEntry(request);
if (!response.ok) {
throw new Error('Response was not ok');
if (response.message) {
core.warning(`Cache reservation failed: ${response.message}`);
}
throw new Error(response.message || 'Response was not ok');
}
signedUploadUrl = response.signedUploadUrl;
}
Expand All @@ -920,6 +967,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
const finalizeResponse = yield twirpClient.FinalizeCacheEntryUpload(finalizeRequest);
core.debug(`FinalizeCacheEntryUploadResponse: ${finalizeResponse.ok}`);
if (!finalizeResponse.ok) {
if (finalizeResponse.message) {
throw new FinalizeCacheError(finalizeResponse.message);
}
throw new Error(`Unable to finalize cache with key ${key}, another job may be finalizing this cache.`);
}
cacheId = parseInt(finalizeResponse.entryId);
Expand All @@ -932,8 +982,19 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`);
}
else if (typedError.name === FinalizeCacheError.name) {
core.warning(typedError.message);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
// Log server errors (5xx) as errors, all other errors as warnings
if (typedError instanceof http_client_1.HttpClientError &&
typeof typedError.statusCode === 'number' &&
typedError.statusCode >= 500) {
core.error(`Failed to save: ${typedError.message}`);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
}
}
}
finally {
Expand Down Expand Up @@ -1035,11 +1096,12 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType {
constructor() {
super("github.actions.results.api.v1.CreateCacheEntryResponse", [
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
{ no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
{ no: 2, name: "signed_upload_url", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value) {
const message = { ok: false, signedUploadUrl: "" };
const message = { ok: false, signedUploadUrl: "", message: "" };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
Expand All @@ -1056,6 +1118,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType {
case /* string signed_upload_url */ 2:
message.signedUploadUrl = reader.string();
break;
case /* string message */ 3:
message.message = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
Expand All @@ -1074,6 +1139,9 @@ class CreateCacheEntryResponse$Type extends runtime_5.MessageType {
/* string signed_upload_url = 2; */
if (message.signedUploadUrl !== "")
writer.tag(2, runtime_1.WireType.LengthDelimited).string(message.signedUploadUrl);
/* string message = 3; */
if (message.message !== "")
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
Expand Down Expand Up @@ -1157,11 +1225,12 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType {
constructor() {
super("github.actions.results.api.v1.FinalizeCacheEntryUploadResponse", [
{ no: 1, name: "ok", kind: "scalar", T: 8 /*ScalarType.BOOL*/ },
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ }
{ no: 2, name: "entry_id", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
{ no: 3, name: "message", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
]);
}
create(value) {
const message = { ok: false, entryId: "0" };
const message = { ok: false, entryId: "0", message: "" };
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
if (value !== undefined)
(0, runtime_3.reflectionMergePartial)(this, message, value);
Expand All @@ -1178,6 +1247,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType {
case /* int64 entry_id */ 2:
message.entryId = reader.int64().toString();
break;
case /* string message */ 3:
message.message = reader.string();
break;
default:
let u = options.readUnknownField;
if (u === "throw")
Expand All @@ -1196,6 +1268,9 @@ class FinalizeCacheEntryUploadResponse$Type extends runtime_5.MessageType {
/* int64 entry_id = 2; */
if (message.entryId !== "0")
writer.tag(2, runtime_1.WireType.Varint).int64(message.entryId);
/* string message = 3; */
if (message.message !== "")
writer.tag(3, runtime_1.WireType.LengthDelimited).string(message.message);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? runtime_2.UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
Expand Down Expand Up @@ -36553,6 +36628,7 @@ const reflection_equals_1 = __nccwpck_require__(4827);
const binary_writer_1 = __nccwpck_require__(3957);
const binary_reader_1 = __nccwpck_require__(2889);
const baseDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf({}));
const messageTypeDescriptor = baseDescriptors[message_type_contract_1.MESSAGE_TYPE] = {};
/**
* This standard message type provides reflection-based
* operations to work with a message.
Expand All @@ -36563,7 +36639,8 @@ class MessageType {
this.typeName = name;
this.fields = fields.map(reflection_info_1.normalizeFieldInfo);
this.options = options !== null && options !== void 0 ? options : {};
this.messagePrototype = Object.create(null, Object.assign(Object.assign({}, baseDescriptors), { [message_type_contract_1.MESSAGE_TYPE]: { value: this } }));
messageTypeDescriptor.value = this;
this.messagePrototype = Object.create(null, baseDescriptors);
this.refTypeCheck = new reflection_type_check_1.ReflectionTypeCheck(this);
this.refJsonReader = new reflection_json_reader_1.ReflectionJsonReader(this);
this.refJsonWriter = new reflection_json_writer_1.ReflectionJsonWriter(this);
Expand Down Expand Up @@ -79791,7 +79868,7 @@ module.exports = parseParams
/***/ ((module) => {

"use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.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":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.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":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@protobuf-ts/runtime-rpc":"^2.11.1","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","@protobuf-ts/plugin":"^2.9.4","typescript":"^5.2.2"}}');

/***/ })

Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载