From aad9d15d47a6041a1c5e79c6c58cc0675630817c Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 29 Mar 2022 23:49:07 +0530 Subject: [PATCH 1/6] new tollkit and isghes --- __tests__/actionUtils.test.ts | 2 +- dist/restore/index.js | 290 ++++------------------------------ dist/save/index.js | 290 ++++------------------------------ package-lock.json | 11 +- package.json | 2 +- src/utils/actionUtils.ts | 5 +- 6 files changed, 64 insertions(+), 536 deletions(-) diff --git a/__tests__/actionUtils.test.ts b/__tests__/actionUtils.test.ts index c220e71..544a464 100644 --- a/__tests__/actionUtils.test.ts +++ b/__tests__/actionUtils.test.ts @@ -20,7 +20,7 @@ afterEach(() => { test("isGhes returns true if server url is not github.com", () => { try { process.env["GITHUB_SERVER_URL"] = "http://example.com"; - expect(actionUtils.isGhes()).toBe(true); + expect(actionUtils.isGhes()).toBe(false); } finally { process.env["GITHUB_SERVER_URL"] = undefined; } diff --git a/dist/restore/index.js b/dist/restore/index.js index c56b6cd..9313aff 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -1405,36 +1405,7 @@ exports.default = _default; /* 39 */, /* 40 */, /* 41 */, -/* 42 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createTraceState = void 0; -var tracestate_impl_1 = __webpack_require__(756); -function createTraceState(rawTraceState) { - return new tracestate_impl_1.TraceStateImpl(rawTraceState); -} -exports.createTraceState = createTraceState; -//# sourceMappingURL=utils.js.map - -/***/ }), +/* 42 */, /* 43 */, /* 44 */, /* 45 */, @@ -3221,10 +3192,7 @@ const options_1 = __webpack_require__(538); const requestUtils_1 = __webpack_require__(899); const versionSalt = '1.0'; function getCacheApiUrl(resource) { - // Ideally we just use ACTIONS_CACHE_URL - const baseUrl = (process.env['ACTIONS_CACHE_URL'] || - process.env['ACTIONS_RUNTIME_URL'] || - '').replace('pipelines', 'artifactcache'); + const baseUrl = process.env['ACTIONS_CACHE_URL'] || ''; if (!baseUrl) { throw new Error('Cache Service Url not found, unable to restore cache.'); } @@ -3313,6 +3281,7 @@ function reserveCache(key, paths, options) { const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); + console.log(response); return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; }); } @@ -4470,7 +4439,7 @@ var NoopTracer_1 = __webpack_require__(151); var NoopTracerProvider = /** @class */ (function () { function NoopTracerProvider() { } - NoopTracerProvider.prototype.getTracer = function (_name, _version, _options) { + NoopTracerProvider.prototype.getTracer = function (_name, _version) { return new NoopTracer_1.NoopTracer(); }; return NoopTracerProvider; @@ -5519,7 +5488,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { // // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // on 64-bit systems), split the download into multiple segments - const maxSegmentSize = buffer.constants.MAX_LENGTH; + // ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. + const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH); const downloadProgress = new DownloadProgress(contentLength); const fd = fs.openSync(archivePath, 'w'); try { @@ -36293,9 +36263,9 @@ var ProxyTracerProvider = /** @class */ (function () { /** * Get a {@link ProxyTracer} */ - ProxyTracerProvider.prototype.getTracer = function (name, version, options) { + ProxyTracerProvider.prototype.getTracer = function (name, version) { var _a; - return ((_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name, version, options)); + return ((_a = this.getDelegateTracer(name, version)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name, version)); }; ProxyTracerProvider.prototype.getDelegate = function () { var _a; @@ -36307,9 +36277,9 @@ var ProxyTracerProvider = /** @class */ (function () { ProxyTracerProvider.prototype.setDelegate = function (delegate) { this._delegate = delegate; }; - ProxyTracerProvider.prototype.getDelegateTracer = function (name, version, options) { + ProxyTracerProvider.prototype.getDelegateTracer = function (name, version) { var _a; - return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options); + return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version); }; return ProxyTracerProvider; }()); @@ -36348,11 +36318,10 @@ var NOOP_TRACER = new NoopTracer_1.NoopTracer(); * Proxy tracer provided by the proxy tracer provider */ var ProxyTracer = /** @class */ (function () { - function ProxyTracer(_provider, name, version, options) { + function ProxyTracer(_provider, name, version) { this._provider = _provider; this.name = name; this.version = version; - this.options = options; } ProxyTracer.prototype.startSpan = function (name, options, context) { return this._getTracer().startSpan(name, options, context); @@ -36369,7 +36338,7 @@ var ProxyTracer = /** @class */ (function () { if (this._delegate) { return this._delegate; } - var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options); + var tracer = this._provider.getDelegateTracer(this.name, this.version); if (!tracer) { return NOOP_TRACER; } @@ -37369,13 +37338,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.diag = exports.propagation = exports.trace = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.baggageEntryMetadataFromString = void 0; +exports.diag = exports.propagation = exports.trace = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.baggageEntryMetadataFromString = void 0; __exportStar(__webpack_require__(880), exports); var utils_1 = __webpack_require__(112); Object.defineProperty(exports, "baggageEntryMetadataFromString", { enumerable: true, get: function () { return utils_1.baggageEntryMetadataFromString; } }); __exportStar(__webpack_require__(452), exports); __exportStar(__webpack_require__(158), exports); -__exportStar(__webpack_require__(907), exports); __exportStar(__webpack_require__(893), exports); __exportStar(__webpack_require__(881), exports); __exportStar(__webpack_require__(906), exports); @@ -37391,11 +37359,8 @@ __exportStar(__webpack_require__(220), exports); __exportStar(__webpack_require__(932), exports); __exportStar(__webpack_require__(975), exports); __exportStar(__webpack_require__(207), exports); -var utils_2 = __webpack_require__(42); -Object.defineProperty(exports, "createTraceState", { enumerable: true, get: function () { return utils_2.createTraceState; } }); __exportStar(__webpack_require__(694), exports); __exportStar(__webpack_require__(695), exports); -__exportStar(__webpack_require__(743), exports); var spancontext_utils_1 = __webpack_require__(629); Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } }); Object.defineProperty(exports, "isValidTraceId", { enumerable: true, get: function () { return spancontext_utils_1.isValidTraceId; } }); @@ -37463,8 +37428,7 @@ exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); function isGhes() { - const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); - return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; + return false; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { @@ -42117,58 +42081,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); /* 587 */, /* 588 */, /* 589 */, -/* 590 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validateValue = exports.validateKey = void 0; -var VALID_KEY_CHAR_RANGE = '[_0-9a-z-*/]'; -var VALID_KEY = "[a-z]" + VALID_KEY_CHAR_RANGE + "{0,255}"; -var VALID_VENDOR_KEY = "[a-z0-9]" + VALID_KEY_CHAR_RANGE + "{0,240}@[a-z]" + VALID_KEY_CHAR_RANGE + "{0,13}"; -var VALID_KEY_REGEX = new RegExp("^(?:" + VALID_KEY + "|" + VALID_VENDOR_KEY + ")$"); -var VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/; -var INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/; -/** - * Key is opaque string up to 256 characters printable. It MUST begin with a - * lowercase letter, and can only contain lowercase letters a-z, digits 0-9, - * underscores _, dashes -, asterisks *, and forward slashes /. - * For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the - * vendor name. Vendors SHOULD set the tenant ID at the beginning of the key. - * see https://www.w3.org/TR/trace-context/#key - */ -function validateKey(key) { - return VALID_KEY_REGEX.test(key); -} -exports.validateKey = validateKey; -/** - * Value is opaque string up to 256 characters printable ASCII RFC0020 - * characters (i.e., the range 0x20 to 0x7E) except comma , and =. - */ -function validateValue(value) { - return (VALID_VALUE_BASE_REGEX.test(value) && - !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value)); -} -exports.validateValue = validateValue; -//# sourceMappingURL=tracestate-validators.js.map - -/***/ }), +/* 590 */, /* 591 */, /* 592 */, /* 593 */, @@ -46439,6 +46352,15 @@ function checkKey(key) { throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`); } } +/** + * isFeatureAvailable to check the presence of Actions cache service + * + * @returns boolean return true if Actions cache service feature is available, otherwise false + */ +function isFeatureAvailable() { + return !!process.env['ACTIONS_CACHE_URL']; +} +exports.isFeatureAvailable = isFeatureAvailable; /** * Restores cache from keys * @@ -47220,30 +47142,7 @@ exports.OidcClient = OidcClient; //# sourceMappingURL=oidc-utils.js.map /***/ }), -/* 743 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=tracer_options.js.map - -/***/ }), +/* 743 */, /* 744 */, /* 745 */, /* 746 */, @@ -47340,117 +47239,7 @@ function async(callback) /* 753 */, /* 754 */, /* 755 */, -/* 756 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TraceStateImpl = void 0; -var tracestate_validators_1 = __webpack_require__(590); -var MAX_TRACE_STATE_ITEMS = 32; -var MAX_TRACE_STATE_LEN = 512; -var LIST_MEMBERS_SEPARATOR = ','; -var LIST_MEMBER_KEY_VALUE_SPLITTER = '='; -/** - * TraceState must be a class and not a simple object type because of the spec - * requirement (https://www.w3.org/TR/trace-context/#tracestate-field). - * - * Here is the list of allowed mutations: - * - New key-value pair should be added into the beginning of the list - * - The value of any key can be updated. Modified keys MUST be moved to the - * beginning of the list. - */ -var TraceStateImpl = /** @class */ (function () { - function TraceStateImpl(rawTraceState) { - this._internalState = new Map(); - if (rawTraceState) - this._parse(rawTraceState); - } - TraceStateImpl.prototype.set = function (key, value) { - // TODO: Benchmark the different approaches(map vs list) and - // use the faster one. - var traceState = this._clone(); - if (traceState._internalState.has(key)) { - traceState._internalState.delete(key); - } - traceState._internalState.set(key, value); - return traceState; - }; - TraceStateImpl.prototype.unset = function (key) { - var traceState = this._clone(); - traceState._internalState.delete(key); - return traceState; - }; - TraceStateImpl.prototype.get = function (key) { - return this._internalState.get(key); - }; - TraceStateImpl.prototype.serialize = function () { - var _this = this; - return this._keys() - .reduce(function (agg, key) { - agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + _this.get(key)); - return agg; - }, []) - .join(LIST_MEMBERS_SEPARATOR); - }; - TraceStateImpl.prototype._parse = function (rawTraceState) { - if (rawTraceState.length > MAX_TRACE_STATE_LEN) - return; - this._internalState = rawTraceState - .split(LIST_MEMBERS_SEPARATOR) - .reverse() // Store in reverse so new keys (.set(...)) will be placed at the beginning - .reduce(function (agg, part) { - var listMember = part.trim(); // Optional Whitespace (OWS) handling - var i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER); - if (i !== -1) { - var key = listMember.slice(0, i); - var value = listMember.slice(i + 1, part.length); - if (tracestate_validators_1.validateKey(key) && tracestate_validators_1.validateValue(value)) { - agg.set(key, value); - } - else { - // TODO: Consider to add warning log - } - } - return agg; - }, new Map()); - // Because of the reverse() requirement, trunc must be done after map is created - if (this._internalState.size > MAX_TRACE_STATE_ITEMS) { - this._internalState = new Map(Array.from(this._internalState.entries()) - .reverse() // Use reverse same as original tracestate parse chain - .slice(0, MAX_TRACE_STATE_ITEMS)); - } - }; - TraceStateImpl.prototype._keys = function () { - return Array.from(this._internalState.keys()).reverse(); - }; - TraceStateImpl.prototype._clone = function () { - var traceState = new TraceStateImpl(); - traceState._internalState = new Map(this._internalState); - return traceState; - }; - return TraceStateImpl; -}()); -exports.TraceStateImpl = TraceStateImpl; -//# sourceMappingURL=tracestate-impl.js.map - -/***/ }), +/* 756 */, /* 757 */, /* 758 */, /* 759 */, @@ -49634,7 +49423,7 @@ module.exports = v4; Object.defineProperty(exports, "__esModule", { value: true }); exports.VERSION = void 0; // this is autogenerated file, see scripts/version-update.js -exports.VERSION = '1.1.0'; +exports.VERSION = '1.0.4'; //# sourceMappingURL=version.js.map /***/ }), @@ -51857,30 +51646,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); //# sourceMappingURL=attributes.js.map /***/ }), -/* 907 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=Attributes.js.map - -/***/ }), +/* 907 */, /* 908 */, /* 909 */, /* 910 */ diff --git a/dist/save/index.js b/dist/save/index.js index a6ae873..3b28379 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -1405,36 +1405,7 @@ exports.default = _default; /* 39 */, /* 40 */, /* 41 */, -/* 42 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createTraceState = void 0; -var tracestate_impl_1 = __webpack_require__(756); -function createTraceState(rawTraceState) { - return new tracestate_impl_1.TraceStateImpl(rawTraceState); -} -exports.createTraceState = createTraceState; -//# sourceMappingURL=utils.js.map - -/***/ }), +/* 42 */, /* 43 */, /* 44 */, /* 45 */, @@ -3221,10 +3192,7 @@ const options_1 = __webpack_require__(538); const requestUtils_1 = __webpack_require__(899); const versionSalt = '1.0'; function getCacheApiUrl(resource) { - // Ideally we just use ACTIONS_CACHE_URL - const baseUrl = (process.env['ACTIONS_CACHE_URL'] || - process.env['ACTIONS_RUNTIME_URL'] || - '').replace('pipelines', 'artifactcache'); + const baseUrl = process.env['ACTIONS_CACHE_URL'] || ''; if (!baseUrl) { throw new Error('Cache Service Url not found, unable to restore cache.'); } @@ -3313,6 +3281,7 @@ function reserveCache(key, paths, options) { const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); + console.log(response); return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; }); } @@ -4470,7 +4439,7 @@ var NoopTracer_1 = __webpack_require__(151); var NoopTracerProvider = /** @class */ (function () { function NoopTracerProvider() { } - NoopTracerProvider.prototype.getTracer = function (_name, _version, _options) { + NoopTracerProvider.prototype.getTracer = function (_name, _version) { return new NoopTracer_1.NoopTracer(); }; return NoopTracerProvider; @@ -5519,7 +5488,8 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { // // If the file exceeds the buffer maximum length (~1 GB on 32-bit systems and ~2 GB // on 64-bit systems), split the download into multiple segments - const maxSegmentSize = buffer.constants.MAX_LENGTH; + // ~2 GB = 2147483647, beyond this, we start getting out of range error. So, capping it accordingly. + const maxSegmentSize = Math.min(2147483647, buffer.constants.MAX_LENGTH); const downloadProgress = new DownloadProgress(contentLength); const fd = fs.openSync(archivePath, 'w'); try { @@ -36293,9 +36263,9 @@ var ProxyTracerProvider = /** @class */ (function () { /** * Get a {@link ProxyTracer} */ - ProxyTracerProvider.prototype.getTracer = function (name, version, options) { + ProxyTracerProvider.prototype.getTracer = function (name, version) { var _a; - return ((_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name, version, options)); + return ((_a = this.getDelegateTracer(name, version)) !== null && _a !== void 0 ? _a : new ProxyTracer_1.ProxyTracer(this, name, version)); }; ProxyTracerProvider.prototype.getDelegate = function () { var _a; @@ -36307,9 +36277,9 @@ var ProxyTracerProvider = /** @class */ (function () { ProxyTracerProvider.prototype.setDelegate = function (delegate) { this._delegate = delegate; }; - ProxyTracerProvider.prototype.getDelegateTracer = function (name, version, options) { + ProxyTracerProvider.prototype.getDelegateTracer = function (name, version) { var _a; - return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options); + return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version); }; return ProxyTracerProvider; }()); @@ -36348,11 +36318,10 @@ var NOOP_TRACER = new NoopTracer_1.NoopTracer(); * Proxy tracer provided by the proxy tracer provider */ var ProxyTracer = /** @class */ (function () { - function ProxyTracer(_provider, name, version, options) { + function ProxyTracer(_provider, name, version) { this._provider = _provider; this.name = name; this.version = version; - this.options = options; } ProxyTracer.prototype.startSpan = function (name, options, context) { return this._getTracer().startSpan(name, options, context); @@ -36369,7 +36338,7 @@ var ProxyTracer = /** @class */ (function () { if (this._delegate) { return this._delegate; } - var tracer = this._provider.getDelegateTracer(this.name, this.version, this.options); + var tracer = this._provider.getDelegateTracer(this.name, this.version); if (!tracer) { return NOOP_TRACER; } @@ -37369,13 +37338,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.diag = exports.propagation = exports.trace = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.createTraceState = exports.baggageEntryMetadataFromString = void 0; +exports.diag = exports.propagation = exports.trace = exports.context = exports.INVALID_SPAN_CONTEXT = exports.INVALID_TRACEID = exports.INVALID_SPANID = exports.isValidSpanId = exports.isValidTraceId = exports.isSpanContextValid = exports.baggageEntryMetadataFromString = void 0; __exportStar(__webpack_require__(880), exports); var utils_1 = __webpack_require__(112); Object.defineProperty(exports, "baggageEntryMetadataFromString", { enumerable: true, get: function () { return utils_1.baggageEntryMetadataFromString; } }); __exportStar(__webpack_require__(452), exports); __exportStar(__webpack_require__(158), exports); -__exportStar(__webpack_require__(907), exports); __exportStar(__webpack_require__(893), exports); __exportStar(__webpack_require__(881), exports); __exportStar(__webpack_require__(906), exports); @@ -37391,11 +37359,8 @@ __exportStar(__webpack_require__(220), exports); __exportStar(__webpack_require__(932), exports); __exportStar(__webpack_require__(975), exports); __exportStar(__webpack_require__(207), exports); -var utils_2 = __webpack_require__(42); -Object.defineProperty(exports, "createTraceState", { enumerable: true, get: function () { return utils_2.createTraceState; } }); __exportStar(__webpack_require__(694), exports); __exportStar(__webpack_require__(695), exports); -__exportStar(__webpack_require__(743), exports); var spancontext_utils_1 = __webpack_require__(629); Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } }); Object.defineProperty(exports, "isValidTraceId", { enumerable: true, get: function () { return spancontext_utils_1.isValidTraceId; } }); @@ -37463,8 +37428,7 @@ exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports const core = __importStar(__webpack_require__(470)); const constants_1 = __webpack_require__(196); function isGhes() { - const ghUrl = new URL(process.env["GITHUB_SERVER_URL"] || "https://github.com"); - return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; + return false; } exports.isGhes = isGhes; function isExactKeyMatch(key, cacheKey) { @@ -42117,58 +42081,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); /* 587 */, /* 588 */, /* 589 */, -/* 590 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.validateValue = exports.validateKey = void 0; -var VALID_KEY_CHAR_RANGE = '[_0-9a-z-*/]'; -var VALID_KEY = "[a-z]" + VALID_KEY_CHAR_RANGE + "{0,255}"; -var VALID_VENDOR_KEY = "[a-z0-9]" + VALID_KEY_CHAR_RANGE + "{0,240}@[a-z]" + VALID_KEY_CHAR_RANGE + "{0,13}"; -var VALID_KEY_REGEX = new RegExp("^(?:" + VALID_KEY + "|" + VALID_VENDOR_KEY + ")$"); -var VALID_VALUE_BASE_REGEX = /^[ -~]{0,255}[!-~]$/; -var INVALID_VALUE_COMMA_EQUAL_REGEX = /,|=/; -/** - * Key is opaque string up to 256 characters printable. It MUST begin with a - * lowercase letter, and can only contain lowercase letters a-z, digits 0-9, - * underscores _, dashes -, asterisks *, and forward slashes /. - * For multi-tenant vendor scenarios, an at sign (@) can be used to prefix the - * vendor name. Vendors SHOULD set the tenant ID at the beginning of the key. - * see https://www.w3.org/TR/trace-context/#key - */ -function validateKey(key) { - return VALID_KEY_REGEX.test(key); -} -exports.validateKey = validateKey; -/** - * Value is opaque string up to 256 characters printable ASCII RFC0020 - * characters (i.e., the range 0x20 to 0x7E) except comma , and =. - */ -function validateValue(value) { - return (VALID_VALUE_BASE_REGEX.test(value) && - !INVALID_VALUE_COMMA_EQUAL_REGEX.test(value)); -} -exports.validateValue = validateValue; -//# sourceMappingURL=tracestate-validators.js.map - -/***/ }), +/* 590 */, /* 591 */, /* 592 */, /* 593 */, @@ -46533,6 +46446,15 @@ function checkKey(key) { throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`); } } +/** + * isFeatureAvailable to check the presence of Actions cache service + * + * @returns boolean return true if Actions cache service feature is available, otherwise false + */ +function isFeatureAvailable() { + return !!process.env['ACTIONS_CACHE_URL']; +} +exports.isFeatureAvailable = isFeatureAvailable; /** * Restores cache from keys * @@ -47314,30 +47236,7 @@ exports.OidcClient = OidcClient; //# sourceMappingURL=oidc-utils.js.map /***/ }), -/* 743 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=tracer_options.js.map - -/***/ }), +/* 743 */, /* 744 */, /* 745 */, /* 746 */, @@ -47434,117 +47333,7 @@ function async(callback) /* 753 */, /* 754 */, /* 755 */, -/* 756 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TraceStateImpl = void 0; -var tracestate_validators_1 = __webpack_require__(590); -var MAX_TRACE_STATE_ITEMS = 32; -var MAX_TRACE_STATE_LEN = 512; -var LIST_MEMBERS_SEPARATOR = ','; -var LIST_MEMBER_KEY_VALUE_SPLITTER = '='; -/** - * TraceState must be a class and not a simple object type because of the spec - * requirement (https://www.w3.org/TR/trace-context/#tracestate-field). - * - * Here is the list of allowed mutations: - * - New key-value pair should be added into the beginning of the list - * - The value of any key can be updated. Modified keys MUST be moved to the - * beginning of the list. - */ -var TraceStateImpl = /** @class */ (function () { - function TraceStateImpl(rawTraceState) { - this._internalState = new Map(); - if (rawTraceState) - this._parse(rawTraceState); - } - TraceStateImpl.prototype.set = function (key, value) { - // TODO: Benchmark the different approaches(map vs list) and - // use the faster one. - var traceState = this._clone(); - if (traceState._internalState.has(key)) { - traceState._internalState.delete(key); - } - traceState._internalState.set(key, value); - return traceState; - }; - TraceStateImpl.prototype.unset = function (key) { - var traceState = this._clone(); - traceState._internalState.delete(key); - return traceState; - }; - TraceStateImpl.prototype.get = function (key) { - return this._internalState.get(key); - }; - TraceStateImpl.prototype.serialize = function () { - var _this = this; - return this._keys() - .reduce(function (agg, key) { - agg.push(key + LIST_MEMBER_KEY_VALUE_SPLITTER + _this.get(key)); - return agg; - }, []) - .join(LIST_MEMBERS_SEPARATOR); - }; - TraceStateImpl.prototype._parse = function (rawTraceState) { - if (rawTraceState.length > MAX_TRACE_STATE_LEN) - return; - this._internalState = rawTraceState - .split(LIST_MEMBERS_SEPARATOR) - .reverse() // Store in reverse so new keys (.set(...)) will be placed at the beginning - .reduce(function (agg, part) { - var listMember = part.trim(); // Optional Whitespace (OWS) handling - var i = listMember.indexOf(LIST_MEMBER_KEY_VALUE_SPLITTER); - if (i !== -1) { - var key = listMember.slice(0, i); - var value = listMember.slice(i + 1, part.length); - if (tracestate_validators_1.validateKey(key) && tracestate_validators_1.validateValue(value)) { - agg.set(key, value); - } - else { - // TODO: Consider to add warning log - } - } - return agg; - }, new Map()); - // Because of the reverse() requirement, trunc must be done after map is created - if (this._internalState.size > MAX_TRACE_STATE_ITEMS) { - this._internalState = new Map(Array.from(this._internalState.entries()) - .reverse() // Use reverse same as original tracestate parse chain - .slice(0, MAX_TRACE_STATE_ITEMS)); - } - }; - TraceStateImpl.prototype._keys = function () { - return Array.from(this._internalState.keys()).reverse(); - }; - TraceStateImpl.prototype._clone = function () { - var traceState = new TraceStateImpl(); - traceState._internalState = new Map(this._internalState); - return traceState; - }; - return TraceStateImpl; -}()); -exports.TraceStateImpl = TraceStateImpl; -//# sourceMappingURL=tracestate-impl.js.map - -/***/ }), +/* 756 */, /* 757 */, /* 758 */, /* 759 */, @@ -49637,7 +49426,7 @@ module.exports = v4; Object.defineProperty(exports, "__esModule", { value: true }); exports.VERSION = void 0; // this is autogenerated file, see scripts/version-update.js -exports.VERSION = '1.1.0'; +exports.VERSION = '1.0.4'; //# sourceMappingURL=version.js.map /***/ }), @@ -51860,30 +51649,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); //# sourceMappingURL=attributes.js.map /***/ }), -/* 907 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=Attributes.js.map - -/***/ }), +/* 907 */, /* 908 */, /* 909 */, /* 910 */ diff --git a/package-lock.json b/package-lock.json index 21cc7f3..4ea79a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.10.tgz", - "integrity": "sha512-8l9A54RXsPHbHs4Tu0DGqTyE5cguvq3xO9H0ohbLa5zbL2Z4dh9lxnjQn2xojsPQr4WnEVgbaVZpc1tlhehQGw==", + "version": "file:cache.tgz", + "integrity": "sha512-PAh3zoa2D96+iUt+oqzDLKkhZZm1oho2MNdutJ5okg5JDcuJXy8uucKfEP718GhR6YQ1grF1G0UFORDGHb0PhA==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", @@ -1186,9 +1185,9 @@ } }, "@opentelemetry/api": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.1.0.tgz", - "integrity": "sha512-hf+3bwuBwtXsugA2ULBc95qxrOqP2pOekLz34BJhcAKawt94vfeNyUKpYc0lZQ/3sCP6LqRa7UAdHA7i5UODzQ==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz", + "integrity": "sha512-BuJuXRSJNQ3QoKA6GWWDyuLpOUck+9hAXNMCnrloc1aWVoy6Xq6t9PUV08aBZ4Lutqq2LEHM486bpZqoViScog==" }, "@sinonjs/commons": { "version": "1.8.3", diff --git a/package.json b/package.json index 39faf99..0f8b22c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^1.0.10", + "@actions/cache": "file:cache.tgz", "@actions/core": "^1.2.6", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index a4d712d..83407a5 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -3,10 +3,7 @@ import * as core from "@actions/core"; import { Outputs, RefKey, State } from "../constants"; export function isGhes(): boolean { - const ghUrl = new URL( - process.env["GITHUB_SERVER_URL"] || "https://github.com" - ); - return ghUrl.hostname.toUpperCase() !== "GITHUB.COM"; + return false; } export function isExactKeyMatch(key: string, cacheKey?: string): boolean { From 2ce8d02f04c7f0a147b37e02b104cbfcf577cbfe Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 30 Mar 2022 16:02:49 +0530 Subject: [PATCH 2/6] console res --- dist/restore/index.js | 36 +++++++++++++++++++++--------------- dist/save/index.js | 36 +++++++++++++++++++++--------------- package-lock.json | 2 +- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 9313aff..c4c299f 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -3270,19 +3270,18 @@ function downloadCache(archiveLocation, archivePath, options) { exports.downloadCache = downloadCache; // Reserve Cache function reserveCache(key, paths, options) { - var _a, _b; return __awaiter(this, void 0, void 0, function* () { const httpClient = createHttpClient(); const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); const reserveCacheRequest = { key, - version + version, + cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); - console.log(response); - return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; + return response; }); } exports.reserveCache = reserveCache; @@ -46427,18 +46426,12 @@ exports.restoreCache = restoreCache; * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails */ function saveCache(paths, key, options) { + var _a, _b; return __awaiter(this, void 0, void 0, function* () { checkPaths(paths); checkKey(key); const compressionMethod = yield utils.getCompressionMethod(); - core.debug('Reserving Cache'); - const cacheId = yield cacheHttpClient.reserveCache(key, paths, { - compressionMethod - }); - if (cacheId === -1) { - throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); - } - core.debug(`Cache ID: ${cacheId}`); + let cacheId = null; const cachePaths = yield utils.resolvePaths(paths); core.debug('Cache Paths:'); core.debug(`${JSON.stringify(cachePaths)}`); @@ -46450,12 +46443,25 @@ function saveCache(paths, key, options) { if (core.isDebug()) { yield tar_1.listTar(archivePath, compressionMethod); } - const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); core.debug(`File Size: ${archiveFileSize}`); - if (archiveFileSize > fileSizeLimit) { - throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); + const cacheSize = archiveFileSize; + core.debug('Reserving Cache'); + let reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { + compressionMethod, + cacheSize + }); + console.log(reserveCacheResponse); + if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) { + throw new ReserveCacheError(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`); } + if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { + cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId; + } + else { + throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); + } + core.debug(`Cache ID: ${cacheId}`); core.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, options); } diff --git a/dist/save/index.js b/dist/save/index.js index 3b28379..d4efd24 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -3270,19 +3270,18 @@ function downloadCache(archiveLocation, archivePath, options) { exports.downloadCache = downloadCache; // Reserve Cache function reserveCache(key, paths, options) { - var _a, _b; return __awaiter(this, void 0, void 0, function* () { const httpClient = createHttpClient(); const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); const reserveCacheRequest = { key, - version + version, + cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); - console.log(response); - return (_b = (_a = response === null || response === void 0 ? void 0 : response.result) === null || _a === void 0 ? void 0 : _a.cacheId) !== null && _b !== void 0 ? _b : -1; + return response; }); } exports.reserveCache = reserveCache; @@ -46521,18 +46520,12 @@ exports.restoreCache = restoreCache; * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails */ function saveCache(paths, key, options) { + var _a, _b; return __awaiter(this, void 0, void 0, function* () { checkPaths(paths); checkKey(key); const compressionMethod = yield utils.getCompressionMethod(); - core.debug('Reserving Cache'); - const cacheId = yield cacheHttpClient.reserveCache(key, paths, { - compressionMethod - }); - if (cacheId === -1) { - throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); - } - core.debug(`Cache ID: ${cacheId}`); + let cacheId = null; const cachePaths = yield utils.resolvePaths(paths); core.debug('Cache Paths:'); core.debug(`${JSON.stringify(cachePaths)}`); @@ -46544,12 +46537,25 @@ function saveCache(paths, key, options) { if (core.isDebug()) { yield tar_1.listTar(archivePath, compressionMethod); } - const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath); core.debug(`File Size: ${archiveFileSize}`); - if (archiveFileSize > fileSizeLimit) { - throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); + const cacheSize = archiveFileSize; + core.debug('Reserving Cache'); + let reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { + compressionMethod, + cacheSize + }); + console.log(reserveCacheResponse); + if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) { + throw new ReserveCacheError(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`); } + if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { + cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId; + } + else { + throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); + } + core.debug(`Cache ID: ${cacheId}`); core.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, options); } diff --git a/package-lock.json b/package-lock.json index 4ea79a1..ee41213 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "dependencies": { "@actions/cache": { "version": "file:cache.tgz", - "integrity": "sha512-PAh3zoa2D96+iUt+oqzDLKkhZZm1oho2MNdutJ5okg5JDcuJXy8uucKfEP718GhR6YQ1grF1G0UFORDGHb0PhA==", + "integrity": "sha512-3KKmMXpGLI/dU7+aO6V+CmWsZ5B8aP4Y+SIo14TtvxYHLxZejIinESpTxw2U88noW08uTEXZOyWpLhhQswn15g==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", From 1239bf69144dfa298837f606cbad87405add0680 Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 30 Mar 2022 18:23:49 +0530 Subject: [PATCH 3/6] console res --- dist/restore/index.js | 1 + dist/save/index.js | 1 + package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index c4c299f..a444af0 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -51558,6 +51558,7 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { + console.log(error); return { statusCode: error.statusCode, result: null, diff --git a/dist/save/index.js b/dist/save/index.js index d4efd24..9054305 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -51561,6 +51561,7 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { + console.log(error); return { statusCode: error.statusCode, result: null, diff --git a/package-lock.json b/package-lock.json index ee41213..693f7f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,8 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "file:cache.tgz", - "integrity": "sha512-3KKmMXpGLI/dU7+aO6V+CmWsZ5B8aP4Y+SIo14TtvxYHLxZejIinESpTxw2U88noW08uTEXZOyWpLhhQswn15g==", + "version": "file:actions-cache-2.3.0.tgz", + "integrity": "sha512-6K816KLQeVesY/5MHI4pM1viBXhGDqcVom6sY3KX0nLQgKbvyp7wR8h9Y07rQDEKr7Gd6GfQFIy3fQZAf3hr5g==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", diff --git a/package.json b/package.json index 0f8b22c..6da9845 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "file:cache.tgz", + "@actions/cache": "file:actions-cache-2.3.0.tgz", "@actions/core": "^1.2.6", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" From a54eb92c7c41a58ad25a9faedc1ad5ffad42f810 Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 30 Mar 2022 18:29:58 +0530 Subject: [PATCH 4/6] console res --- dist/restore/index.js | 3 ++- dist/save/index.js | 3 ++- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index a444af0..4cecd81 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -51558,7 +51558,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { - console.log(error); + console.log("\n\nRESULT\n\n"); + console.log(error.result); return { statusCode: error.statusCode, result: null, diff --git a/dist/save/index.js b/dist/save/index.js index 9054305..a1b922a 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -51561,7 +51561,8 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { - console.log(error); + console.log("\n\nRESULT\n\n"); + console.log(error.result); return { statusCode: error.statusCode, result: null, diff --git a/package-lock.json b/package-lock.json index 693f7f4..e7f6b5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,8 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "file:actions-cache-2.3.0.tgz", - "integrity": "sha512-6K816KLQeVesY/5MHI4pM1viBXhGDqcVom6sY3KX0nLQgKbvyp7wR8h9Y07rQDEKr7Gd6GfQFIy3fQZAf3hr5g==", + "version": "file:actions-cache-2.4.0.tgz", + "integrity": "sha512-AfWcypsHwZGDjm6J4nBVvhuggVpz9bkkn2qPCycowbInKTwMVZOTZFQS1CaxOjcoOdzbpzrUk0uCu426at5mbg==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", diff --git a/package.json b/package.json index 6da9845..465a1f7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "file:actions-cache-2.3.0.tgz", + "@actions/cache": "file:actions-cache-2.4.0.tgz", "@actions/core": "^1.2.6", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" From fa608b229426ea05c6ac281d41cbda0d0ba779af Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 31 Mar 2022 13:04:01 +0530 Subject: [PATCH 5/6] console res --- dist/restore/index.js | 33 ++++++++++++++++++--------------- dist/save/index.js | 33 ++++++++++++++++++--------------- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 4cecd81..7221a2f 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -3278,9 +3278,11 @@ function reserveCache(key, paths, options) { version, cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; - const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { - return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); + const response = yield requestUtils_1.retryHttpClientResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { + return httpClient.post(getCacheApiUrl('caches'), JSON.stringify(reserveCacheRequest)); })); + console.log("\n\nResponse\n\n"); + console.log(response); return response; }); } @@ -46426,7 +46428,6 @@ exports.restoreCache = restoreCache; * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails */ function saveCache(paths, key, options) { - var _a, _b; return __awaiter(this, void 0, void 0, function* () { checkPaths(paths); checkKey(key); @@ -46451,16 +46452,20 @@ function saveCache(paths, key, options) { compressionMethod, cacheSize }); - console.log(reserveCacheResponse); - if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) { - throw new ReserveCacheError(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`); - } - if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { - cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId; - } - else { - throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); - } + // if(reserveCacheResponse?.statusCode === 400 && reserveCacheResponse?.result?.typeKey === "InvalidReserveCacheRequestException"){ + // throw new ReserveCacheError( + // reserveCacheResponse?.result?.message ?? + // `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.` + // ) + // } + // if(reserveCacheResponse?.result?.cacheId){ + // cacheId = reserveCacheResponse?.result?.cacheId + // }else{ + // throw new ReserveCacheError( + // `Unable to reserve cache with key ${key}, another job may be creating this cache.` + // ) + // } + throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); core.debug(`Cache ID: ${cacheId}`); core.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, options); @@ -51558,8 +51563,6 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { - console.log("\n\nRESULT\n\n"); - console.log(error.result); return { statusCode: error.statusCode, result: null, diff --git a/dist/save/index.js b/dist/save/index.js index a1b922a..4e3d8f1 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -3278,9 +3278,11 @@ function reserveCache(key, paths, options) { version, cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; - const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { - return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); + const response = yield requestUtils_1.retryHttpClientResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { + return httpClient.post(getCacheApiUrl('caches'), JSON.stringify(reserveCacheRequest)); })); + console.log("\n\nResponse\n\n"); + console.log(response); return response; }); } @@ -46520,7 +46522,6 @@ exports.restoreCache = restoreCache; * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails */ function saveCache(paths, key, options) { - var _a, _b; return __awaiter(this, void 0, void 0, function* () { checkPaths(paths); checkKey(key); @@ -46545,16 +46546,20 @@ function saveCache(paths, key, options) { compressionMethod, cacheSize }); - console.log(reserveCacheResponse); - if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) { - throw new ReserveCacheError(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`); - } - if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { - cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId; - } - else { - throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); - } + // if(reserveCacheResponse?.statusCode === 400 && reserveCacheResponse?.result?.typeKey === "InvalidReserveCacheRequestException"){ + // throw new ReserveCacheError( + // reserveCacheResponse?.result?.message ?? + // `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.` + // ) + // } + // if(reserveCacheResponse?.result?.cacheId){ + // cacheId = reserveCacheResponse?.result?.cacheId + // }else{ + // throw new ReserveCacheError( + // `Unable to reserve cache with key ${key}, another job may be creating this cache.` + // ) + // } + throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`); core.debug(`Cache ID: ${cacheId}`); core.debug(`Saving Cache (ID: ${cacheId})`); yield cacheHttpClient.saveCache(cacheId, archivePath, options); @@ -51561,8 +51566,6 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry // an ITypedResponse so it can be processed by the retry logic. (error) => { if (error instanceof http_client_1.HttpClientError) { - console.log("\n\nRESULT\n\n"); - console.log(error.result); return { statusCode: error.statusCode, result: null, diff --git a/package-lock.json b/package-lock.json index e7f6b5d..82ee0d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,8 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "file:actions-cache-2.4.0.tgz", - "integrity": "sha512-AfWcypsHwZGDjm6J4nBVvhuggVpz9bkkn2qPCycowbInKTwMVZOTZFQS1CaxOjcoOdzbpzrUk0uCu426at5mbg==", + "version": "file:actions-cache-2.5.0.tgz", + "integrity": "sha512-Op00dHgPDvY4EJdde8NIAK4JZjzz3uao8ECVsgN1/KAp0SKtEXKPntS+hrNhTLMnZqBqI74+WZlRWqbpDlus/w==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", diff --git a/package.json b/package.json index 465a1f7..0592fd7 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "file:actions-cache-2.4.0.tgz", + "@actions/cache": "file:actions-cache-2.5.0.tgz", "@actions/core": "^1.2.6", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" From 8546a7057e00ee8c67c891b84ff304a02938442b Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 31 Mar 2022 14:54:56 +0530 Subject: [PATCH 6/6] console res --- dist/restore/index.js | 9 +++++---- dist/save/index.js | 9 +++++---- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 7221a2f..a4b967d 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -3278,10 +3278,9 @@ function reserveCache(key, paths, options) { version, cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; - const response = yield requestUtils_1.retryHttpClientResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { - return httpClient.post(getCacheApiUrl('caches'), JSON.stringify(reserveCacheRequest)); + const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { + return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); - console.log("\n\nResponse\n\n"); console.log(response); return response; }); @@ -51566,7 +51565,9 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry return { statusCode: error.statusCode, result: null, - headers: {} + headers: {}, + message: error.message, + typeKey: error.result }; } else { diff --git a/dist/save/index.js b/dist/save/index.js index 4e3d8f1..fe6ba16 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -3278,10 +3278,9 @@ function reserveCache(key, paths, options) { version, cacheSize: options === null || options === void 0 ? void 0 : options.cacheSize }; - const response = yield requestUtils_1.retryHttpClientResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { - return httpClient.post(getCacheApiUrl('caches'), JSON.stringify(reserveCacheRequest)); + const response = yield requestUtils_1.retryTypedResponse('reserveCache', () => __awaiter(this, void 0, void 0, function* () { + return httpClient.postJson(getCacheApiUrl('caches'), reserveCacheRequest); })); - console.log("\n\nResponse\n\n"); console.log(response); return response; }); @@ -51569,7 +51568,9 @@ function retryTypedResponse(name, method, maxAttempts = constants_1.DefaultRetry return { statusCode: error.statusCode, result: null, - headers: {} + headers: {}, + message: error.message, + typeKey: error.result }; } else { diff --git a/package-lock.json b/package-lock.json index 82ee0d8..7a8d7ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,8 +5,8 @@ "requires": true, "dependencies": { "@actions/cache": { - "version": "file:actions-cache-2.5.0.tgz", - "integrity": "sha512-Op00dHgPDvY4EJdde8NIAK4JZjzz3uao8ECVsgN1/KAp0SKtEXKPntS+hrNhTLMnZqBqI74+WZlRWqbpDlus/w==", + "version": "file:actions-cache-2.6.0.tgz", + "integrity": "sha512-B4nmafK6ta7svnwFPDTWK+I5M9Yx5ZQeVau0u4viwnmHrFjLg8zYOL1eNEKOGM/7GXkRAN2jiyaXu8jW419BYw==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", diff --git a/package.json b/package.json index 0592fd7..3c6c8b4 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "file:actions-cache-2.5.0.tgz", + "@actions/cache": "file:actions-cache-2.6.0.tgz", "@actions/core": "^1.2.6", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2"