From c2b33cd7843124caa22781c5f63a9e90cf0f18dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 30 May 2021 16:37:33 +0200 Subject: [PATCH] chore(deps): bump @actions/tool-cache from 1.6.1 to 1.7.0 (#286) * chore(deps): bump @actions/tool-cache from 1.6.1 to 1.7.0 Bumps [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache) from 1.6.1 to 1.7.0. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/main/packages/tool-cache/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/tool-cache) Signed-off-by: dependabot[bot] * Update generated content Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: CrazyMax --- dist/index.js | 179 +++++++++++++++++++++++++++++++++++++------------- package.json | 2 +- yarn.lock | 8 +-- 3 files changed, 137 insertions(+), 52 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1fed5dfd..0f31391c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2656,6 +2656,25 @@ function copyFile(srcFile, destFile, force) { "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.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) { @@ -2665,14 +2684,8 @@ 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; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports._readLinuxVersionFile = exports._getOsVersion = exports._findMatch = void 0; const semver = __importStar(__webpack_require__(562)); const core_1 = __webpack_require__(186); // needs to be require for core node modules to be mocked @@ -2769,6 +2782,25 @@ exports._readLinuxVersionFile = _readLinuxVersionFile; "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.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) { @@ -2778,14 +2810,8 @@ 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; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.RetryHelper = void 0; const core = __importStar(__webpack_require__(186)); /** * Internal class for retries @@ -2846,6 +2872,25 @@ exports.RetryHelper = RetryHelper; "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.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) { @@ -2855,17 +2900,11 @@ 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.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0; const core = __importStar(__webpack_require__(186)); const io = __importStar(__webpack_require__(351)); const fs = __importStar(__webpack_require__(747)); @@ -2897,9 +2936,10 @@ const userAgent = 'actions/tool-cache'; * @param url url of tool to download * @param dest path to download tool * @param auth authorization header + * @param headers other headers * @returns path to downloaded tool */ -function downloadTool(url, dest, auth) { +function downloadTool(url, dest, auth, headers) { return __awaiter(this, void 0, void 0, function* () { dest = dest || path.join(_getTempDirectory(), v4_1.default()); yield io.mkdirP(path.dirname(dest)); @@ -2910,7 +2950,7 @@ function downloadTool(url, dest, auth) { 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); + return yield downloadToolAttempt(url, dest || '', auth, headers); }), (err) => { if (err instanceof HTTPError && err.httpStatusCode) { // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests @@ -2926,7 +2966,7 @@ function downloadTool(url, dest, auth) { }); } exports.downloadTool = downloadTool; -function downloadToolAttempt(url, dest, auth) { +function downloadToolAttempt(url, dest, auth, headers) { return __awaiter(this, void 0, void 0, function* () { if (fs.existsSync(dest)) { throw new Error(`Destination file path ${dest} already exists`); @@ -2935,12 +2975,12 @@ function downloadToolAttempt(url, dest, auth) { const http = new httpm.HttpClient(userAgent, [], { allowRetries: false }); - let headers; if (auth) { core.debug('set auth'); - headers = { - authorization: auth - }; + if (headers === undefined) { + headers = {}; + } + headers.authorization = auth; } const response = yield http.get(url, headers); if (response.message.statusCode !== 200) { @@ -3098,6 +3138,7 @@ function extractTar(file, dest, flags = 'xz') { if (isGnuTar) { // Suppress warnings when using GNU tar to extract archives created by BSD tar args.push('--warning=no-unknown-keyword'); + args.push('--overwrite'); } args.push('-C', destArg, '-f', fileArg); yield exec_1.exec(`tar`, args); @@ -3163,20 +3204,50 @@ function extractZipWin(file, dest) { // 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); + const pwshPath = yield io.which('pwsh', false); + //To match the file overwrite behavior on nix systems, we use the overwrite = true flag for ExtractToDirectory + //and the -Force flag for Expand-Archive as a fallback + if (pwshPath) { + //attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive + const pwshCommand = [ + `$ErrorActionPreference = 'Stop' ;`, + `try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`, + `try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`, + `catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;` + ].join(' '); + const args = [ + '-NoLogo', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + pwshCommand + ]; + core.debug(`Using pwsh at path: ${pwshPath}`); + yield exec_1.exec(`"${pwshPath}"`, args); + } + else { + const powershellCommand = [ + `$ErrorActionPreference = 'Stop' ;`, + `try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`, + `if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`, + `else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }` + ].join(' '); + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + powershellCommand + ]; + const powershellPath = yield io.which('powershell', true); + core.debug(`Using powershell at path: ${powershellPath}`); + yield exec_1.exec(`"${powershellPath}"`, args); + } }); } function extractZipNix(file, dest) { @@ -3186,6 +3257,7 @@ function extractZipNix(file, dest) { if (!core.isDebug()) { args.unshift('-q'); } + args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); }); } @@ -3268,9 +3340,9 @@ function find(toolName, versionSpec, arch) { } arch = arch || os.arch(); // attempt to resolve an explicit version - if (!_isExplicitVersion(versionSpec)) { + if (!isExplicitVersion(versionSpec)) { const localVersions = findAllVersions(toolName, arch); - const match = _evaluateVersions(localVersions, versionSpec); + const match = evaluateVersions(localVersions, versionSpec); versionSpec = match; } // check for the explicit version in the cache @@ -3303,7 +3375,7 @@ function findAllVersions(toolName, arch) { if (fs.existsSync(toolPath)) { const children = fs.readdirSync(toolPath); for (const child of children) { - if (_isExplicitVersion(child)) { + if (isExplicitVersion(child)) { const fullPath = path.join(toolPath, child, arch || ''); if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { versions.push(child); @@ -3386,14 +3458,26 @@ function _completeToolPath(tool, version, arch) { fs.writeFileSync(markerPath, ''); core.debug('finished caching tool'); } -function _isExplicitVersion(versionSpec) { +/** + * Check if version string is explicit + * + * @param versionSpec version string to check + */ +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) { +exports.isExplicitVersion = isExplicitVersion; +/** + * Get the highest satisfiying semantic version in `versions` which satisfies `versionSpec` + * + * @param versions array of versions to evaluate + * @param versionSpec semantic version spec to satisfy + */ +function evaluateVersions(versions, versionSpec) { let version = ''; core.debug(`evaluating ${versions.length} versions`); versions = versions.sort((a, b) => { @@ -3418,6 +3502,7 @@ function _evaluateVersions(versions, versionSpec) { } return version; } +exports.evaluateVersions = evaluateVersions; /** * Gets RUNNER_TOOL_CACHE */ diff --git a/package.json b/package.json index 126f56d7..26dfd9ad 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@actions/core": "^1.3.0", "@actions/exec": "^1.0.4", "@actions/http-client": "^1.0.11", - "@actions/tool-cache": "^1.6.1" + "@actions/tool-cache": "^1.7.0" }, "devDependencies": { "@types/jest": "^26.0.14", diff --git a/yarn.lock b/yarn.lock index 2bfdf473..c25893a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -26,10 +26,10 @@ resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.2.tgz#2f614b6e69ce14d191180451eb38e6576a6e6b27" integrity sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg== -"@actions/tool-cache@^1.6.1": - version "1.6.1" - resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.6.1.tgz#5e199f7bfd9863eb2b0d467cd70751ef8042ec40" - integrity sha512-F+vwEDwfqcHMKuSkj79pihOnsAMv23EkG76nMpc82UsnXwyQdyEsktGxrB0SNtm7pRqTXEIOoAPTgrSQclXYTg== +"@actions/tool-cache@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.7.0.tgz#bd9d5996d8cd3c50b61b8d6d1c3fb134e962cc21" + integrity sha512-ybO7s67MueJVwWGP4kLynzjW/4Rsiy5/RD9+XJsi/8JHbmYjXdBiluuJdwanQOsmQvZJRe8OkNzaLEnLuMu+qA== dependencies: "@actions/core" "^1.2.6" "@actions/exec" "^1.0.0"