@@ -30840,7 +30840,7 @@ const DISTRIBUTIONS_ONLY_MAJOR_VERSION = (/* unused pure expression or super */
3084030840/* harmony export */ Vt: () => (/* binding */ getBooleanInput),
3084130841/* harmony export */ lN: () => (/* binding */ isJdkCacheEnabled)
3084230842/* harmony export */ });
30843- /* unused harmony exports getVersionFromToolcachePath, extractJdkFile, getDownloadArchiveExtension, isVersionSatisfies, getToolcachePath, isGhes, getVersionFromFileContent, convertVersionToSemver, getGitHubHttpHeaders, MAX_PAGINATION_PAGES, getNextPageUrlFromLinkHeader, validatePaginationUrl, renameWinArchive, getLatestMajorVersion */
30843+ /* unused harmony exports getVersionFromToolcachePath, extractJdkFile, cacheJdkDir, getDownloadArchiveExtension, isVersionSatisfies, getToolcachePath, isGhes, getVersionFromFileContent, convertVersionToSemver, getGitHubHttpHeaders, MAX_PAGINATION_PAGES, getNextPageUrlFromLinkHeader, validatePaginationUrl, renameWinArchive, getLatestMajorVersion */
3084430844/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(857);
3084530845/* harmony import */ var os__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(os__WEBPACK_IMPORTED_MODULE_0__);
3084630846/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(6928);
@@ -30851,7 +30851,14 @@ const DISTRIBUTIONS_ONLY_MAJOR_VERSION = (/* unused pure expression or super */
3085130851/* harmony import */ var semver__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(semver__WEBPACK_IMPORTED_MODULE_3__);
3085230852/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(3838);
3085330853/* harmony import */ var _actions_tool_cache__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(9805);
30854- /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(7242);
30854+ /* harmony import */ var _actions_exec__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(5260);
30855+ /* harmony import */ var _actions_io__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(8701);
30856+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(6982);
30857+ /* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__nccwpck_require__.n(crypto__WEBPACK_IMPORTED_MODULE_8__);
30858+ /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(7242);
30859+
30860+
30861+
3085530862
3085630863
3085730864
@@ -30878,8 +30885,8 @@ function getBooleanInput(inputName, defaultValue = false) {
3087830885 throw new Error(`Invalid value '${inputValue}' for boolean input '${inputName}'. Expected 'true' or 'false'.`);
3087930886}
3088030887function isJdkCacheEnabled(cache) {
30881- return _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_6__ /* .INPUT_CACHE_JDK */ .GL).trim()
30882- ? getBooleanInput(_constants_js__WEBPACK_IMPORTED_MODULE_6__ /* .INPUT_CACHE_JDK */ .GL)
30888+ return _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_9__ /* .INPUT_CACHE_JDK */ .GL).trim()
30889+ ? getBooleanInput(_constants_js__WEBPACK_IMPORTED_MODULE_9__ /* .INPUT_CACHE_JDK */ .GL)
3088330890 : Boolean(cache.trim());
3088430891}
3088530892function getVersionFromToolcachePath(toolPath) {
@@ -30899,14 +30906,116 @@ async function extractJdkFile(toolPath, extension) {
3089930906 }
3090030907 switch (extension) {
3090130908 case 'tar.gz':
30909+ return await extractTarGz(toolPath);
3090230910 case 'tar':
3090330911 return await tc.extractTar(toolPath);
3090430912 case 'zip':
30905- return await tc.extractZip (toolPath);
30913+ return await extractZipArchive (toolPath);
3090630914 default:
3090730915 return await tc.extract7z(toolPath);
3090830916 }
3090930917}
30918+ async function createExtractFolder() {
30919+ const dest = path.join(getTempDir(), randomUUID());
30920+ await io.mkdirP(dest);
30921+ return dest;
30922+ }
30923+ /**
30924+ * Decompressing a JDK tarball with the default single-threaded gzip is one of the
30925+ * slowest parts of the install, so hand the decompression to `pigz` when the runner
30926+ * provides it. Any failure falls back to the stock extraction.
30927+ */
30928+ async function extractTarGz(toolPath) {
30929+ const pigzPath = await io.which('pigz');
30930+ // tar splits --use-compress-program on whitespace, so a path containing a
30931+ // space would be word-split into a bogus command.
30932+ if (pigzPath && !/\s/.test(pigzPath)) {
30933+ const dest = await createExtractFolder();
30934+ try {
30935+ return await tc.extractTar(toolPath, dest, [
30936+ '--use-compress-program',
30937+ `${pigzPath} -d`,
30938+ '-x'
30939+ ]);
30940+ }
30941+ catch (error) {
30942+ await io.rmRF(dest);
30943+ core.debug(`Failed to extract '${toolPath}' with pigz, falling back to gzip: ${getErrorMessage(error)}`);
30944+ }
30945+ }
30946+ return await tc.extractTar(toolPath);
30947+ }
30948+ /**
30949+ * `tc.extractZip` shells out to PowerShell's `Expand-Archive` on Windows, which is
30950+ * several times slower than the bundled bsdtar. Prefer `tar.exe` and fall back to
30951+ * the stock extraction when it is unavailable or fails.
30952+ */
30953+ async function extractZipArchive(toolPath) {
30954+ if (process.platform === 'win32') {
30955+ const systemTar = path.join(process.env['SystemRoot'] || 'C:\\Windows', 'System32', 'tar.exe');
30956+ if (fs.existsSync(systemTar)) {
30957+ const dest = await createExtractFolder();
30958+ try {
30959+ await exec.exec(`"${systemTar}"`, ['-xf', toolPath, '-C', dest], {
30960+ silent: true
30961+ });
30962+ return dest;
30963+ }
30964+ catch (error) {
30965+ await io.rmRF(dest);
30966+ core.debug(`Failed to extract '${toolPath}' with tar.exe, falling back to Expand-Archive: ${getErrorMessage(error)}`);
30967+ }
30968+ }
30969+ }
30970+ return await tc.extractZip(toolPath);
30971+ }
30972+ /**
30973+ * Equivalent of `tc.cacheDir`, but moves the extracted JDK into the tool-cache
30974+ * instead of copying it. `tc.cacheDir` recursively copies the whole tree, which
30975+ * means a several hundred megabyte JDK is written to disk twice. The extraction
30976+ * directory and the tool-cache normally live on the same filesystem, so a rename
30977+ * is effectively free. Anything unexpected (a different filesystem, or a file
30978+ * handle held open by anti-virus software on Windows) falls back to the copy.
30979+ */
30980+ async function cacheJdkDir(sourceDir, toolName, version, architecture) {
30981+ const destPath = getToolcacheDestination(toolName, version, architecture);
30982+ if (destPath) {
30983+ let moved = false;
30984+ try {
30985+ // lstat, not stat: renaming a symlinked source would put the link itself
30986+ // in the tool-cache, leaving a dangling JAVA_HOME once RUNNER_TEMP is
30987+ // cleaned. tc.cacheDir dereferences it, so let it handle that case.
30988+ if (fs.lstatSync(sourceDir).isDirectory()) {
30989+ await io.rmRF(destPath);
30990+ await io.rmRF(`${destPath}.complete`);
30991+ await io.mkdirP(path.dirname(destPath));
30992+ // Renaming is atomic, so a failure here leaves sourceDir untouched and
30993+ // the copy-based fallback below can still run.
30994+ fs.renameSync(sourceDir, destPath);
30995+ moved = true;
30996+ }
30997+ }
30998+ catch (error) {
30999+ core.debug(`Failed to move '${sourceDir}' into the tool-cache, falling back to a copy: ${getErrorMessage(error)}`);
31000+ }
31001+ if (moved) {
31002+ fs.writeFileSync(`${destPath}.complete`, '');
31003+ return destPath;
31004+ }
31005+ }
31006+ return await tc.cacheDir(sourceDir, toolName, version, architecture);
31007+ }
31008+ function getToolcacheDestination(toolName, version, architecture) {
31009+ const toolcacheRoot = process.env['RUNNER_TOOL_CACHE'];
31010+ if (!toolcacheRoot) {
31011+ return null;
31012+ }
31013+ // Mirrors the destination layout used by `tc.cacheDir`.
31014+ return path.join(toolcacheRoot, toolName, semver.clean(version) || version, architecture || os.arch());
31015+ }
31016+ function getErrorMessage(error) {
31017+ return error instanceof Error ? error.message : String(error);
31018+ }
3091031019function getDownloadArchiveExtension() {
3091131020 return process.platform === 'win32' ? 'zip' : 'tar.gz';
3091231021}
@@ -30938,7 +31047,7 @@ function getToolcachePath(toolName, version, architecture) {
3093831047 return null;
3093931048}
3094031049function isJobStatusSuccess() {
30941- const jobStatus = _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_6__ /* .INPUT_JOB_STATUS */ .wG);
31050+ const jobStatus = _actions_core__WEBPACK_IMPORTED_MODULE_4__/* .getInput */ .V4(_constants_js__WEBPACK_IMPORTED_MODULE_9__ /* .INPUT_JOB_STATUS */ .wG);
3094231051 return jobStatus === 'success';
3094331052}
3094431053function isGhes() {
0 commit comments