From dc1a9f27915005c4867178213f98cc27415de97a Mon Sep 17 00:00:00 2001 From: Shubham Tiwari <64764738+tiwarishub@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:39:57 +0530 Subject: [PATCH] Caching on GHES (#308) * initial changes * review comments * updated with correct message * linting * update version * updated version --- .licenses/npm/@actions/cache.dep.yml | 2 +- __tests__/util.test.ts | 42 +- dist/cleanup/index.js | 136 +- dist/setup/index.js | 3234 +++++++++++++------------- package-lock.json | 26 +- package.json | 4 +- src/setup-java.ts | 4 +- src/util.ts | 22 + 8 files changed, 1792 insertions(+), 1678 deletions(-) diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml index c2d23e2e3..35b0a4bf1 100644 --- a/.licenses/npm/@actions/cache.dep.yml +++ b/.licenses/npm/@actions/cache.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/cache" -version: 1.0.8 +version: 2.0.0 type: npm summary: Actions cache lib homepage: https://github.com/actions/toolkit/tree/main/packages/cache diff --git a/__tests__/util.test.ts b/__tests__/util.test.ts index 6509917e2..9815c950b 100644 --- a/__tests__/util.test.ts +++ b/__tests__/util.test.ts @@ -1,4 +1,9 @@ -import { isVersionSatisfies } from '../src/util'; +import * as cache from '@actions/cache'; +import * as core from '@actions/core'; +import { isVersionSatisfies, isCacheFeatureAvailable } from '../src/util'; + +jest.mock('@actions/cache'); +jest.mock('@actions/core'); describe('isVersionSatisfies', () => { it.each([ @@ -20,3 +25,38 @@ describe('isVersionSatisfies', () => { expect(actual).toBe(expected); }); }); + +describe('isCacheFeatureAvailable', () => { + it('isCacheFeatureAvailable disabled on GHES', () => { + jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false); + try { + process.env['GITHUB_SERVER_URL'] = 'http://example.com'; + isCacheFeatureAvailable(); + } catch (error) { + expect(error).toHaveProperty( + 'message', + 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' + ); + } finally { + delete process.env['GITHUB_SERVER_URL']; + } + }); + + it('isCacheFeatureAvailable disabled on dotcom', () => { + jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false); + const infoMock = jest.spyOn(core, 'warning'); + const message = 'The runner was not able to contact the cache service. Caching will be skipped'; + try { + process.env['GITHUB_SERVER_URL'] = 'http://github.com'; + expect(isCacheFeatureAvailable()).toBe(false); + expect(infoMock).toHaveBeenCalledWith(message); + } finally { + delete process.env['GITHUB_SERVER_URL']; + } + }); + + it('isCacheFeatureAvailable is enabled', () => { + jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => true); + expect(isCacheFeatureAvailable()).toBe(true); + }); +}); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index a9052b609..545789607 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -3730,10 +3730,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.'); } @@ -5932,7 +5929,35 @@ module.exports = { /* 193 */, /* 194 */, /* 195 */, -/* 196 */, +/* 196 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; +exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; +exports.INPUT_JAVA_VERSION = 'java-version'; +exports.INPUT_ARCHITECTURE = 'architecture'; +exports.INPUT_JAVA_PACKAGE = 'java-package'; +exports.INPUT_DISTRIBUTION = 'distribution'; +exports.INPUT_JDK_FILE = 'jdkFile'; +exports.INPUT_CHECK_LATEST = 'check-latest'; +exports.INPUT_SERVER_ID = 'server-id'; +exports.INPUT_SERVER_USERNAME = 'server-username'; +exports.INPUT_SERVER_PASSWORD = 'server-password'; +exports.INPUT_SETTINGS_PATH = 'settings-path'; +exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings'; +exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key'; +exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase'; +exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined; +exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; +exports.INPUT_CACHE = 'cache'; +exports.INPUT_JOB_STATUS = 'job-status'; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; + + +/***/ }), /* 197 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -6092,7 +6117,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const core = __importStar(__webpack_require__(470)); const gpg = __importStar(__webpack_require__(884)); -const constants = __importStar(__webpack_require__(694)); +const constants = __importStar(__webpack_require__(196)); const util_1 = __webpack_require__(322); const cache_1 = __webpack_require__(913); function removePrivateKeyFromKeychain() { @@ -6889,7 +6914,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 { @@ -9110,14 +9136,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__webpack_require__(87)); const path_1 = __importDefault(__webpack_require__(622)); const fs = __importStar(__webpack_require__(747)); const semver = __importStar(__webpack_require__(876)); +const cache = __importStar(__webpack_require__(692)); const core = __importStar(__webpack_require__(470)); const tc = __importStar(__webpack_require__(533)); -const constants_1 = __webpack_require__(694); +const constants_1 = __webpack_require__(196); function getTempDir() { let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); return tempDirectory; @@ -9187,6 +9214,24 @@ function isJobStatusSuccess() { return jobStatus === 'success'; } exports.isJobStatusSuccess = isJobStatusSuccess; +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -41953,7 +41998,7 @@ __exportStar(__webpack_require__(220), exports); __exportStar(__webpack_require__(932), exports); __exportStar(__webpack_require__(975), exports); __exportStar(__webpack_require__(207), exports); -__exportStar(__webpack_require__(773), exports); +__exportStar(__webpack_require__(694), exports); __exportStar(__webpack_require__(695), exports); var spancontext_utils_1 = __webpack_require__(629); Object.defineProperty(exports, "isSpanContextValid", { enumerable: true, get: function () { return spancontext_utils_1.isSpanContextValid; } }); @@ -53506,6 +53551,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 * @@ -53626,28 +53680,23 @@ exports.saveCache = saveCache; "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.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; -exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; -exports.INPUT_JAVA_VERSION = 'java-version'; -exports.INPUT_ARCHITECTURE = 'architecture'; -exports.INPUT_JAVA_PACKAGE = 'java-package'; -exports.INPUT_DISTRIBUTION = 'distribution'; -exports.INPUT_JDK_FILE = 'jdkFile'; -exports.INPUT_CHECK_LATEST = 'check-latest'; -exports.INPUT_SERVER_ID = 'server-id'; -exports.INPUT_SERVER_USERNAME = 'server-username'; -exports.INPUT_SERVER_PASSWORD = 'server-password'; -exports.INPUT_SETTINGS_PATH = 'settings-path'; -exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings'; -exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key'; -exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase'; -exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined; -exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; -exports.INPUT_CACHE = 'cache'; -exports.INPUT_JOB_STATUS = 'job-status'; -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; - +//# sourceMappingURL=tracer_provider.js.map /***/ }), /* 695 */ @@ -55714,30 +55763,7 @@ module.exports = function(dst, src) { /* 770 */, /* 771 */, /* 772 */, -/* 773 */ -/***/ (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_provider.js.map - -/***/ }), +/* 773 */, /* 774 */, /* 775 */, /* 776 */, diff --git a/dist/setup/index.js b/dist/setup/index.js index b1445c710..b37a8116d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -3773,20 +3773,7 @@ exports.tokenList_serializeSteps = tokenList_serializeSteps; /* 55 */, /* 56 */, /* 57 */, -/* 58 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -// Unique ID creation requires a high quality random # generator. In node.js -// this is pretty straight-forward - we use the crypto API. - -var crypto = __webpack_require__(373); - -module.exports = function nodeRNG() { - return crypto.randomBytes(16); -}; - - -/***/ }), +/* 58 */, /* 59 */ /***/ (function(__unusedmodule, exports) { @@ -4711,7 +4698,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.JavaBase = void 0; -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const core = __importStar(__webpack_require__(470)); const fs = __importStar(__webpack_require__(747)); const semver_1 = __importDefault(__webpack_require__(876)); @@ -9539,10 +9526,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.'); } @@ -10539,10 +10523,333 @@ exports.pop = pop; /* 137 */, /* 138 */, /* 139 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Unique ID creation requires a high quality random # generator. In node.js +// this is pretty straight-forward - we use the crypto API. + +var crypto = __webpack_require__(373); + +module.exports = function nodeRNG() { + return crypto.randomBytes(16); +}; + + +/***/ }), +/* 140 */, +/* 141 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + + +var net = __webpack_require__(631); +var tls = __webpack_require__(818); +var http = __webpack_require__(605); +var https = __webpack_require__(34); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); + + +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} + + +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); + +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } + + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); + + function onFree() { + self.emit('free', socket, options); + } + + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); + + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} + + +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} + + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test + + +/***/ }), +/* 142 */, +/* 143 */ +/***/ (function(module) { + +// parse out just the options we care about so we always get a consistent +// obj with keys in a consistent order. +const opts = ['includePrerelease', 'loose', 'rtl'] +const parseOptions = options => + !options ? {} + : typeof options !== 'object' ? { loose: true } + : opts.filter(k => options[k]).reduce((options, k) => { + options[k] = true + return options + }, {}) +module.exports = parseOptions + + +/***/ }), +/* 144 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -10552,1400 +10859,479 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.LocalDistribution = void 0; +const tc = __importStar(__webpack_require__(186)); const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); -const fs = __importStar(__webpack_require__(747)); -const mm = __importStar(__webpack_require__(31)); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -const httpm = __importStar(__webpack_require__(539)); -const semver = __importStar(__webpack_require__(550)); -const stream = __importStar(__webpack_require__(794)); -const util = __importStar(__webpack_require__(669)); -const v4_1 = __importDefault(__webpack_require__(494)); -const exec_1 = __webpack_require__(986); -const assert_1 = __webpack_require__(357); -const retry_helper_1 = __webpack_require__(979); -class HTTPError extends Error { - constructor(httpStatusCode) { - super(`Unexpected HTTP response: ${httpStatusCode}`); - this.httpStatusCode = httpStatusCode; - Object.setPrototypeOf(this, new.target.prototype); +const fs_1 = __importDefault(__webpack_require__(747)); +const path_1 = __importDefault(__webpack_require__(622)); +const base_installer_1 = __webpack_require__(83); +const util_1 = __webpack_require__(322); +const constants_1 = __webpack_require__(211); +class LocalDistribution extends base_installer_1.JavaBase { + constructor(installerOptions, jdkFile) { + super('jdkfile', installerOptions); + this.jdkFile = jdkFile; } -} -exports.HTTPError = HTTPError; -const IS_WINDOWS = process.platform === 'win32'; -const IS_MAC = process.platform === 'darwin'; -const userAgent = 'actions/tool-cache'; -/** - * Download a tool from an url and stream it into a file - * - * @param url url of tool to download - * @param dest path to download tool - * @param auth authorization header - * @returns path to downloaded tool - */ -function downloadTool(url, dest, auth) { - return __awaiter(this, void 0, void 0, function* () { - dest = dest || path.join(_getTempDirectory(), v4_1.default()); - yield io.mkdirP(path.dirname(dest)); - core.debug(`Downloading ${url}`); - core.debug(`Destination ${dest}`); - const maxAttempts = 3; - const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); - const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); - const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); - return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { - return yield downloadToolAttempt(url, dest || '', auth); - }), (err) => { - if (err instanceof HTTPError && err.httpStatusCode) { - // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests - if (err.httpStatusCode < 500 && - err.httpStatusCode !== 408 && - err.httpStatusCode !== 429) { - return false; - } + setupJava() { + return __awaiter(this, void 0, void 0, function* () { + let foundJava = this.findInToolcache(); + if (foundJava) { + core.info(`Resolved Java ${foundJava.version} from tool-cache`); } - // Otherwise retry - return true; - }); - }); -} -exports.downloadTool = downloadTool; -function downloadToolAttempt(url, dest, auth) { - return __awaiter(this, void 0, void 0, function* () { - if (fs.existsSync(dest)) { - throw new Error(`Destination file path ${dest} already exists`); - } - // Get the response headers - const http = new httpm.HttpClient(userAgent, [], { - allowRetries: false - }); - let headers; - if (auth) { - core.debug('set auth'); - headers = { - authorization: auth - }; - } - const response = yield http.get(url, headers); - if (response.message.statusCode !== 200) { - const err = new HTTPError(response.message.statusCode); - core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - throw err; - } - // Download the response body - const pipeline = util.promisify(stream.pipeline); - const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); - const readStream = responseMessageFactory(); - let succeeded = false; - try { - yield pipeline(readStream, fs.createWriteStream(dest)); - core.debug('download complete'); - succeeded = true; - return dest; - } - finally { - // Error, delete dest before retry - if (!succeeded) { - core.debug('download failed'); - try { - yield io.rmRF(dest); + else { + core.info(`Java ${this.version} was not found in tool-cache. Trying to unpack JDK file...`); + if (!this.jdkFile) { + throw new Error("'jdkFile' is not specified"); } - catch (err) { - core.debug(`Failed to delete '${dest}'. ${err.message}`); + const jdkFilePath = path_1.default.resolve(this.jdkFile); + const stats = fs_1.default.statSync(jdkFilePath); + if (!stats.isFile()) { + throw new Error(`JDK file was not found in path '${jdkFilePath}'`); } + core.info(`Extracting Java from '${jdkFilePath}'`); + const extractedJavaPath = yield util_1.extractJdkFile(jdkFilePath); + const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; + const archivePath = path_1.default.join(extractedJavaPath, archiveName); + const javaVersion = this.version; + let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture); + // for different Java distributions, postfix can exist or not so need to check both cases + if (process.platform === 'darwin' && + fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) { + javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX); + } + foundJava = { + version: javaVersion, + path: javaPath + }; } - } - }); + core.info(`Setting Java ${foundJava.version} as default`); + this.setJavaDefault(foundJava.version, foundJava.path); + return foundJava; + }); + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('This method should not be implemented in local file provider'); + }); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('This method should not be implemented in local file provider'); + }); + } } -/** - * Extract a .7z file +exports.LocalDistribution = LocalDistribution; + + +/***/ }), +/* 145 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +/* + * Copyright The OpenTelemetry Authors * - * @param file path to the .7z file - * @param dest destination directory. Optional. - * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this - * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will - * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is - * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line - * interface, it is smaller than the full command line interface, and it does support long paths. At the - * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. - * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path - * to 7zr.exe can be pass to this function. - * @returns path to the destination directory - */ -function extract7z(file, dest, _7zPath) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - const originalCwd = process.cwd(); - process.chdir(dest); - if (_7zPath) { - try { - const logLevel = core.isDebug() ? '-bb1' : '-bb0'; - const args = [ - 'x', - logLevel, - '-bd', - '-sccUTF-8', - file - ]; - const options = { - silent: true - }; - yield exec_1.exec(`"${_7zPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - else { - const escapedScript = path - .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') - .replace(/'/g, "''") - .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - const options = { - silent: true - }; - try { - const powershellPath = yield io.which('powershell', true); - yield exec_1.exec(`"${powershellPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - return dest; - }); -} -exports.extract7z = extract7z; -/** - * Extract a compressed tar archive - * - * @param file path to the tar - * @param dest destination directory. Optional. - * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. - * @returns path to the destination directory - */ -function extractTar(file, dest, flags = 'xz') { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - // Create dest - dest = yield _createExtractFolder(dest); - // Determine whether GNU tar - core.debug('Checking tar --version'); - let versionOutput = ''; - yield exec_1.exec('tar --version', [], { - ignoreReturnCode: true, - silent: true, - listeners: { - stdout: (data) => (versionOutput += data.toString()), - stderr: (data) => (versionOutput += data.toString()) - } - }); - core.debug(versionOutput.trim()); - const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); - // Initialize args - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - if (core.isDebug() && !flags.includes('v')) { - args.push('-v'); - } - let destArg = dest; - let fileArg = file; - if (IS_WINDOWS && isGnuTar) { - args.push('--force-local'); - destArg = dest.replace(/\\/g, '/'); - // Technically only the dest needs to have `/` but for aesthetic consistency - // convert slashes in the file arg too. - fileArg = file.replace(/\\/g, '/'); - } - if (isGnuTar) { - // Suppress warnings when using GNU tar to extract archives created by BSD tar - args.push('--warning=no-unknown-keyword'); - } - args.push('-C', destArg, '-f', fileArg); - yield exec_1.exec(`tar`, args); - return dest; - }); -} -exports.extractTar = extractTar; -/** - * Extract a xar compatible archive + * 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 * - * @param file path to the archive - * @param dest destination directory. Optional. - * @param flags flags for the xar. Optional. - * @returns path to the destination directory - */ -function extractXar(file, dest, flags = []) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - args.push('-x', '-C', dest, '-f', file); - if (core.isDebug()) { - args.push('-v'); - } - const xarPath = yield io.which('xar', true); - yield exec_1.exec(`"${xarPath}"`, _unique(args)); - return dest; - }); -} -exports.extractXar = extractXar; -/** - * Extract a zip + * https://www.apache.org/licenses/LICENSE-2.0 * - * @param file path to the zip - * @param dest destination directory. Optional. - * @returns path to the destination directory + * 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. */ -function extractZip(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = yield _createExtractFolder(dest); - if (IS_WINDOWS) { - yield extractZipWin(file, dest); - } - else { - yield extractZipNix(file, dest); +Object.defineProperty(exports, "__esModule", { value: true }); +exports._globalThis = void 0; +/** only globals that common to node and browsers are allowed */ +// eslint-disable-next-line node/no-unsupported-features/es-builtins +exports._globalThis = typeof globalThis === 'object' ? globalThis : global; +//# sourceMappingURL=globalThis.js.map + +/***/ }), +/* 146 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); } - return dest; - }); -} -exports.extractZip = extractZip; -function extractZipWin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - // build the powershell command - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; - // run powershell - const powershellPath = yield io.which('powershell', true); - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - yield exec_1.exec(`"${powershellPath}"`, args); - }); -} -function extractZipNix(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = yield io.which('unzip', true); - const args = [file]; - if (!core.isDebug()) { - args.unshift('-q'); + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); - }); -} + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var infra_1 = __webpack_require__(23); /** - * Caches a directory and installs it into the tool cacheDir + * Converts a whitespace separated string into an array of tokens. * - * @param sourceDir the directory to cache into tools - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * @param value - a string of whitespace separated tokens */ -function cacheDir(sourceDir, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source dir: ${sourceDir}`); - if (!fs.statSync(sourceDir).isDirectory()) { - throw new Error('sourceDir is not a directory'); - } - // Create the tool dir - const destPath = yield _createToolPath(tool, version, arch); - // copy each child item. do not move. move can fail on Windows - // due to anti-virus software having an open handle on a file. - for (const itemName of fs.readdirSync(sourceDir)) { - const s = path.join(sourceDir, itemName); - yield io.cp(s, destPath, { recursive: true }); - } - // write .complete - _completeToolPath(tool, version, arch); - return destPath; - }); +function orderedSet_parse(value) { + /** + * 1. Let inputTokens be the result of splitting input on ASCII whitespace. + * 2. Let tokens be a new ordered set. + * 3. For each token in inputTokens, append token to tokens. + * 4. Return tokens. + */ + var inputTokens = infra_1.string.splitAStringOnASCIIWhitespace(value); + return new Set(inputTokens); } -exports.cacheDir = cacheDir; +exports.orderedSet_parse = orderedSet_parse; /** - * Caches a downloaded file (GUID) and installs it - * into the tool cache with a given targetName + * Converts an array of tokens into a space separated string. * - * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. - * @param targetFile the name of the file name in the tools directory - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * @param tokens - an array of token strings */ -function cacheFile(sourceFile, targetFile, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source file: ${sourceFile}`); - if (!fs.statSync(sourceFile).isFile()) { - throw new Error('sourceFile is not a file'); - } - // create the tool dir - const destFolder = yield _createToolPath(tool, version, arch); - // copy instead of move. move can fail on Windows due to - // anti-virus software having an open handle on a file. - const destPath = path.join(destFolder, targetFile); - core.debug(`destination file ${destPath}`); - yield io.cp(sourceFile, destPath); - // write .complete - _completeToolPath(tool, version, arch); - return destFolder; - }); +function orderedSet_serialize(tokens) { + /** + * The ordered set serializer takes a set and returns the concatenation of + * set using U+0020 SPACE. + */ + return __spread(tokens).join(' '); } -exports.cacheFile = cacheFile; +exports.orderedSet_serialize = orderedSet_serialize; /** - * Finds the path to a tool version in the local installed tool cache + * Removes duplicate tokens and convert all whitespace characters + * to space. * - * @param toolName name of the tool - * @param versionSpec version of the tool - * @param arch optional arch. defaults to arch of computer + * @param value - a string of whitespace separated tokens */ -function find(toolName, versionSpec, arch) { - if (!toolName) { - throw new Error('toolName parameter is required'); - } - if (!versionSpec) { - throw new Error('versionSpec parameter is required'); - } - arch = arch || os.arch(); - // attempt to resolve an explicit version - if (!_isExplicitVersion(versionSpec)) { - const localVersions = findAllVersions(toolName, arch); - const match = _evaluateVersions(localVersions, versionSpec); - versionSpec = match; - } - // check for the explicit version in the cache - let toolPath = ''; - if (versionSpec) { - versionSpec = semver.clean(versionSpec) || ''; - const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); - core.debug(`checking cache: ${cachePath}`); - if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { - core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); - toolPath = cachePath; - } - else { - core.debug('not found'); - } - } - return toolPath; +function orderedSet_sanitize(value) { + return orderedSet_serialize(orderedSet_parse(value)); } -exports.find = find; +exports.orderedSet_sanitize = orderedSet_sanitize; /** - * Finds the paths to all versions of a tool that are installed in the local tool cache + * Determines whether a set contains the other. * - * @param toolName name of the tool - * @param arch optional arch. defaults to arch of computer + * @param set1 - a set + * @param set1 - a set that is contained in set1 + * @param caseSensitive - whether matches are case-sensitive */ -function findAllVersions(toolName, arch) { - const versions = []; - arch = arch || os.arch(); - const toolPath = path.join(_getCacheDirectory(), toolName); - if (fs.existsSync(toolPath)) { - const children = fs.readdirSync(toolPath); - for (const child of children) { - if (_isExplicitVersion(child)) { - const fullPath = path.join(toolPath, child, arch || ''); - if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { - versions.push(child); +function orderedSet_contains(set1, set2, caseSensitive) { + var e_1, _a, e_2, _b; + try { + for (var set2_1 = __values(set2), set2_1_1 = set2_1.next(); !set2_1_1.done; set2_1_1 = set2_1.next()) { + var val2 = set2_1_1.value; + var found = false; + try { + for (var set1_1 = (e_2 = void 0, __values(set1)), set1_1_1 = set1_1.next(); !set1_1_1.done; set1_1_1 = set1_1.next()) { + var val1 = set1_1_1.value; + if (caseSensitive) { + if (val1 === val2) { + found = true; + break; + } + } + else { + if (val1.toUpperCase() === val2.toUpperCase()) { + found = true; + break; + } + } } } - } - } - return versions; -} -exports.findAllVersions = findAllVersions; -function getManifestFromRepo(owner, repo, auth, branch = 'master') { - return __awaiter(this, void 0, void 0, function* () { - let releases = []; - const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; - const http = new httpm.HttpClient('tool-cache'); - const headers = {}; - if (auth) { - core.debug('set auth'); - headers.authorization = auth; - } - const response = yield http.getJson(treeUrl, headers); - if (!response.result) { - return releases; - } - let manifestUrl = ''; - for (const item of response.result.tree) { - if (item.path === 'versions-manifest.json') { - manifestUrl = item.url; - break; + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (set1_1_1 && !set1_1_1.done && (_b = set1_1.return)) _b.call(set1_1); + } + finally { if (e_2) throw e_2.error; } } + if (!found) + return false; } - headers['accept'] = 'application/vnd.github.VERSION.raw'; - let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); - if (versionsRaw) { - // shouldn't be needed but protects against invalid json saved with BOM - versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); - try { - releases = JSON.parse(versionsRaw); - } - catch (_a) { - core.debug('Invalid json'); - } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (set2_1_1 && !set2_1_1.done && (_a = set2_1.return)) _a.call(set2_1); } - return releases; - }); -} -exports.getManifestFromRepo = getManifestFromRepo; -function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { - return __awaiter(this, void 0, void 0, function* () { - // wrap the internal impl - const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); - return match; - }); + finally { if (e_1) throw e_1.error; } + } + return true; } -exports.findFromManifest = findFromManifest; -function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - // create a temp dir - dest = path.join(_getTempDirectory(), v4_1.default()); +exports.orderedSet_contains = orderedSet_contains; +//# sourceMappingURL=OrderedSetAlgorithm.js.map + +/***/ }), +/* 147 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + + +exports.fromCallback = function (fn) { + return Object.defineProperty(function () { + if (typeof arguments[arguments.length - 1] === 'function') fn.apply(this, arguments) + else { + return new Promise((resolve, reject) => { + arguments[arguments.length] = (err, res) => { + if (err) return reject(err) + resolve(res) } - yield io.mkdirP(dest); - return dest; - }); + arguments.length++ + fn.apply(this, arguments) + }) + } + }, 'name', { value: fn.name }) } -function _createToolPath(tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - core.debug(`destination ${folderPath}`); - const markerPath = `${folderPath}.complete`; - yield io.rmRF(folderPath); - yield io.rmRF(markerPath); - yield io.mkdirP(folderPath); - return folderPath; - }); -} -function _completeToolPath(tool, version, arch) { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - const markerPath = `${folderPath}.complete`; - fs.writeFileSync(markerPath, ''); - core.debug('finished caching tool'); -} -function _isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec) || ''; - core.debug(`isExplicit: ${c}`); - const valid = semver.valid(c) != null; - core.debug(`explicit? ${valid}`); - return valid; -} -function _evaluateVersions(versions, versionSpec) { - let version = ''; - core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version = potential; - break; - } - } - if (version) { - core.debug(`matched: ${version}`); - } - else { - core.debug('match not found'); - } - return version; -} -/** - * Gets RUNNER_TOOL_CACHE - */ -function _getCacheDirectory() { - const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; - assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); - return cacheDirectory; -} -/** - * Gets RUNNER_TEMP - */ -function _getTempDirectory() { - const tempDirectory = process.env['RUNNER_TEMP'] || ''; - assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); - return tempDirectory; -} -/** - * Gets a global variable - */ -function _getGlobal(key, defaultValue) { - /* eslint-disable @typescript-eslint/no-explicit-any */ - const value = global[key]; - /* eslint-enable @typescript-eslint/no-explicit-any */ - return value !== undefined ? value : defaultValue; -} -/** - * Returns an array of unique values. - * @param values Values to make unique. - */ -function _unique(values) { - return Array.from(new Set(values)); + +exports.fromPromise = function (fn) { + return Object.defineProperty(function () { + const cb = arguments[arguments.length - 1] + if (typeof cb !== 'function') return fn.apply(this, arguments) + else fn.apply(this, arguments).then(r => cb(null, r), cb) + }, 'name', { value: fn.name }) } -//# sourceMappingURL=tool-cache.js.map + /***/ }), -/* 140 */, -/* 141 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 148 */, +/* 149 */ +/***/ (function(module) { "use strict"; -var net = __webpack_require__(631); -var tls = __webpack_require__(818); -var http = __webpack_require__(605); -var https = __webpack_require__(34); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); +var conversions = {}; +module.exports = conversions; +function sign(x) { + return x < 0 ? -1 : 1; +} -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +function evenRound(x) { + // Round x to the nearest integer, choosing the even integer if it lies halfway between two. + if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) + return Math.floor(x); + } else { + return Math.round(x); + } +} +function createNumberConversion(bitLength, typeOpts) { + if (!typeOpts.unsigned) { + --bitLength; + } + const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); + const upperBound = Math.pow(2, bitLength) - 1; -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} + const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); + const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + return function(V, opts) { + if (!opts) opts = {}; -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} + let x = +V; -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} + if (opts.enforceRange) { + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite number"); + } + x = sign(x) * Math.floor(Math.abs(x)); + if (x < lowerBound || x > upperBound) { + throw new TypeError("Argument is not in byte range"); + } -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; + return x; + } - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } - } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); + if (!isNaN(x) && opts.clamp) { + x = evenRound(x); -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + if (x < lowerBound) x = lowerBound; + if (x > upperBound) x = upperBound; + return x; + } - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } + if (!Number.isFinite(x) || x === 0) { + return 0; + } - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); + x = sign(x) * Math.floor(Math.abs(x)); + x = x % moduloVal; - function onFree() { - self.emit('free', socket, options); - } + if (!typeOpts.unsigned && x >= moduloBound) { + return x - moduloVal; + } else if (typeOpts.unsigned) { + if (x < 0) { + x += moduloVal; + } else if (x === -0) { // don't return negative zero + return 0; + } + } - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); + return x; } - }); +} + +conversions["void"] = function () { + return undefined; }; -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); +conversions["boolean"] = function (val) { + return !!val; +}; - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port - } - }); - if (options.localAddress) { - connectOptions.localAddress = options.localAddress; - } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } +conversions["byte"] = createNumberConversion(8, { unsigned: false }); +conversions["octet"] = createNumberConversion(8, { unsigned: true }); - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); +conversions["short"] = createNumberConversion(16, { unsigned: false }); +conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } +conversions["long"] = createNumberConversion(32, { unsigned: false }); +conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } +conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); +conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); +conversions["double"] = function (V) { + const x = +V; - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite floating-point value"); } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } - - function onError(cause) { - connectReq.removeAllListeners(); - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } + return x; }; -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); +conversions["unrestricted double"] = function (V) { + const x = +V; - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } + if (isNaN(x)) { + throw new TypeError("Argument is NaN"); + } + + return x; }; -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); +// not quite valid, but good enough for JS +conversions["float"] = conversions["double"]; +conversions["unrestricted float"] = conversions["unrestricted double"]; - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} +conversions["DOMString"] = function (V, opts) { + if (!opts) opts = {}; + if (opts.treatNullAsEmptyString && V === null) { + return ""; + } -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; - } - return host; // for v0.11 or later -} + return String(V); +}; -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; +conversions["ByteString"] = function (V, opts) { + const x = String(V); + let c = undefined; + for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { + if (c > 255) { + throw new TypeError("Argument is not a valid bytestring"); } - } } - } - return target; -} + return x; +}; -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); +conversions["USVString"] = function (V) { + const S = String(V); + const n = S.length; + const U = []; + for (let i = 0; i < n; ++i) { + const c = S.charCodeAt(i); + if (c < 0xD800 || c > 0xDFFF) { + U.push(String.fromCodePoint(c)); + } else if (0xDC00 <= c && c <= 0xDFFF) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + if (i === n - 1) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + const d = S.charCodeAt(i + 1); + if (0xDC00 <= d && d <= 0xDFFF) { + const a = c & 0x3FF; + const b = d & 0x3FF; + U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); + ++i; + } else { + U.push(String.fromCodePoint(0xFFFD)); + } + } + } } - console.error.apply(console, args); - } -} else { - debug = function() {}; -} -exports.debug = debug; // for test + return U.join(''); +}; -/***/ }), -/* 142 */, -/* 143 */ -/***/ (function(module) { +conversions["Date"] = function (V, opts) { + if (!(V instanceof Date)) { + throw new TypeError("Argument is not a Date object"); + } + if (isNaN(V)) { + return undefined; + } -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) -module.exports = parseOptions + return V; +}; + +conversions["RegExp"] = function (V, opts) { + if (!(V instanceof RegExp)) { + V = new RegExp(V); + } + + return V; +}; /***/ }), -/* 144 */ +/* 150 */, +/* 151 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.LocalDistribution = void 0; -const tc = __importStar(__webpack_require__(139)); -const core = __importStar(__webpack_require__(470)); -const fs_1 = __importDefault(__webpack_require__(747)); -const path_1 = __importDefault(__webpack_require__(622)); -const base_installer_1 = __webpack_require__(83); -const util_1 = __webpack_require__(322); -const constants_1 = __webpack_require__(211); -class LocalDistribution extends base_installer_1.JavaBase { - constructor(installerOptions, jdkFile) { - super('jdkfile', installerOptions); - this.jdkFile = jdkFile; - } - setupJava() { - return __awaiter(this, void 0, void 0, function* () { - let foundJava = this.findInToolcache(); - if (foundJava) { - core.info(`Resolved Java ${foundJava.version} from tool-cache`); - } - else { - core.info(`Java ${this.version} was not found in tool-cache. Trying to unpack JDK file...`); - if (!this.jdkFile) { - throw new Error("'jdkFile' is not specified"); - } - const jdkFilePath = path_1.default.resolve(this.jdkFile); - const stats = fs_1.default.statSync(jdkFilePath); - if (!stats.isFile()) { - throw new Error(`JDK file was not found in path '${jdkFilePath}'`); - } - core.info(`Extracting Java from '${jdkFilePath}'`); - const extractedJavaPath = yield util_1.extractJdkFile(jdkFilePath); - const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; - const archivePath = path_1.default.join(extractedJavaPath, archiveName); - const javaVersion = this.version; - let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture); - // for different Java distributions, postfix can exist or not so need to check both cases - if (process.platform === 'darwin' && - fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) { - javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX); - } - foundJava = { - version: javaVersion, - path: javaPath - }; - } - core.info(`Setting Java ${foundJava.version} as default`); - this.setJavaDefault(foundJava.version, foundJava.path); - return foundJava; - }); - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - throw new Error('This method should not be implemented in local file provider'); - }); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - throw new Error('This method should not be implemented in local file provider'); - }); - } -} -exports.LocalDistribution = LocalDistribution; - - -/***/ }), -/* 145 */ -/***/ (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._globalThis = void 0; -/** only globals that common to node and browsers are allowed */ -// eslint-disable-next-line node/no-unsupported-features/es-builtins -exports._globalThis = typeof globalThis === 'object' ? globalThis : global; -//# sourceMappingURL=globalThis.js.map - -/***/ }), -/* 146 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var infra_1 = __webpack_require__(23); -/** - * Converts a whitespace separated string into an array of tokens. - * - * @param value - a string of whitespace separated tokens - */ -function orderedSet_parse(value) { - /** - * 1. Let inputTokens be the result of splitting input on ASCII whitespace. - * 2. Let tokens be a new ordered set. - * 3. For each token in inputTokens, append token to tokens. - * 4. Return tokens. - */ - var inputTokens = infra_1.string.splitAStringOnASCIIWhitespace(value); - return new Set(inputTokens); -} -exports.orderedSet_parse = orderedSet_parse; -/** - * Converts an array of tokens into a space separated string. - * - * @param tokens - an array of token strings - */ -function orderedSet_serialize(tokens) { - /** - * The ordered set serializer takes a set and returns the concatenation of - * set using U+0020 SPACE. - */ - return __spread(tokens).join(' '); -} -exports.orderedSet_serialize = orderedSet_serialize; -/** - * Removes duplicate tokens and convert all whitespace characters - * to space. - * - * @param value - a string of whitespace separated tokens - */ -function orderedSet_sanitize(value) { - return orderedSet_serialize(orderedSet_parse(value)); -} -exports.orderedSet_sanitize = orderedSet_sanitize; -/** - * Determines whether a set contains the other. - * - * @param set1 - a set - * @param set1 - a set that is contained in set1 - * @param caseSensitive - whether matches are case-sensitive - */ -function orderedSet_contains(set1, set2, caseSensitive) { - var e_1, _a, e_2, _b; - try { - for (var set2_1 = __values(set2), set2_1_1 = set2_1.next(); !set2_1_1.done; set2_1_1 = set2_1.next()) { - var val2 = set2_1_1.value; - var found = false; - try { - for (var set1_1 = (e_2 = void 0, __values(set1)), set1_1_1 = set1_1.next(); !set1_1_1.done; set1_1_1 = set1_1.next()) { - var val1 = set1_1_1.value; - if (caseSensitive) { - if (val1 === val2) { - found = true; - break; - } - } - else { - if (val1.toUpperCase() === val2.toUpperCase()) { - found = true; - break; - } - } - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (set1_1_1 && !set1_1_1.done && (_b = set1_1.return)) _b.call(set1_1); - } - finally { if (e_2) throw e_2.error; } - } - if (!found) - return false; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (set2_1_1 && !set2_1_1.done && (_a = set2_1.return)) _a.call(set2_1); - } - finally { if (e_1) throw e_1.error; } - } - return true; -} -exports.orderedSet_contains = orderedSet_contains; -//# sourceMappingURL=OrderedSetAlgorithm.js.map - -/***/ }), -/* 147 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - - -exports.fromCallback = function (fn) { - return Object.defineProperty(function () { - if (typeof arguments[arguments.length - 1] === 'function') fn.apply(this, arguments) - else { - return new Promise((resolve, reject) => { - arguments[arguments.length] = (err, res) => { - if (err) return reject(err) - resolve(res) - } - arguments.length++ - fn.apply(this, arguments) - }) - } - }, 'name', { value: fn.name }) -} - -exports.fromPromise = function (fn) { - return Object.defineProperty(function () { - const cb = arguments[arguments.length - 1] - if (typeof cb !== 'function') return fn.apply(this, arguments) - else fn.apply(this, arguments).then(r => cb(null, r), cb) - }, 'name', { value: fn.name }) -} - - -/***/ }), -/* 148 */, -/* 149 */ -/***/ (function(module) { - -"use strict"; - - -var conversions = {}; -module.exports = conversions; - -function sign(x) { - return x < 0 ? -1 : 1; -} - -function evenRound(x) { - // Round x to the nearest integer, choosing the even integer if it lies halfway between two. - if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) - return Math.floor(x); - } else { - return Math.round(x); - } -} - -function createNumberConversion(bitLength, typeOpts) { - if (!typeOpts.unsigned) { - --bitLength; - } - const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); - const upperBound = Math.pow(2, bitLength) - 1; - - const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); - const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); - - return function(V, opts) { - if (!opts) opts = {}; - - let x = +V; - - if (opts.enforceRange) { - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite number"); - } - - x = sign(x) * Math.floor(Math.abs(x)); - if (x < lowerBound || x > upperBound) { - throw new TypeError("Argument is not in byte range"); - } - - return x; - } - - if (!isNaN(x) && opts.clamp) { - x = evenRound(x); - - if (x < lowerBound) x = lowerBound; - if (x > upperBound) x = upperBound; - return x; - } - - if (!Number.isFinite(x) || x === 0) { - return 0; - } - - x = sign(x) * Math.floor(Math.abs(x)); - x = x % moduloVal; - - if (!typeOpts.unsigned && x >= moduloBound) { - return x - moduloVal; - } else if (typeOpts.unsigned) { - if (x < 0) { - x += moduloVal; - } else if (x === -0) { // don't return negative zero - return 0; - } - } - - return x; - } -} - -conversions["void"] = function () { - return undefined; -}; - -conversions["boolean"] = function (val) { - return !!val; -}; - -conversions["byte"] = createNumberConversion(8, { unsigned: false }); -conversions["octet"] = createNumberConversion(8, { unsigned: true }); - -conversions["short"] = createNumberConversion(16, { unsigned: false }); -conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); - -conversions["long"] = createNumberConversion(32, { unsigned: false }); -conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); - -conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); -conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); - -conversions["double"] = function (V) { - const x = +V; - - if (!Number.isFinite(x)) { - throw new TypeError("Argument is not a finite floating-point value"); - } - - return x; -}; - -conversions["unrestricted double"] = function (V) { - const x = +V; - - if (isNaN(x)) { - throw new TypeError("Argument is NaN"); - } - - return x; -}; - -// not quite valid, but good enough for JS -conversions["float"] = conversions["double"]; -conversions["unrestricted float"] = conversions["unrestricted double"]; - -conversions["DOMString"] = function (V, opts) { - if (!opts) opts = {}; - - if (opts.treatNullAsEmptyString && V === null) { - return ""; - } - - return String(V); -}; - -conversions["ByteString"] = function (V, opts) { - const x = String(V); - let c = undefined; - for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { - if (c > 255) { - throw new TypeError("Argument is not a valid bytestring"); - } - } - - return x; -}; - -conversions["USVString"] = function (V) { - const S = String(V); - const n = S.length; - const U = []; - for (let i = 0; i < n; ++i) { - const c = S.charCodeAt(i); - if (c < 0xD800 || c > 0xDFFF) { - U.push(String.fromCodePoint(c)); - } else if (0xDC00 <= c && c <= 0xDFFF) { - U.push(String.fromCodePoint(0xFFFD)); - } else { - if (i === n - 1) { - U.push(String.fromCodePoint(0xFFFD)); - } else { - const d = S.charCodeAt(i + 1); - if (0xDC00 <= d && d <= 0xDFFF) { - const a = c & 0x3FF; - const b = d & 0x3FF; - U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); - ++i; - } else { - U.push(String.fromCodePoint(0xFFFD)); - } - } - } - } - - return U.join(''); -}; - -conversions["Date"] = function (V, opts) { - if (!(V instanceof Date)) { - throw new TypeError("Argument is not a Date object"); - } - if (isNaN(V)) { - return undefined; - } - - return V; -}; - -conversions["RegExp"] = function (V, opts) { - if (!(V instanceof RegExp)) { - V = new RegExp(V); - } - - return V; -}; - - -/***/ }), -/* 150 */, -/* 151 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; @@ -13318,328 +12704,939 @@ var __read = (this && this.__read) || function (o, n) { try { if (r && !r.done && (m = i["return"])) m.call(i); } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var util_1 = __webpack_require__(918); -var util_2 = __webpack_require__(592); -var TreeAlgorithm_1 = __webpack_require__(873); -var MutationObserverAlgorithm_1 = __webpack_require__(151); -/** - * Signals a slot change to the given slot. - * - * @param slot - a slot - */ -function shadowTree_signalASlotChange(slot) { - /** - * 1. Append slot to slot’s relevant agent’s signal slots. - * 2. Queue a mutation observer microtask. - */ - var window = DOMImpl_1.dom.window; - window._signalSlots.add(slot); - MutationObserverAlgorithm_1.observer_queueAMutationObserverMicrotask(); + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var util_1 = __webpack_require__(918); +var util_2 = __webpack_require__(592); +var TreeAlgorithm_1 = __webpack_require__(873); +var MutationObserverAlgorithm_1 = __webpack_require__(151); +/** + * Signals a slot change to the given slot. + * + * @param slot - a slot + */ +function shadowTree_signalASlotChange(slot) { + /** + * 1. Append slot to slot’s relevant agent’s signal slots. + * 2. Queue a mutation observer microtask. + */ + var window = DOMImpl_1.dom.window; + window._signalSlots.add(slot); + MutationObserverAlgorithm_1.observer_queueAMutationObserverMicrotask(); +} +exports.shadowTree_signalASlotChange = shadowTree_signalASlotChange; +/** + * Determines whether a the shadow tree of the given element node is + * connected to a document node. + * + * @param element - an element node of the shadow tree + */ +function shadowTree_isConnected(element) { + /** + * An element is connected if its shadow-including root is a document. + */ + return util_1.Guard.isDocumentNode(TreeAlgorithm_1.tree_rootNode(element, true)); +} +exports.shadowTree_isConnected = shadowTree_isConnected; +/** + * Determines whether a slotable is assigned. + * + * @param slotable - a slotable + */ +function shadowTree_isAssigned(slotable) { + /** + * A slotable is assigned if its assigned slot is non-null. + */ + return (slotable._assignedSlot !== null); +} +exports.shadowTree_isAssigned = shadowTree_isAssigned; +/** + * Finds a slot for the given slotable. + * + * @param slotable - a slotable + * @param openFlag - `true` to search open shadow tree's only + */ +function shadowTree_findASlot(slotable, openFlag) { + if (openFlag === void 0) { openFlag = false; } + /** + * 1. If slotable’s parent is null, then return null. + * 2. Let shadow be slotable’s parent’s shadow root. + * 3. If shadow is null, then return null. + * 4. If the open flag is set and shadow’s mode is not "open", then + * return null. + * 5. Return the first slot in tree order in shadow’s descendants whose name + * is slotable’s name, if any, and null otherwise. + */ + var node = util_1.Cast.asNode(slotable); + var parent = node._parent; + if (parent === null) + return null; + var shadow = parent._shadowRoot || null; + if (shadow === null) + return null; + if (openFlag && shadow._mode !== "open") + return null; + var child = TreeAlgorithm_1.tree_getFirstDescendantNode(shadow, false, true, function (e) { return util_1.Guard.isSlot(e); }); + while (child !== null) { + if (child._name === slotable._name) + return child; + child = TreeAlgorithm_1.tree_getNextDescendantNode(shadow, child, false, true, function (e) { return util_1.Guard.isSlot(e); }); + } + return null; +} +exports.shadowTree_findASlot = shadowTree_findASlot; +/** + * Finds slotables for the given slot. + * + * @param slot - a slot + */ +function shadowTree_findSlotables(slot) { + var e_1, _a; + /** + * 1. Let result be an empty list. + * 2. If slot’s root is not a shadow root, then return result. + */ + var result = []; + var root = TreeAlgorithm_1.tree_rootNode(slot); + if (!util_1.Guard.isShadowRoot(root)) + return result; + /** + * 3. Let host be slot’s root’s host. + * 4. For each slotable child of host, slotable, in tree order: + */ + var host = root._host; + try { + for (var _b = __values(host._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var slotable = _c.value; + if (util_1.Guard.isSlotable(slotable)) { + /** + * 4.1. Let foundSlot be the result of finding a slot given slotable. + * 4.2. If foundSlot is slot, then append slotable to result. + */ + var foundSlot = shadowTree_findASlot(slotable); + if (foundSlot === slot) { + result.push(slotable); + } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + /** + * 5. Return result. + */ + return result; +} +exports.shadowTree_findSlotables = shadowTree_findSlotables; +/** + * Finds slotables for the given slot. + * + * @param slot - a slot + */ +function shadowTree_findFlattenedSlotables(slot) { + var e_2, _a, e_3, _b; + /** + * 1. Let result be an empty list. + * 2. If slot’s root is not a shadow root, then return result. + */ + var result = []; + var root = TreeAlgorithm_1.tree_rootNode(slot); + if (!util_1.Guard.isShadowRoot(root)) + return result; + /** + * 3. Let slotables be the result of finding slotables given slot. + * 4. If slotables is the empty list, then append each slotable child of + * slot, in tree order, to slotables. + */ + var slotables = shadowTree_findSlotables(slot); + if (util_2.isEmpty(slotables)) { + try { + for (var _c = __values(slot._children), _d = _c.next(); !_d.done; _d = _c.next()) { + var slotable = _d.value; + if (util_1.Guard.isSlotable(slotable)) { + slotables.push(slotable); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_2) throw e_2.error; } + } + } + try { + /** + * 5. For each node in slotables: + */ + for (var slotables_1 = __values(slotables), slotables_1_1 = slotables_1.next(); !slotables_1_1.done; slotables_1_1 = slotables_1.next()) { + var node = slotables_1_1.value; + /** + * 5.1. If node is a slot whose root is a shadow root, then: + */ + if (util_1.Guard.isSlot(node) && util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(node))) { + /** + * 5.1.1. Let temporaryResult be the result of finding flattened slotables given node. + * 5.1.2. Append each slotable in temporaryResult, in order, to result. + */ + var temporaryResult = shadowTree_findFlattenedSlotables(node); + result.push.apply(result, __spread(temporaryResult)); + } + else { + /** + * 5.2. Otherwise, append node to result. + */ + result.push(node); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (slotables_1_1 && !slotables_1_1.done && (_b = slotables_1.return)) _b.call(slotables_1); + } + finally { if (e_3) throw e_3.error; } + } + /** + * 6. Return result. + */ + return result; +} +exports.shadowTree_findFlattenedSlotables = shadowTree_findFlattenedSlotables; +/** + * Assigns slotables to the given slot. + * + * @param slot - a slot + */ +function shadowTree_assignSlotables(slot) { + var e_4, _a; + /** + * 1. Let slotables be the result of finding slotables for slot. + * 2. If slotables and slot’s assigned nodes are not identical, then run + * signal a slot change for slot. + */ + var slotables = shadowTree_findSlotables(slot); + if (slotables.length === slot._assignedNodes.length) { + var nodesIdentical = true; + for (var i = 0; i < slotables.length; i++) { + if (slotables[i] !== slot._assignedNodes[i]) { + nodesIdentical = false; + break; + } + } + if (!nodesIdentical) { + shadowTree_signalASlotChange(slot); + } + } + /** + * 3. Set slot’s assigned nodes to slotables. + * 4. For each slotable in slotables, set slotable’s assigned slot to slot. + */ + slot._assignedNodes = slotables; + try { + for (var slotables_2 = __values(slotables), slotables_2_1 = slotables_2.next(); !slotables_2_1.done; slotables_2_1 = slotables_2.next()) { + var slotable = slotables_2_1.value; + slotable._assignedSlot = slot; + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (slotables_2_1 && !slotables_2_1.done && (_a = slotables_2.return)) _a.call(slotables_2); + } + finally { if (e_4) throw e_4.error; } + } +} +exports.shadowTree_assignSlotables = shadowTree_assignSlotables; +/** + * Assigns slotables to all nodes of a tree. + * + * @param root - root node + */ +function shadowTree_assignSlotablesForATree(root) { + /** + * To assign slotables for a tree, given a node root, run assign slotables + * for each slot slot in root’s inclusive descendants, in tree order. + */ + var descendant = TreeAlgorithm_1.tree_getFirstDescendantNode(root, true, false, function (e) { return util_1.Guard.isSlot(e); }); + while (descendant !== null) { + shadowTree_assignSlotables(descendant); + descendant = TreeAlgorithm_1.tree_getNextDescendantNode(root, descendant, true, false, function (e) { return util_1.Guard.isSlot(e); }); + } +} +exports.shadowTree_assignSlotablesForATree = shadowTree_assignSlotablesForATree; +/** + * Assigns a slot to a slotables. + * + * @param slotable - a slotable + */ +function shadowTree_assignASlot(slotable) { + /** + * 1. Let slot be the result of finding a slot with slotable. + * 2. If slot is non-null, then run assign slotables for slot. + */ + var slot = shadowTree_findASlot(slotable); + if (slot !== null) { + shadowTree_assignSlotables(slot); + } +} +exports.shadowTree_assignASlot = shadowTree_assignASlot; +//# sourceMappingURL=ShadowTreeAlgorithm.js.map + +/***/ }), +/* 181 */ +/***/ (function(module) { + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' + +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 + +module.exports = { + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH +} + + +/***/ }), +/* 182 */, +/* 183 */, +/* 184 */, +/* 185 */, +/* 186 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const io = __importStar(__webpack_require__(1)); +const fs = __importStar(__webpack_require__(747)); +const mm = __importStar(__webpack_require__(31)); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); +const httpm = __importStar(__webpack_require__(539)); +const semver = __importStar(__webpack_require__(550)); +const stream = __importStar(__webpack_require__(794)); +const util = __importStar(__webpack_require__(669)); +const v4_1 = __importDefault(__webpack_require__(494)); +const exec_1 = __webpack_require__(986); +const assert_1 = __webpack_require__(357); +const retry_helper_1 = __webpack_require__(979); +class HTTPError extends Error { + constructor(httpStatusCode) { + super(`Unexpected HTTP response: ${httpStatusCode}`); + this.httpStatusCode = httpStatusCode; + Object.setPrototypeOf(this, new.target.prototype); + } +} +exports.HTTPError = HTTPError; +const IS_WINDOWS = process.platform === 'win32'; +const IS_MAC = process.platform === 'darwin'; +const userAgent = 'actions/tool-cache'; +/** + * Download a tool from an url and stream it into a file + * + * @param url url of tool to download + * @param dest path to download tool + * @param auth authorization header + * @returns path to downloaded tool + */ +function downloadTool(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + dest = dest || path.join(_getTempDirectory(), v4_1.default()); + yield io.mkdirP(path.dirname(dest)); + core.debug(`Downloading ${url}`); + core.debug(`Destination ${dest}`); + const maxAttempts = 3; + const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); + const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); + const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); + return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { + return yield downloadToolAttempt(url, dest || '', auth); + }), (err) => { + if (err instanceof HTTPError && err.httpStatusCode) { + // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests + if (err.httpStatusCode < 500 && + err.httpStatusCode !== 408 && + err.httpStatusCode !== 429) { + return false; + } + } + // Otherwise retry + return true; + }); + }); +} +exports.downloadTool = downloadTool; +function downloadToolAttempt(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + if (fs.existsSync(dest)) { + throw new Error(`Destination file path ${dest} already exists`); + } + // Get the response headers + const http = new httpm.HttpClient(userAgent, [], { + allowRetries: false + }); + let headers; + if (auth) { + core.debug('set auth'); + headers = { + authorization: auth + }; + } + const response = yield http.get(url, headers); + if (response.message.statusCode !== 200) { + const err = new HTTPError(response.message.statusCode); + core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + throw err; + } + // Download the response body + const pipeline = util.promisify(stream.pipeline); + const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); + const readStream = responseMessageFactory(); + let succeeded = false; + try { + yield pipeline(readStream, fs.createWriteStream(dest)); + core.debug('download complete'); + succeeded = true; + return dest; + } + finally { + // Error, delete dest before retry + if (!succeeded) { + core.debug('download failed'); + try { + yield io.rmRF(dest); + } + catch (err) { + core.debug(`Failed to delete '${dest}'. ${err.message}`); + } + } + } + }); +} +/** + * Extract a .7z file + * + * @param file path to the .7z file + * @param dest destination directory. Optional. + * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this + * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will + * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is + * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line + * interface, it is smaller than the full command line interface, and it does support long paths. At the + * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. + * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path + * to 7zr.exe can be pass to this function. + * @returns path to the destination directory + */ +function extract7z(file, dest, _7zPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + const originalCwd = process.cwd(); + process.chdir(dest); + if (_7zPath) { + try { + const logLevel = core.isDebug() ? '-bb1' : '-bb0'; + const args = [ + 'x', + logLevel, + '-bd', + '-sccUTF-8', + file + ]; + const options = { + silent: true + }; + yield exec_1.exec(`"${_7zPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + else { + const escapedScript = path + .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') + .replace(/'/g, "''") + .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + const options = { + silent: true + }; + try { + const powershellPath = yield io.which('powershell', true); + yield exec_1.exec(`"${powershellPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + return dest; + }); +} +exports.extract7z = extract7z; +/** + * Extract a compressed tar archive + * + * @param file path to the tar + * @param dest destination directory. Optional. + * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. + * @returns path to the destination directory + */ +function extractTar(file, dest, flags = 'xz') { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + // Create dest + dest = yield _createExtractFolder(dest); + // Determine whether GNU tar + core.debug('Checking tar --version'); + let versionOutput = ''; + yield exec_1.exec('tar --version', [], { + ignoreReturnCode: true, + silent: true, + listeners: { + stdout: (data) => (versionOutput += data.toString()), + stderr: (data) => (versionOutput += data.toString()) + } + }); + core.debug(versionOutput.trim()); + const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); + // Initialize args + let args; + if (flags instanceof Array) { + args = flags; + } + else { + args = [flags]; + } + if (core.isDebug() && !flags.includes('v')) { + args.push('-v'); + } + let destArg = dest; + let fileArg = file; + if (IS_WINDOWS && isGnuTar) { + args.push('--force-local'); + destArg = dest.replace(/\\/g, '/'); + // Technically only the dest needs to have `/` but for aesthetic consistency + // convert slashes in the file arg too. + fileArg = file.replace(/\\/g, '/'); + } + if (isGnuTar) { + // Suppress warnings when using GNU tar to extract archives created by BSD tar + args.push('--warning=no-unknown-keyword'); + } + args.push('-C', destArg, '-f', fileArg); + yield exec_1.exec(`tar`, args); + return dest; + }); +} +exports.extractTar = extractTar; +/** + * Extract a xar compatible archive + * + * @param file path to the archive + * @param dest destination directory. Optional. + * @param flags flags for the xar. Optional. + * @returns path to the destination directory + */ +function extractXar(file, dest, flags = []) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + let args; + if (flags instanceof Array) { + args = flags; + } + else { + args = [flags]; + } + args.push('-x', '-C', dest, '-f', file); + if (core.isDebug()) { + args.push('-v'); + } + const xarPath = yield io.which('xar', true); + yield exec_1.exec(`"${xarPath}"`, _unique(args)); + return dest; + }); +} +exports.extractXar = extractXar; +/** + * Extract a zip + * + * @param file path to the zip + * @param dest destination directory. Optional. + * @returns path to the destination directory + */ +function extractZip(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + dest = yield _createExtractFolder(dest); + if (IS_WINDOWS) { + yield extractZipWin(file, dest); + } + else { + yield extractZipNix(file, dest); + } + return dest; + }); +} +exports.extractZip = extractZip; +function extractZipWin(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + // build the powershell command + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; + // run powershell + const powershellPath = yield io.which('powershell', true); + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + yield exec_1.exec(`"${powershellPath}"`, args); + }); +} +function extractZipNix(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const unzipPath = yield io.which('unzip', true); + const args = [file]; + if (!core.isDebug()) { + args.unshift('-q'); + } + yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); + }); } -exports.shadowTree_signalASlotChange = shadowTree_signalASlotChange; /** - * Determines whether a the shadow tree of the given element node is - * connected to a document node. + * Caches a directory and installs it into the tool cacheDir * - * @param element - an element node of the shadow tree + * @param sourceDir the directory to cache into tools + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture */ -function shadowTree_isConnected(element) { - /** - * An element is connected if its shadow-including root is a document. - */ - return util_1.Guard.isDocumentNode(TreeAlgorithm_1.tree_rootNode(element, true)); +function cacheDir(sourceDir, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source dir: ${sourceDir}`); + if (!fs.statSync(sourceDir).isDirectory()) { + throw new Error('sourceDir is not a directory'); + } + // Create the tool dir + const destPath = yield _createToolPath(tool, version, arch); + // copy each child item. do not move. move can fail on Windows + // due to anti-virus software having an open handle on a file. + for (const itemName of fs.readdirSync(sourceDir)) { + const s = path.join(sourceDir, itemName); + yield io.cp(s, destPath, { recursive: true }); + } + // write .complete + _completeToolPath(tool, version, arch); + return destPath; + }); } -exports.shadowTree_isConnected = shadowTree_isConnected; +exports.cacheDir = cacheDir; /** - * Determines whether a slotable is assigned. + * Caches a downloaded file (GUID) and installs it + * into the tool cache with a given targetName * - * @param slotable - a slotable + * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. + * @param targetFile the name of the file name in the tools directory + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture */ -function shadowTree_isAssigned(slotable) { - /** - * A slotable is assigned if its assigned slot is non-null. - */ - return (slotable._assignedSlot !== null); +function cacheFile(sourceFile, targetFile, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source file: ${sourceFile}`); + if (!fs.statSync(sourceFile).isFile()) { + throw new Error('sourceFile is not a file'); + } + // create the tool dir + const destFolder = yield _createToolPath(tool, version, arch); + // copy instead of move. move can fail on Windows due to + // anti-virus software having an open handle on a file. + const destPath = path.join(destFolder, targetFile); + core.debug(`destination file ${destPath}`); + yield io.cp(sourceFile, destPath); + // write .complete + _completeToolPath(tool, version, arch); + return destFolder; + }); } -exports.shadowTree_isAssigned = shadowTree_isAssigned; +exports.cacheFile = cacheFile; /** - * Finds a slot for the given slotable. + * Finds the path to a tool version in the local installed tool cache * - * @param slotable - a slotable - * @param openFlag - `true` to search open shadow tree's only + * @param toolName name of the tool + * @param versionSpec version of the tool + * @param arch optional arch. defaults to arch of computer */ -function shadowTree_findASlot(slotable, openFlag) { - if (openFlag === void 0) { openFlag = false; } - /** - * 1. If slotable’s parent is null, then return null. - * 2. Let shadow be slotable’s parent’s shadow root. - * 3. If shadow is null, then return null. - * 4. If the open flag is set and shadow’s mode is not "open", then - * return null. - * 5. Return the first slot in tree order in shadow’s descendants whose name - * is slotable’s name, if any, and null otherwise. - */ - var node = util_1.Cast.asNode(slotable); - var parent = node._parent; - if (parent === null) - return null; - var shadow = parent._shadowRoot || null; - if (shadow === null) - return null; - if (openFlag && shadow._mode !== "open") - return null; - var child = TreeAlgorithm_1.tree_getFirstDescendantNode(shadow, false, true, function (e) { return util_1.Guard.isSlot(e); }); - while (child !== null) { - if (child._name === slotable._name) - return child; - child = TreeAlgorithm_1.tree_getNextDescendantNode(shadow, child, false, true, function (e) { return util_1.Guard.isSlot(e); }); +function find(toolName, versionSpec, arch) { + if (!toolName) { + throw new Error('toolName parameter is required'); } - return null; -} -exports.shadowTree_findASlot = shadowTree_findASlot; -/** - * Finds slotables for the given slot. - * - * @param slot - a slot - */ -function shadowTree_findSlotables(slot) { - var e_1, _a; - /** - * 1. Let result be an empty list. - * 2. If slot’s root is not a shadow root, then return result. - */ - var result = []; - var root = TreeAlgorithm_1.tree_rootNode(slot); - if (!util_1.Guard.isShadowRoot(root)) - return result; - /** - * 3. Let host be slot’s root’s host. - * 4. For each slotable child of host, slotable, in tree order: - */ - var host = root._host; - try { - for (var _b = __values(host._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var slotable = _c.value; - if (util_1.Guard.isSlotable(slotable)) { - /** - * 4.1. Let foundSlot be the result of finding a slot given slotable. - * 4.2. If foundSlot is slot, then append slotable to result. - */ - var foundSlot = shadowTree_findASlot(slotable); - if (foundSlot === slot) { - result.push(slotable); - } - } - } + if (!versionSpec) { + throw new Error('versionSpec parameter is required'); } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + arch = arch || os.arch(); + // attempt to resolve an explicit version + if (!_isExplicitVersion(versionSpec)) { + const localVersions = findAllVersions(toolName, arch); + const match = _evaluateVersions(localVersions, versionSpec); + versionSpec = match; + } + // check for the explicit version in the cache + let toolPath = ''; + if (versionSpec) { + versionSpec = semver.clean(versionSpec) || ''; + const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); + core.debug(`checking cache: ${cachePath}`); + if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { + core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + toolPath = cachePath; + } + else { + core.debug('not found'); } - finally { if (e_1) throw e_1.error; } } - /** - * 5. Return result. - */ - return result; + return toolPath; } -exports.shadowTree_findSlotables = shadowTree_findSlotables; +exports.find = find; /** - * Finds slotables for the given slot. + * Finds the paths to all versions of a tool that are installed in the local tool cache * - * @param slot - a slot + * @param toolName name of the tool + * @param arch optional arch. defaults to arch of computer */ -function shadowTree_findFlattenedSlotables(slot) { - var e_2, _a, e_3, _b; - /** - * 1. Let result be an empty list. - * 2. If slot’s root is not a shadow root, then return result. - */ - var result = []; - var root = TreeAlgorithm_1.tree_rootNode(slot); - if (!util_1.Guard.isShadowRoot(root)) - return result; - /** - * 3. Let slotables be the result of finding slotables given slot. - * 4. If slotables is the empty list, then append each slotable child of - * slot, in tree order, to slotables. - */ - var slotables = shadowTree_findSlotables(slot); - if (util_2.isEmpty(slotables)) { - try { - for (var _c = __values(slot._children), _d = _c.next(); !_d.done; _d = _c.next()) { - var slotable = _d.value; - if (util_1.Guard.isSlotable(slotable)) { - slotables.push(slotable); +function findAllVersions(toolName, arch) { + const versions = []; + arch = arch || os.arch(); + const toolPath = path.join(_getCacheDirectory(), toolName); + if (fs.existsSync(toolPath)) { + const children = fs.readdirSync(toolPath); + for (const child of children) { + if (_isExplicitVersion(child)) { + const fullPath = path.join(toolPath, child, arch || ''); + if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { + versions.push(child); } } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + return versions; +} +exports.findAllVersions = findAllVersions; +function getManifestFromRepo(owner, repo, auth, branch = 'master') { + return __awaiter(this, void 0, void 0, function* () { + let releases = []; + const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; + const http = new httpm.HttpClient('tool-cache'); + const headers = {}; + if (auth) { + core.debug('set auth'); + headers.authorization = auth; + } + const response = yield http.getJson(treeUrl, headers); + if (!response.result) { + return releases; + } + let manifestUrl = ''; + for (const item of response.result.tree) { + if (item.path === 'versions-manifest.json') { + manifestUrl = item.url; + break; } - finally { if (e_2) throw e_2.error; } } - } - try { - /** - * 5. For each node in slotables: - */ - for (var slotables_1 = __values(slotables), slotables_1_1 = slotables_1.next(); !slotables_1_1.done; slotables_1_1 = slotables_1.next()) { - var node = slotables_1_1.value; - /** - * 5.1. If node is a slot whose root is a shadow root, then: - */ - if (util_1.Guard.isSlot(node) && util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(node))) { - /** - * 5.1.1. Let temporaryResult be the result of finding flattened slotables given node. - * 5.1.2. Append each slotable in temporaryResult, in order, to result. - */ - var temporaryResult = shadowTree_findFlattenedSlotables(node); - result.push.apply(result, __spread(temporaryResult)); + headers['accept'] = 'application/vnd.github.VERSION.raw'; + let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); + if (versionsRaw) { + // shouldn't be needed but protects against invalid json saved with BOM + versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); + try { + releases = JSON.parse(versionsRaw); } - else { - /** - * 5.2. Otherwise, append node to result. - */ - result.push(node); + catch (_a) { + core.debug('Invalid json'); } } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (slotables_1_1 && !slotables_1_1.done && (_b = slotables_1.return)) _b.call(slotables_1); + return releases; + }); +} +exports.getManifestFromRepo = getManifestFromRepo; +function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { + return __awaiter(this, void 0, void 0, function* () { + // wrap the internal impl + const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); + return match; + }); +} +exports.findFromManifest = findFromManifest; +function _createExtractFolder(dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!dest) { + // create a temp dir + dest = path.join(_getTempDirectory(), v4_1.default()); } - finally { if (e_3) throw e_3.error; } - } - /** - * 6. Return result. - */ - return result; + yield io.mkdirP(dest); + return dest; + }); } -exports.shadowTree_findFlattenedSlotables = shadowTree_findFlattenedSlotables; -/** - * Assigns slotables to the given slot. - * - * @param slot - a slot - */ -function shadowTree_assignSlotables(slot) { - var e_4, _a; - /** - * 1. Let slotables be the result of finding slotables for slot. - * 2. If slotables and slot’s assigned nodes are not identical, then run - * signal a slot change for slot. - */ - var slotables = shadowTree_findSlotables(slot); - if (slotables.length === slot._assignedNodes.length) { - var nodesIdentical = true; - for (var i = 0; i < slotables.length; i++) { - if (slotables[i] !== slot._assignedNodes[i]) { - nodesIdentical = false; - break; - } +function _createToolPath(tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + core.debug(`destination ${folderPath}`); + const markerPath = `${folderPath}.complete`; + yield io.rmRF(folderPath); + yield io.rmRF(markerPath); + yield io.mkdirP(folderPath); + return folderPath; + }); +} +function _completeToolPath(tool, version, arch) { + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + const markerPath = `${folderPath}.complete`; + fs.writeFileSync(markerPath, ''); + core.debug('finished caching tool'); +} +function _isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec) || ''; + core.debug(`isExplicit: ${c}`); + const valid = semver.valid(c) != null; + core.debug(`explicit? ${valid}`); + return valid; +} +function _evaluateVersions(versions, versionSpec) { + let version = ''; + core.debug(`evaluating ${versions.length} versions`); + versions = versions.sort((a, b) => { + if (semver.gt(a, b)) { + return 1; } - if (!nodesIdentical) { - shadowTree_signalASlotChange(slot); + return -1; + }); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version = potential; + break; } } - /** - * 3. Set slot’s assigned nodes to slotables. - * 4. For each slotable in slotables, set slotable’s assigned slot to slot. - */ - slot._assignedNodes = slotables; - try { - for (var slotables_2 = __values(slotables), slotables_2_1 = slotables_2.next(); !slotables_2_1.done; slotables_2_1 = slotables_2.next()) { - var slotable = slotables_2_1.value; - slotable._assignedSlot = slot; - } + if (version) { + core.debug(`matched: ${version}`); } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (slotables_2_1 && !slotables_2_1.done && (_a = slotables_2.return)) _a.call(slotables_2); - } - finally { if (e_4) throw e_4.error; } + else { + core.debug('match not found'); } + return version; } -exports.shadowTree_assignSlotables = shadowTree_assignSlotables; /** - * Assigns slotables to all nodes of a tree. - * - * @param root - root node + * Gets RUNNER_TOOL_CACHE */ -function shadowTree_assignSlotablesForATree(root) { - /** - * To assign slotables for a tree, given a node root, run assign slotables - * for each slot slot in root’s inclusive descendants, in tree order. - */ - var descendant = TreeAlgorithm_1.tree_getFirstDescendantNode(root, true, false, function (e) { return util_1.Guard.isSlot(e); }); - while (descendant !== null) { - shadowTree_assignSlotables(descendant); - descendant = TreeAlgorithm_1.tree_getNextDescendantNode(root, descendant, true, false, function (e) { return util_1.Guard.isSlot(e); }); - } +function _getCacheDirectory() { + const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; + assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); + return cacheDirectory; } -exports.shadowTree_assignSlotablesForATree = shadowTree_assignSlotablesForATree; /** - * Assigns a slot to a slotables. - * - * @param slotable - a slotable + * Gets RUNNER_TEMP */ -function shadowTree_assignASlot(slotable) { - /** - * 1. Let slot be the result of finding a slot with slotable. - * 2. If slot is non-null, then run assign slotables for slot. - */ - var slot = shadowTree_findASlot(slotable); - if (slot !== null) { - shadowTree_assignSlotables(slot); - } +function _getTempDirectory() { + const tempDirectory = process.env['RUNNER_TEMP'] || ''; + assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); + return tempDirectory; } -exports.shadowTree_assignASlot = shadowTree_assignASlot; -//# sourceMappingURL=ShadowTreeAlgorithm.js.map - -/***/ }), -/* 181 */ -/***/ (function(module) { - -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -const SEMVER_SPEC_VERSION = '2.0.0' - -const MAX_LENGTH = 256 -const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 - -// Max safe segment length for coercion. -const MAX_SAFE_COMPONENT_LENGTH = 16 - -module.exports = { - SEMVER_SPEC_VERSION, - MAX_LENGTH, - MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH +/** + * Gets a global variable + */ +function _getGlobal(key, defaultValue) { + /* eslint-disable @typescript-eslint/no-explicit-any */ + const value = global[key]; + /* eslint-enable @typescript-eslint/no-explicit-any */ + return value !== undefined ? value : defaultValue; } - +/** + * Returns an array of unique values. + * @param values Values to make unique. + */ +function _unique(values) { + return Array.from(new Set(values)); +} +//# sourceMappingURL=tool-cache.js.map /***/ }), -/* 182 */, -/* 183 */, -/* 184 */, -/* 185 */, -/* 186 */, /* 187 */, /* 188 */, /* 189 */, @@ -13861,7 +13858,7 @@ const base_installer_1 = __webpack_require__(83); const semver_1 = __importDefault(__webpack_require__(876)); const util_1 = __webpack_require__(322); const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); class MicrosoftDistributions extends base_installer_1.JavaBase { @@ -15207,7 +15204,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 { @@ -18764,13 +18762,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__webpack_require__(87)); const path_1 = __importDefault(__webpack_require__(622)); const fs = __importStar(__webpack_require__(747)); const semver = __importStar(__webpack_require__(876)); +const cache = __importStar(__webpack_require__(692)); const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const constants_1 = __webpack_require__(211); function getTempDir() { let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); @@ -18841,6 +18840,24 @@ function isJobStatusSuccess() { return jobStatus === 'success'; } exports.isJobStatusSuccess = isJobStatusSuccess; +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), @@ -28720,7 +28737,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.TemurinDistribution = exports.TemurinImplementation = void 0; const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); const semver_1 = __importDefault(__webpack_require__(876)); @@ -37603,7 +37620,7 @@ exports.document_adopt = document_adopt; /* 494 */ /***/ (function(module, __unusedexports, __webpack_require__) { -var rng = __webpack_require__(58); +var rng = __webpack_require__(139); var bytesToUuid = __webpack_require__(722); function v4(options, buf, offset) { @@ -38471,7 +38488,7 @@ const base_installer_1 = __webpack_require__(83); const semver_1 = __importDefault(__webpack_require__(876)); const util_1 = __webpack_require__(322); const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); const supportedPlatform = `'linux', 'linux-musl', 'macos', 'solaris', 'windows'`; @@ -44851,7 +44868,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.AdoptDistribution = exports.AdoptImplementation = void 0; const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); const semver_1 = __importDefault(__webpack_require__(876)); @@ -53946,6 +53963,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 * @@ -60015,7 +60041,7 @@ function run() { const matchersPath = path.join(__dirname, '..', '..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); yield auth.configureAuthentication(); - if (cache) { + if (cache && util_1.isCacheFeatureAvailable()) { yield cache_1.restore(cache); } } @@ -88268,7 +88294,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.ZuluDistribution = void 0; const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); +const tc = __importStar(__webpack_require__(186)); const path_1 = __importDefault(__webpack_require__(622)); const fs_1 = __importDefault(__webpack_require__(747)); const semver_1 = __importDefault(__webpack_require__(876)); @@ -99020,7 +99046,7 @@ exports.checkBypass = checkBypass; /* 953 */ /***/ (function(module, __unusedexports, __webpack_require__) { -var rng = __webpack_require__(58); +var rng = __webpack_require__(139); var bytesToUuid = __webpack_require__(722); // **`v1()` - Generate time-based UUID** diff --git a/package-lock.json b/package-lock.json index 9a2c16dcd..0589fcc9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "setup-java", - "version": "2.0.0", + "version": "3.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-java", - "version": "2.0.0", + "version": "3.1.0", "license": "MIT", "dependencies": { - "@actions/cache": "^1.0.8", + "@actions/cache": "^2.0.0", "@actions/core": "^1.2.6", "@actions/exec": "^1.0.4", "@actions/glob": "^0.2.0", @@ -32,17 +32,17 @@ } }, "node_modules/@actions/cache": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", - "integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", + "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "dependencies": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^1.0.9", "@actions/io": "^1.0.1", - "@azure/ms-rest-js": "^2.0.7", - "@azure/storage-blob": "^12.1.2", + "@azure/ms-rest-js": "^2.6.0", + "@azure/storage-blob": "^12.8.0", "semver": "^6.1.0", "uuid": "^3.3.3" } @@ -6662,17 +6662,17 @@ }, "dependencies": { "@actions/cache": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-1.0.8.tgz", - "integrity": "sha512-GWNNB67w93HGJRQXlsV56YqrdAuDoP3esK/mo5mzU8WoDCVjtQgJGsTdkYUX7brswtT7xnI30bWNo1WLKQ8FZQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.0.tgz", + "integrity": "sha512-d7n8ul6HjWX6oDrNEPoqn8ZvqyyDhp9Uek6WOxALyxGVsXU+8+ND+viD3UfrXVWfs/GQiqI5Eq4cOozZj0yRFQ==", "requires": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^1.0.9", "@actions/io": "^1.0.1", - "@azure/ms-rest-js": "^2.0.7", - "@azure/storage-blob": "^12.1.2", + "@azure/ms-rest-js": "^2.6.0", + "@azure/storage-blob": "^12.8.0", "semver": "^6.1.0", "uuid": "^3.3.3" }, diff --git a/package.json b/package.json index 8bcf9356d..890112152 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-java", - "version": "2.0.0", + "version": "3.1.0", "private": true, "description": "setup java action", "main": "dist/setup/index.js", @@ -24,7 +24,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^1.0.8", + "@actions/cache": "^2.0.0", "@actions/core": "^1.2.6", "@actions/exec": "^1.0.4", "@actions/glob": "^0.2.0", diff --git a/src/setup-java.ts b/src/setup-java.ts index c6b12875f..8274be938 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core'; import * as auth from './auth'; -import { getBooleanInput } from './util'; +import { getBooleanInput, isCacheFeatureAvailable } from './util'; import * as constants from './constants'; import { restore } from './cache'; import * as path from 'path'; @@ -42,7 +42,7 @@ async function run() { core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); await auth.configureAuthentication(); - if (cache) { + if (cache && isCacheFeatureAvailable()) { await restore(cache); } } catch (error) { diff --git a/src/util.ts b/src/util.ts index 588b3624a..10f18c5fe 100644 --- a/src/util.ts +++ b/src/util.ts @@ -2,6 +2,7 @@ import os from 'os'; import path from 'path'; import * as fs from 'fs'; import * as semver from 'semver'; +import * as cache from '@actions/cache'; import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; @@ -77,3 +78,24 @@ export function isJobStatusSuccess() { return jobStatus === 'success'; } + +export function isGhes(): boolean { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} + +export function isCacheFeatureAvailable(): boolean { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error( + 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' + ); + } else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + + return false; + } + + return true; +}