From 7e403af8c53c3abd3b63daba785f01184d9d2fae Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 12 Oct 2022 16:18:54 +0200 Subject: [PATCH 01/17] Revert cache index.js --- dist/setup/index.js | 191 ++++++++++++++++---------------------------- src/install-pypy.ts | 6 +- 2 files changed, 74 insertions(+), 123 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index d92820713..16fc0c5f9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -525,13 +525,7 @@ function resolvePaths(patterns) { .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); core.debug(`Matched: ${relativeFile}`); // Paths are made relative so the tar entries are all relative to the root of the workspace. - if (relativeFile === '') { - // path.relative returns empty string if workspace and file are equal - paths.push('.'); - } - else { - paths.push(`${relativeFile}`); - } + paths.push(`${relativeFile}`); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -689,7 +683,6 @@ const util = __importStar(__nccwpck_require__(3837)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); const requestUtils_1 = __nccwpck_require__(3981); -const abort_controller_1 = __nccwpck_require__(2557); /** * Pipes the body of a HTTP response to a stream * @@ -873,24 +866,15 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { const fd = fs.openSync(archivePath, 'w'); try { downloadProgress.startDisplayTimer(); - const controller = new abort_controller_1.AbortController(); - const abortSignal = controller.signal; while (!downloadProgress.isDone()) { const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); downloadProgress.nextSegment(segmentSize); - const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, { - abortSignal, + const result = yield client.downloadToBuffer(segmentStart, segmentSize, { concurrency: options.downloadConcurrency, onProgress: downloadProgress.onProgress() - })); - if (result === 'timeout') { - controller.abort(); - throw new Error('Aborting cache download as the download time exceeded the timeout.'); - } - else if (Buffer.isBuffer(result)) { - fs.writeFileSync(fd, result); - } + }); + fs.writeFileSync(fd, result); } } finally { @@ -901,16 +885,6 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { }); } exports.downloadCacheStorageSDK = downloadCacheStorageSDK; -const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () { - let timeoutHandle; - const timeoutPromise = new Promise(resolve => { - timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs); - }); - return Promise.race([promise, timeoutPromise]).then(result => { - clearTimeout(timeoutHandle); - return result; - }); -}); //# sourceMappingURL=downloadUtils.js.map /***/ }), @@ -1070,7 +1044,6 @@ const fs_1 = __nccwpck_require__(7147); const path = __importStar(__nccwpck_require__(1017)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); -const IS_WINDOWS = process.platform === 'win32'; function getTarPath(args, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { switch (process.platform) { @@ -1118,43 +1091,26 @@ function getWorkingDirectory() { var _a; return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); } -// Common function for extractTar and listTar to get the compression method -function getCompressionProgram(compressionMethod) { - // -d: Decompress. - // unzstd is equivalent to 'zstd -d' - // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return [ - '--use-compress-program', - IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' - ]; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; - default: - return ['-z']; - } -} -function listTar(archivePath, compressionMethod) { - return __awaiter(this, void 0, void 0, function* () { - const args = [ - ...getCompressionProgram(compressionMethod), - '-tf', - archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), - '-P' - ]; - yield execTar(args, compressionMethod); - }); -} -exports.listTar = listTar; function extractTar(archivePath, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); + // --d: Decompress. + // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + function getCompressionProgram() { + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return ['--use-compress-program', 'zstd -d --long=30']; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', 'zstd -d']; + default: + return ['-z']; + } + } const args = [ - ...getCompressionProgram(compressionMethod), + ...getCompressionProgram(), '-xf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', @@ -1173,19 +1129,15 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); const workingDirectory = getWorkingDirectory(); // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores. - // zstdmt is equivalent to 'zstd -T0' // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // Using 30 here because we also support 32-bit self-hosted runners. // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd. function getCompressionProgram() { switch (compressionMethod) { case constants_1.CompressionMethod.Zstd: - return [ - '--use-compress-program', - IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' - ]; + return ['--use-compress-program', 'zstd -T0 --long=30']; case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; + return ['--use-compress-program', 'zstd -T0']; default: return ['-z']; } @@ -1207,6 +1159,32 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { }); } exports.createTar = createTar; +function listTar(archivePath, compressionMethod) { + return __awaiter(this, void 0, void 0, function* () { + // --d: Decompress. + // --long=#: Enables long distance matching with # bits. + // Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + function getCompressionProgram() { + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return ['--use-compress-program', 'zstd -d --long=30']; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', 'zstd -d']; + default: + return ['-z']; + } + } + const args = [ + ...getCompressionProgram(), + '-tf', + archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), + '-P' + ]; + yield execTar(args, compressionMethod); + }); +} +exports.listTar = listTar; //# sourceMappingURL=tar.js.map /***/ }), @@ -1257,8 +1235,7 @@ function getDownloadOptions(copy) { const result = { useAzureSdk: true, downloadConcurrency: 8, - timeoutInMs: 30000, - segmentTimeoutInMs: 3600000 + timeoutInMs: 30000 }; if (copy) { if (typeof copy.useAzureSdk === 'boolean') { @@ -1270,21 +1247,10 @@ function getDownloadOptions(copy) { if (typeof copy.timeoutInMs === 'number') { result.timeoutInMs = copy.timeoutInMs; } - if (typeof copy.segmentTimeoutInMs === 'number') { - result.segmentTimeoutInMs = copy.segmentTimeoutInMs; - } - } - const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']; - if (segmentDownloadTimeoutMins && - !isNaN(Number(segmentDownloadTimeoutMins)) && - isFinite(Number(segmentDownloadTimeoutMins))) { - result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000; } core.debug(`Use Azure SDK: ${result.useAzureSdk}`); core.debug(`Download concurrency: ${result.downloadConcurrency}`); core.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`); - core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); return result; } exports.getDownloadOptions = getDownloadOptions; @@ -4865,6 +4831,7 @@ const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); +const uuid_1 = __nccwpck_require__(8974); const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action @@ -4894,9 +4861,20 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. + if (name.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedVal.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); } - command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -4914,7 +4892,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueFileCommand('PATH', inputPath); + file_command_1.issueCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -4954,10 +4932,7 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - if (options && options.trimWhitespace === false) { - return inputs; - } - return inputs.map(input => input.trim()); + return inputs; } exports.getMultilineInput = getMultilineInput; /** @@ -4990,12 +4965,8 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { - const filePath = process.env['GITHUB_OUTPUT'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); - } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; /** @@ -5124,11 +5095,7 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - const filePath = process.env['GITHUB_STATE'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); - } - command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('save-state', { name }, value); } exports.saveState = saveState; /** @@ -5194,14 +5161,13 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; +exports.issueCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); -const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueFileCommand(command, message) { +function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -5213,22 +5179,7 @@ function issueFileCommand(command, message) { encoding: 'utf8' }); } -exports.issueFileCommand = issueFileCommand; -function prepareKeyValueMessage(key, value) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - const convertedValue = utils_1.toCommandValue(value); - // These should realistically never happen, but just in case someone finds a - // way to exploit uuid generation let's not allow keys or values that contain - // the delimiter. - if (key.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedValue.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; -} -exports.prepareKeyValueMessage = prepareKeyValueMessage; +exports.issueCommand = issueCommand; //# sourceMappingURL=file-command.js.map /***/ }), @@ -66577,7 +66528,7 @@ function findRelease(releases, pythonVersion, pypyVersion, architecture) { semver.satisfies(pypyVersionToSemantic(item.pypy_version), pypyVersion); const isArchPresent = item.files && (utils_1.IS_WINDOWS - ? isArchPresentForWindows(item) + ? isArchPresentForWindows(item, architecture) : isArchPresentForMacOrLinux(item, architecture, process.platform)); return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent; }); @@ -66613,8 +66564,8 @@ function pypyVersionToSemantic(versionSpec) { return versionSpec.replace(prereleaseVersion, '$1-$2.$3'); } exports.pypyVersionToSemantic = pypyVersionToSemantic; -function isArchPresentForWindows(item) { - return item.files.some((file) => utils_1.WINDOWS_ARCHS.includes(file.arch) && +function isArchPresentForWindows(item, architecture) { + return item.files.some((file) => file.arch === (architecture === 'x32' ? 'x86' : architecture) && // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. utils_1.WINDOWS_PLATFORMS.includes(file.platform)); } exports.isArchPresentForWindows = isArchPresentForWindows; diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 4c49e1150..cf0ce13a0 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -157,7 +157,7 @@ export function findRelease( const isArchPresent = item.files && (IS_WINDOWS - ? isArchPresentForWindows(item) + ? isArchPresentForWindows(item, architecture) : isArchPresentForMacOrLinux(item, architecture, process.platform)); return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent; }); @@ -205,10 +205,10 @@ export function pypyVersionToSemantic(versionSpec: string) { return versionSpec.replace(prereleaseVersion, '$1-$2.$3'); } -export function isArchPresentForWindows(item: any) { +export function isArchPresentForWindows(item: any, architecture: string) { return item.files.some( (file: any) => - WINDOWS_ARCHS.includes(file.arch) && + file.arch === (architecture === 'x32' ? 'x86' : architecture) && // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. WINDOWS_PLATFORMS.includes(file.platform) ); } From de93cfa81c5c8834a994679c1e0fa139a8ae80f3 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 12 Oct 2022 16:21:41 +0200 Subject: [PATCH 02/17] build cache index file --- dist/cache-save/index.js | 185 ++++++++++++++------------------------- 1 file changed, 68 insertions(+), 117 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 09526eaf2..67b113908 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -525,13 +525,7 @@ function resolvePaths(patterns) { .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); core.debug(`Matched: ${relativeFile}`); // Paths are made relative so the tar entries are all relative to the root of the workspace. - if (relativeFile === '') { - // path.relative returns empty string if workspace and file are equal - paths.push('.'); - } - else { - paths.push(`${relativeFile}`); - } + paths.push(`${relativeFile}`); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -689,7 +683,6 @@ const util = __importStar(__nccwpck_require__(3837)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); const requestUtils_1 = __nccwpck_require__(3981); -const abort_controller_1 = __nccwpck_require__(2557); /** * Pipes the body of a HTTP response to a stream * @@ -873,24 +866,15 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { const fd = fs.openSync(archivePath, 'w'); try { downloadProgress.startDisplayTimer(); - const controller = new abort_controller_1.AbortController(); - const abortSignal = controller.signal; while (!downloadProgress.isDone()) { const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); downloadProgress.nextSegment(segmentSize); - const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, { - abortSignal, + const result = yield client.downloadToBuffer(segmentStart, segmentSize, { concurrency: options.downloadConcurrency, onProgress: downloadProgress.onProgress() - })); - if (result === 'timeout') { - controller.abort(); - throw new Error('Aborting cache download as the download time exceeded the timeout.'); - } - else if (Buffer.isBuffer(result)) { - fs.writeFileSync(fd, result); - } + }); + fs.writeFileSync(fd, result); } } finally { @@ -901,16 +885,6 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { }); } exports.downloadCacheStorageSDK = downloadCacheStorageSDK; -const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () { - let timeoutHandle; - const timeoutPromise = new Promise(resolve => { - timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs); - }); - return Promise.race([promise, timeoutPromise]).then(result => { - clearTimeout(timeoutHandle); - return result; - }); -}); //# sourceMappingURL=downloadUtils.js.map /***/ }), @@ -1070,7 +1044,6 @@ const fs_1 = __nccwpck_require__(7147); const path = __importStar(__nccwpck_require__(1017)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); -const IS_WINDOWS = process.platform === 'win32'; function getTarPath(args, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { switch (process.platform) { @@ -1118,43 +1091,26 @@ function getWorkingDirectory() { var _a; return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); } -// Common function for extractTar and listTar to get the compression method -function getCompressionProgram(compressionMethod) { - // -d: Decompress. - // unzstd is equivalent to 'zstd -d' - // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return [ - '--use-compress-program', - IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' - ]; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; - default: - return ['-z']; - } -} -function listTar(archivePath, compressionMethod) { - return __awaiter(this, void 0, void 0, function* () { - const args = [ - ...getCompressionProgram(compressionMethod), - '-tf', - archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), - '-P' - ]; - yield execTar(args, compressionMethod); - }); -} -exports.listTar = listTar; function extractTar(archivePath, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); + // --d: Decompress. + // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + function getCompressionProgram() { + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return ['--use-compress-program', 'zstd -d --long=30']; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', 'zstd -d']; + default: + return ['-z']; + } + } const args = [ - ...getCompressionProgram(compressionMethod), + ...getCompressionProgram(), '-xf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', @@ -1173,19 +1129,15 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); const workingDirectory = getWorkingDirectory(); // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores. - // zstdmt is equivalent to 'zstd -T0' // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // Using 30 here because we also support 32-bit self-hosted runners. // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd. function getCompressionProgram() { switch (compressionMethod) { case constants_1.CompressionMethod.Zstd: - return [ - '--use-compress-program', - IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' - ]; + return ['--use-compress-program', 'zstd -T0 --long=30']; case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; + return ['--use-compress-program', 'zstd -T0']; default: return ['-z']; } @@ -1207,6 +1159,32 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { }); } exports.createTar = createTar; +function listTar(archivePath, compressionMethod) { + return __awaiter(this, void 0, void 0, function* () { + // --d: Decompress. + // --long=#: Enables long distance matching with # bits. + // Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + function getCompressionProgram() { + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return ['--use-compress-program', 'zstd -d --long=30']; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', 'zstd -d']; + default: + return ['-z']; + } + } + const args = [ + ...getCompressionProgram(), + '-tf', + archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), + '-P' + ]; + yield execTar(args, compressionMethod); + }); +} +exports.listTar = listTar; //# sourceMappingURL=tar.js.map /***/ }), @@ -1257,8 +1235,7 @@ function getDownloadOptions(copy) { const result = { useAzureSdk: true, downloadConcurrency: 8, - timeoutInMs: 30000, - segmentTimeoutInMs: 3600000 + timeoutInMs: 30000 }; if (copy) { if (typeof copy.useAzureSdk === 'boolean') { @@ -1270,21 +1247,10 @@ function getDownloadOptions(copy) { if (typeof copy.timeoutInMs === 'number') { result.timeoutInMs = copy.timeoutInMs; } - if (typeof copy.segmentTimeoutInMs === 'number') { - result.segmentTimeoutInMs = copy.segmentTimeoutInMs; - } - } - const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']; - if (segmentDownloadTimeoutMins && - !isNaN(Number(segmentDownloadTimeoutMins)) && - isFinite(Number(segmentDownloadTimeoutMins))) { - result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000; } core.debug(`Use Azure SDK: ${result.useAzureSdk}`); core.debug(`Download concurrency: ${result.downloadConcurrency}`); core.debug(`Request timeout (ms): ${result.timeoutInMs}`); - core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`); - core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); return result; } exports.getDownloadOptions = getDownloadOptions; @@ -4865,6 +4831,7 @@ const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); +const uuid_1 = __nccwpck_require__(8974); const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action @@ -4894,9 +4861,20 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. + if (name.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedVal.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); } - command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -4914,7 +4892,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueFileCommand('PATH', inputPath); + file_command_1.issueCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -4954,10 +4932,7 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - if (options && options.trimWhitespace === false) { - return inputs; - } - return inputs.map(input => input.trim()); + return inputs; } exports.getMultilineInput = getMultilineInput; /** @@ -4990,12 +4965,8 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { - const filePath = process.env['GITHUB_OUTPUT'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); - } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('set-output', { name }, value); } exports.setOutput = setOutput; /** @@ -5124,11 +5095,7 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - const filePath = process.env['GITHUB_STATE'] || ''; - if (filePath) { - return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); - } - command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); + command_1.issueCommand('save-state', { name }, value); } exports.saveState = saveState; /** @@ -5194,14 +5161,13 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; +exports.issueCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); -const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueFileCommand(command, message) { +function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -5213,22 +5179,7 @@ function issueFileCommand(command, message) { encoding: 'utf8' }); } -exports.issueFileCommand = issueFileCommand; -function prepareKeyValueMessage(key, value) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - const convertedValue = utils_1.toCommandValue(value); - // These should realistically never happen, but just in case someone finds a - // way to exploit uuid generation let's not allow keys or values that contain - // the delimiter. - if (key.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedValue.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; -} -exports.prepareKeyValueMessage = prepareKeyValueMessage; +exports.issueCommand = issueCommand; //# sourceMappingURL=file-command.js.map /***/ }), From 5d1b76c2b891ed36dbeb0a0440b565cae64443b5 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 12 Oct 2022 16:24:39 +0200 Subject: [PATCH 03/17] Refactor --- dist/setup/index.js | 7 +++++-- src/install-pypy.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 16fc0c5f9..e49056d52 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66565,8 +66565,11 @@ function pypyVersionToSemantic(versionSpec) { } exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item, architecture) { - return item.files.some((file) => file.arch === (architecture === 'x32' ? 'x86' : architecture) && // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. - utils_1.WINDOWS_PLATFORMS.includes(file.platform)); + // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. + if (architecture === 'x32') { + architecture = 'x86'; + } + return item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); } exports.isArchPresentForWindows = isArchPresentForWindows; function isArchPresentForMacOrLinux(item, architecture, platform) { diff --git a/src/install-pypy.ts b/src/install-pypy.ts index cf0ce13a0..f945e1eda 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -206,10 +206,13 @@ export function pypyVersionToSemantic(versionSpec: string) { } export function isArchPresentForWindows(item: any, architecture: string) { + // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. + if (architecture === 'x32') { + architecture = 'x86'; + } return item.files.some( (file: any) => - file.arch === (architecture === 'x32' ? 'x86' : architecture) && // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. - WINDOWS_PLATFORMS.includes(file.platform) + file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) ); } From 29adb1aa300fca84649aeb92f84136359f0115cc Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:29:25 +0200 Subject: [PATCH 04/17] Debug --- dist/setup/index.js | 5 ++++- src/install-pypy.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index e49056d52..c12e89843 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66569,7 +66569,10 @@ function isArchPresentForWindows(item, architecture) { if (architecture === 'x32') { architecture = 'x86'; } - return item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, arch: ${item.files.arch}`); + const result = item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); + core.info(`result: ${result}`); + return result; } exports.isArchPresentForWindows = isArchPresentForWindows; function isArchPresentForMacOrLinux(item, architecture, platform) { diff --git a/src/install-pypy.ts b/src/install-pypy.ts index f945e1eda..13f401548 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -210,10 +210,13 @@ export function isArchPresentForWindows(item: any, architecture: string) { if (architecture === 'x32') { architecture = 'x86'; } - return item.files.some( + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, arch: ${item.files.arch}`) + const result = item.files.some( (file: any) => file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) ); + core.info(`result: ${result}`) + return result } export function isArchPresentForMacOrLinux( From 7bb5a4bb6110ccdf0f38695ec8d45097ae61c14a Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:34:59 +0200 Subject: [PATCH 05/17] Debug --- src/install-pypy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 13f401548..c259ca740 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -210,10 +210,12 @@ export function isArchPresentForWindows(item: any, architecture: string) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, arch: ${item.files.arch}`) + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}`) const result = item.files.some( - (file: any) => + (file: any) => { + core.info(`arch: ${file.arch}`); file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) + } ); core.info(`result: ${result}`) return result From 69f5a56bfcacd7f03ffa051e14a666b08b31c2b0 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:35:49 +0200 Subject: [PATCH 06/17] Debug --- dist/setup/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index c12e89843..23fba3011 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66569,8 +66569,11 @@ function isArchPresentForWindows(item, architecture) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, arch: ${item.files.arch}`); - const result = item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}`); + const result = item.files.some((file) => { + core.info(`arch: ${file.arch}`); + file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); + }); core.info(`result: ${result}`); return result; } From ae017779cb91e30dd28e3833674b3dc67c7f0526 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:41:31 +0200 Subject: [PATCH 07/17] Debug --- dist/setup/index.js | 2 +- src/install-pypy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 23fba3011..394b7a6a2 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66569,7 +66569,7 @@ function isArchPresentForWindows(item, architecture) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}`); + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, architecture: ${architecture}`); const result = item.files.some((file) => { core.info(`arch: ${file.arch}`); file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); diff --git a/src/install-pypy.ts b/src/install-pypy.ts index c259ca740..e1f04834e 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -210,7 +210,7 @@ export function isArchPresentForWindows(item: any, architecture: string) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}`) + core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, architecture: ${architecture}`) const result = item.files.some( (file: any) => { core.info(`arch: ${file.arch}`); From c139ac5ef6b0f0bd9bb6ec9cde866e852208e17d Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:46:25 +0200 Subject: [PATCH 08/17] Debug --- dist/setup/index.js | 4 +++- src/install-pypy.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 394b7a6a2..542233ca3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66572,7 +66572,9 @@ function isArchPresentForWindows(item, architecture) { core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, architecture: ${architecture}`); const result = item.files.some((file) => { core.info(`arch: ${file.arch}`); - file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); + const res = file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); + core.info(`res: ${res}`); + return res; }); core.info(`result: ${result}`); return result; diff --git a/src/install-pypy.ts b/src/install-pypy.ts index e1f04834e..077341406 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -214,7 +214,9 @@ export function isArchPresentForWindows(item: any, architecture: string) { const result = item.files.some( (file: any) => { core.info(`arch: ${file.arch}`); - file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) + const res = file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform); + core.info(`res: ${res}`); + return res; } ); core.info(`result: ${result}`) From ffca1d453bccc4bc0f58daa1e925d50619a46597 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:54:26 +0200 Subject: [PATCH 09/17] Debug --- dist/setup/index.js | 19 +++++++------------ src/install-pypy.ts | 20 +++++++------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 542233ca3..45fe94b75 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66541,7 +66541,7 @@ function findRelease(releases, pythonVersion, pypyVersion, architecture) { }); const foundRelease = sortedReleases[0]; const foundAsset = utils_1.IS_WINDOWS - ? findAssetForWindows(foundRelease) + ? findAssetForWindows(foundRelease, architecture) : findAssetForMacOrLinux(foundRelease, architecture, process.platform); return { foundAsset, @@ -66569,24 +66569,19 @@ function isArchPresentForWindows(item, architecture) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, architecture: ${architecture}`); - const result = item.files.some((file) => { - core.info(`arch: ${file.arch}`); - const res = file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); - core.info(`res: ${res}`); - return res; + return item.files.some((file) => { + return file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); }); - core.info(`result: ${result}`); - return result; } exports.isArchPresentForWindows = isArchPresentForWindows; function isArchPresentForMacOrLinux(item, architecture, platform) { return item.files.some((file) => file.arch === architecture && file.platform === platform); } exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; -function findAssetForWindows(releases) { - return releases.files.find((item) => utils_1.WINDOWS_ARCHS.includes(item.arch) && - utils_1.WINDOWS_PLATFORMS.includes(item.platform)); +function findAssetForWindows(releases, architecture) { + return releases.files.find((item) => { + return item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform); + }); } exports.findAssetForWindows = findAssetForWindows; function findAssetForMacOrLinux(releases, architecture, platform) { diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 077341406..a830f65ca 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -181,7 +181,7 @@ export function findRelease( const foundRelease = sortedReleases[0]; const foundAsset = IS_WINDOWS - ? findAssetForWindows(foundRelease) + ? findAssetForWindows(foundRelease, architecture) : findAssetForMacOrLinux(foundRelease, architecture, process.platform); return { @@ -210,17 +210,11 @@ export function isArchPresentForWindows(item: any, architecture: string) { if (architecture === 'x32') { architecture = 'x86'; } - core.info(`DEBUG: pypy: ${item.pypy_version}, python: ${item.python_version}, architecture: ${architecture}`) - const result = item.files.some( + return item.files.some( (file: any) => { - core.info(`arch: ${file.arch}`); - const res = file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform); - core.info(`res: ${res}`); - return res; + return file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform); } ); - core.info(`result: ${result}`) - return result } export function isArchPresentForMacOrLinux( @@ -233,11 +227,11 @@ export function isArchPresentForMacOrLinux( ); } -export function findAssetForWindows(releases: any) { +export function findAssetForWindows(releases: any, architecture: string) { return releases.files.find( - (item: any) => - WINDOWS_ARCHS.includes(item.arch) && - WINDOWS_PLATFORMS.includes(item.platform) + (item: any) => { + return item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform); + } ); } From 5041c3b04fc28b21b4b40e39de6350e23c0425bf Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 17:55:35 +0200 Subject: [PATCH 10/17] Debug --- dist/setup/index.js | 3 +++ src/install-pypy.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index 45fe94b75..86d83d2a3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66579,6 +66579,9 @@ function isArchPresentForMacOrLinux(item, architecture, platform) { } exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; function findAssetForWindows(releases, architecture) { + if (architecture === 'x32') { + architecture = 'x86'; + } return releases.files.find((item) => { return item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform); }); diff --git a/src/install-pypy.ts b/src/install-pypy.ts index a830f65ca..3ee6207d1 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -228,6 +228,9 @@ export function isArchPresentForMacOrLinux( } export function findAssetForWindows(releases: any, architecture: string) { + if (architecture === 'x32') { + architecture = 'x86'; + } return releases.files.find( (item: any) => { return item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform); From 82e58e0e69961656bfd9ca3d0eaaaeec7824191c Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 18:07:52 +0200 Subject: [PATCH 11/17] Debug --- dist/setup/index.js | 16 +++++++++------- src/install-pypy.ts | 17 ++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 86d83d2a3..569bc1616 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66565,10 +66565,7 @@ function pypyVersionToSemantic(versionSpec) { } exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item, architecture) { - // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. - if (architecture === 'x32') { - architecture = 'x86'; - } + architecture = ReplaceX32toX86(architecture); return item.files.some((file) => { return file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); }); @@ -66579,9 +66576,7 @@ function isArchPresentForMacOrLinux(item, architecture, platform) { } exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; function findAssetForWindows(releases, architecture) { - if (architecture === 'x32') { - architecture = 'x86'; - } + architecture = ReplaceX32toX86(architecture); return releases.files.find((item) => { return item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform); }); @@ -66591,6 +66586,13 @@ function findAssetForMacOrLinux(releases, architecture, platform) { return releases.files.find((item) => item.arch === architecture && item.platform === platform); } exports.findAssetForMacOrLinux = findAssetForMacOrLinux; +function ReplaceX32toX86(architecture) { + // convert x32 to x86 because os.arch() return x32 for 32-bit systems but PyPy releases json has x86 arch value. + if (architecture === 'x32') { + architecture = 'x86'; + } + return architecture; +} /***/ }), diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 3ee6207d1..1d65839f3 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -206,10 +206,7 @@ export function pypyVersionToSemantic(versionSpec: string) { } export function isArchPresentForWindows(item: any, architecture: string) { - // convert x32 to x86 cause os.arch() return x32 for 32-bit system but PyPy releases json has x86 arch value. - if (architecture === 'x32') { - architecture = 'x86'; - } + architecture = ReplaceX32toX86(architecture); return item.files.some( (file: any) => { return file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform); @@ -228,9 +225,7 @@ export function isArchPresentForMacOrLinux( } export function findAssetForWindows(releases: any, architecture: string) { - if (architecture === 'x32') { - architecture = 'x86'; - } + architecture = ReplaceX32toX86(architecture); return releases.files.find( (item: any) => { return item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform); @@ -247,3 +242,11 @@ export function findAssetForMacOrLinux( (item: any) => item.arch === architecture && item.platform === platform ); } + +function ReplaceX32toX86(architecture: string): string { + // convert x32 to x86 because os.arch() return x32 for 32-bit systems but PyPy releases json has x86 arch value. + if (architecture === 'x32') { + architecture = 'x86'; + } + return architecture; +} From 97960c6cd2f09f0f0a8b44bd4c9b862570302b66 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 13 Oct 2022 18:18:47 +0200 Subject: [PATCH 12/17] Format code --- src/install-pypy.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 1d65839f3..6302b9ecd 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -207,11 +207,11 @@ export function pypyVersionToSemantic(versionSpec: string) { export function isArchPresentForWindows(item: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return item.files.some( - (file: any) => { - return file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform); - } - ); + return item.files.some((file: any) => { + return ( + file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) + ); + }); } export function isArchPresentForMacOrLinux( @@ -226,11 +226,11 @@ export function isArchPresentForMacOrLinux( export function findAssetForWindows(releases: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return releases.files.find( - (item: any) => { - return item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform); - } - ); + return releases.files.find((item: any) => { + return ( + item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform) + ); + }); } export function findAssetForMacOrLinux( From 0a1e867161704c7230b16687c7fc10bba155bd09 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Fri, 14 Oct 2022 10:38:06 +0200 Subject: [PATCH 13/17] Rebuild dist --- dist/cache-save/index.js | 185 ++++++++++++++++++++++++-------------- dist/setup/index.js | 189 ++++++++++++++++++++++++--------------- 2 files changed, 236 insertions(+), 138 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 67b113908..09526eaf2 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -525,7 +525,13 @@ function resolvePaths(patterns) { .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); core.debug(`Matched: ${relativeFile}`); // Paths are made relative so the tar entries are all relative to the root of the workspace. - paths.push(`${relativeFile}`); + if (relativeFile === '') { + // path.relative returns empty string if workspace and file are equal + paths.push('.'); + } + else { + paths.push(`${relativeFile}`); + } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -683,6 +689,7 @@ const util = __importStar(__nccwpck_require__(3837)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); const requestUtils_1 = __nccwpck_require__(3981); +const abort_controller_1 = __nccwpck_require__(2557); /** * Pipes the body of a HTTP response to a stream * @@ -866,15 +873,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { const fd = fs.openSync(archivePath, 'w'); try { downloadProgress.startDisplayTimer(); + const controller = new abort_controller_1.AbortController(); + const abortSignal = controller.signal; while (!downloadProgress.isDone()) { const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); downloadProgress.nextSegment(segmentSize); - const result = yield client.downloadToBuffer(segmentStart, segmentSize, { + const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, { + abortSignal, concurrency: options.downloadConcurrency, onProgress: downloadProgress.onProgress() - }); - fs.writeFileSync(fd, result); + })); + if (result === 'timeout') { + controller.abort(); + throw new Error('Aborting cache download as the download time exceeded the timeout.'); + } + else if (Buffer.isBuffer(result)) { + fs.writeFileSync(fd, result); + } } } finally { @@ -885,6 +901,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { }); } exports.downloadCacheStorageSDK = downloadCacheStorageSDK; +const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () { + let timeoutHandle; + const timeoutPromise = new Promise(resolve => { + timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs); + }); + return Promise.race([promise, timeoutPromise]).then(result => { + clearTimeout(timeoutHandle); + return result; + }); +}); //# sourceMappingURL=downloadUtils.js.map /***/ }), @@ -1044,6 +1070,7 @@ const fs_1 = __nccwpck_require__(7147); const path = __importStar(__nccwpck_require__(1017)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); +const IS_WINDOWS = process.platform === 'win32'; function getTarPath(args, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { switch (process.platform) { @@ -1091,26 +1118,43 @@ function getWorkingDirectory() { var _a; return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); } +// Common function for extractTar and listTar to get the compression method +function getCompressionProgram(compressionMethod) { + // -d: Decompress. + // unzstd is equivalent to 'zstd -d' + // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return [ + '--use-compress-program', + IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' + ]; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; + default: + return ['-z']; + } +} +function listTar(archivePath, compressionMethod) { + return __awaiter(this, void 0, void 0, function* () { + const args = [ + ...getCompressionProgram(compressionMethod), + '-tf', + archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), + '-P' + ]; + yield execTar(args, compressionMethod); + }); +} +exports.listTar = listTar; function extractTar(archivePath, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); - // --d: Decompress. - // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - function getCompressionProgram() { - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -d --long=30']; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -d']; - default: - return ['-z']; - } - } const args = [ - ...getCompressionProgram(), + ...getCompressionProgram(compressionMethod), '-xf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', @@ -1129,15 +1173,19 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); const workingDirectory = getWorkingDirectory(); // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores. + // zstdmt is equivalent to 'zstd -T0' // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // Using 30 here because we also support 32-bit self-hosted runners. // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd. function getCompressionProgram() { switch (compressionMethod) { case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -T0 --long=30']; + return [ + '--use-compress-program', + IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' + ]; case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -T0']; + return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; default: return ['-z']; } @@ -1159,32 +1207,6 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { }); } exports.createTar = createTar; -function listTar(archivePath, compressionMethod) { - return __awaiter(this, void 0, void 0, function* () { - // --d: Decompress. - // --long=#: Enables long distance matching with # bits. - // Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - function getCompressionProgram() { - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -d --long=30']; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -d']; - default: - return ['-z']; - } - } - const args = [ - ...getCompressionProgram(), - '-tf', - archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), - '-P' - ]; - yield execTar(args, compressionMethod); - }); -} -exports.listTar = listTar; //# sourceMappingURL=tar.js.map /***/ }), @@ -1235,7 +1257,8 @@ function getDownloadOptions(copy) { const result = { useAzureSdk: true, downloadConcurrency: 8, - timeoutInMs: 30000 + timeoutInMs: 30000, + segmentTimeoutInMs: 3600000 }; if (copy) { if (typeof copy.useAzureSdk === 'boolean') { @@ -1247,10 +1270,21 @@ function getDownloadOptions(copy) { if (typeof copy.timeoutInMs === 'number') { result.timeoutInMs = copy.timeoutInMs; } + if (typeof copy.segmentTimeoutInMs === 'number') { + result.segmentTimeoutInMs = copy.segmentTimeoutInMs; + } + } + const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']; + if (segmentDownloadTimeoutMins && + !isNaN(Number(segmentDownloadTimeoutMins)) && + isFinite(Number(segmentDownloadTimeoutMins))) { + result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000; } core.debug(`Use Azure SDK: ${result.useAzureSdk}`); core.debug(`Download concurrency: ${result.downloadConcurrency}`); core.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`); + core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); return result; } exports.getDownloadOptions = getDownloadOptions; @@ -4831,7 +4865,6 @@ const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); -const uuid_1 = __nccwpck_require__(8974); const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action @@ -4861,20 +4894,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -4892,7 +4914,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -4932,7 +4954,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -4965,8 +4990,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -5095,7 +5124,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -5161,13 +5194,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -5179,7 +5213,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 569bc1616..07581089b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -525,7 +525,13 @@ function resolvePaths(patterns) { .replace(new RegExp(`\\${path.sep}`, 'g'), '/'); core.debug(`Matched: ${relativeFile}`); // Paths are made relative so the tar entries are all relative to the root of the workspace. - paths.push(`${relativeFile}`); + if (relativeFile === '') { + // path.relative returns empty string if workspace and file are equal + paths.push('.'); + } + else { + paths.push(`${relativeFile}`); + } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } @@ -683,6 +689,7 @@ const util = __importStar(__nccwpck_require__(3837)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); const requestUtils_1 = __nccwpck_require__(3981); +const abort_controller_1 = __nccwpck_require__(2557); /** * Pipes the body of a HTTP response to a stream * @@ -866,15 +873,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { const fd = fs.openSync(archivePath, 'w'); try { downloadProgress.startDisplayTimer(); + const controller = new abort_controller_1.AbortController(); + const abortSignal = controller.signal; while (!downloadProgress.isDone()) { const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart); downloadProgress.nextSegment(segmentSize); - const result = yield client.downloadToBuffer(segmentStart, segmentSize, { + const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, { + abortSignal, concurrency: options.downloadConcurrency, onProgress: downloadProgress.onProgress() - }); - fs.writeFileSync(fd, result); + })); + if (result === 'timeout') { + controller.abort(); + throw new Error('Aborting cache download as the download time exceeded the timeout.'); + } + else if (Buffer.isBuffer(result)) { + fs.writeFileSync(fd, result); + } } } finally { @@ -885,6 +901,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) { }); } exports.downloadCacheStorageSDK = downloadCacheStorageSDK; +const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () { + let timeoutHandle; + const timeoutPromise = new Promise(resolve => { + timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs); + }); + return Promise.race([promise, timeoutPromise]).then(result => { + clearTimeout(timeoutHandle); + return result; + }); +}); //# sourceMappingURL=downloadUtils.js.map /***/ }), @@ -1044,6 +1070,7 @@ const fs_1 = __nccwpck_require__(7147); const path = __importStar(__nccwpck_require__(1017)); const utils = __importStar(__nccwpck_require__(1518)); const constants_1 = __nccwpck_require__(8840); +const IS_WINDOWS = process.platform === 'win32'; function getTarPath(args, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { switch (process.platform) { @@ -1091,26 +1118,43 @@ function getWorkingDirectory() { var _a; return (_a = process.env['GITHUB_WORKSPACE']) !== null && _a !== void 0 ? _a : process.cwd(); } +// Common function for extractTar and listTar to get the compression method +function getCompressionProgram(compressionMethod) { + // -d: Decompress. + // unzstd is equivalent to 'zstd -d' + // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. + // Using 30 here because we also support 32-bit self-hosted runners. + switch (compressionMethod) { + case constants_1.CompressionMethod.Zstd: + return [ + '--use-compress-program', + IS_WINDOWS ? 'zstd -d --long=30' : 'unzstd --long=30' + ]; + case constants_1.CompressionMethod.ZstdWithoutLong: + return ['--use-compress-program', IS_WINDOWS ? 'zstd -d' : 'unzstd']; + default: + return ['-z']; + } +} +function listTar(archivePath, compressionMethod) { + return __awaiter(this, void 0, void 0, function* () { + const args = [ + ...getCompressionProgram(compressionMethod), + '-tf', + archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), + '-P' + ]; + yield execTar(args, compressionMethod); + }); +} +exports.listTar = listTar; function extractTar(archivePath, compressionMethod) { return __awaiter(this, void 0, void 0, function* () { // Create directory to extract tar into const workingDirectory = getWorkingDirectory(); yield io.mkdirP(workingDirectory); - // --d: Decompress. - // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - function getCompressionProgram() { - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -d --long=30']; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -d']; - default: - return ['-z']; - } - } const args = [ - ...getCompressionProgram(), + ...getCompressionProgram(compressionMethod), '-xf', archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), '-P', @@ -1129,15 +1173,19 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { fs_1.writeFileSync(path.join(archiveFolder, manifestFilename), sourceDirectories.join('\n')); const workingDirectory = getWorkingDirectory(); // -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores. + // zstdmt is equivalent to 'zstd -T0' // --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. // Using 30 here because we also support 32-bit self-hosted runners. // Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd. function getCompressionProgram() { switch (compressionMethod) { case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -T0 --long=30']; + return [ + '--use-compress-program', + IS_WINDOWS ? 'zstd -T0 --long=30' : 'zstdmt --long=30' + ]; case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -T0']; + return ['--use-compress-program', IS_WINDOWS ? 'zstd -T0' : 'zstdmt']; default: return ['-z']; } @@ -1159,32 +1207,6 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) { }); } exports.createTar = createTar; -function listTar(archivePath, compressionMethod) { - return __awaiter(this, void 0, void 0, function* () { - // --d: Decompress. - // --long=#: Enables long distance matching with # bits. - // Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit. - // Using 30 here because we also support 32-bit self-hosted runners. - function getCompressionProgram() { - switch (compressionMethod) { - case constants_1.CompressionMethod.Zstd: - return ['--use-compress-program', 'zstd -d --long=30']; - case constants_1.CompressionMethod.ZstdWithoutLong: - return ['--use-compress-program', 'zstd -d']; - default: - return ['-z']; - } - } - const args = [ - ...getCompressionProgram(), - '-tf', - archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), - '-P' - ]; - yield execTar(args, compressionMethod); - }); -} -exports.listTar = listTar; //# sourceMappingURL=tar.js.map /***/ }), @@ -1235,7 +1257,8 @@ function getDownloadOptions(copy) { const result = { useAzureSdk: true, downloadConcurrency: 8, - timeoutInMs: 30000 + timeoutInMs: 30000, + segmentTimeoutInMs: 3600000 }; if (copy) { if (typeof copy.useAzureSdk === 'boolean') { @@ -1247,10 +1270,21 @@ function getDownloadOptions(copy) { if (typeof copy.timeoutInMs === 'number') { result.timeoutInMs = copy.timeoutInMs; } + if (typeof copy.segmentTimeoutInMs === 'number') { + result.segmentTimeoutInMs = copy.segmentTimeoutInMs; + } + } + const segmentDownloadTimeoutMins = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']; + if (segmentDownloadTimeoutMins && + !isNaN(Number(segmentDownloadTimeoutMins)) && + isFinite(Number(segmentDownloadTimeoutMins))) { + result.segmentTimeoutInMs = Number(segmentDownloadTimeoutMins) * 60 * 1000; } core.debug(`Use Azure SDK: ${result.useAzureSdk}`); core.debug(`Download concurrency: ${result.downloadConcurrency}`); core.debug(`Request timeout (ms): ${result.timeoutInMs}`); + core.debug(`Cache segment download timeout mins env var: ${process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']}`); + core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`); return result; } exports.getDownloadOptions = getDownloadOptions; @@ -4831,7 +4865,6 @@ const file_command_1 = __nccwpck_require__(717); const utils_1 = __nccwpck_require__(5278); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); -const uuid_1 = __nccwpck_require__(8974); const oidc_utils_1 = __nccwpck_require__(8041); /** * The code to exit an action @@ -4861,20 +4894,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -4892,7 +4914,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -4932,7 +4954,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -4965,8 +4990,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -5095,7 +5124,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** @@ -5161,13 +5194,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); +const uuid_1 = __nccwpck_require__(8974); const utils_1 = __nccwpck_require__(5278); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -5179,7 +5213,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -66567,7 +66616,7 @@ exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item, architecture) { architecture = ReplaceX32toX86(architecture); return item.files.some((file) => { - return file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform); + return (file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); }); } exports.isArchPresentForWindows = isArchPresentForWindows; @@ -66578,7 +66627,7 @@ exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; function findAssetForWindows(releases, architecture) { architecture = ReplaceX32toX86(architecture); return releases.files.find((item) => { - return item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform); + return (item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform)); }); } exports.findAssetForWindows = findAssetForWindows; From 71e2dec535f83cb09330b6a9c0ff0d07fb9891e8 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Fri, 14 Oct 2022 12:45:52 +0200 Subject: [PATCH 14/17] Minor refactor --- dist/setup/index.js | 8 ++------ src/install-pypy.ts | 12 ++++-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 07581089b..f270dac00 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66615,9 +66615,7 @@ function pypyVersionToSemantic(versionSpec) { exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item, architecture) { architecture = ReplaceX32toX86(architecture); - return item.files.some((file) => { - return (file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); - }); + return item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); } exports.isArchPresentForWindows = isArchPresentForWindows; function isArchPresentForMacOrLinux(item, architecture, platform) { @@ -66626,9 +66624,7 @@ function isArchPresentForMacOrLinux(item, architecture, platform) { exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; function findAssetForWindows(releases, architecture) { architecture = ReplaceX32toX86(architecture); - return releases.files.find((item) => { - return (item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform)); - }); + return releases.files.find((item) => item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform)); } exports.findAssetForWindows = findAssetForWindows; function findAssetForMacOrLinux(releases, architecture, platform) { diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 6302b9ecd..eb0e02ae9 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -207,11 +207,9 @@ export function pypyVersionToSemantic(versionSpec: string) { export function isArchPresentForWindows(item: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return item.files.some((file: any) => { - return ( + return item.files.some((file: any) => file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) - ); - }); + ); } export function isArchPresentForMacOrLinux( @@ -226,11 +224,9 @@ export function isArchPresentForMacOrLinux( export function findAssetForWindows(releases: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return releases.files.find((item: any) => { - return ( + return releases.files.find((item: any) => item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform) - ); - }); + ); } export function findAssetForMacOrLinux( From 957735f5bc6f71e89d8ea22e1ddfc91e33a055b9 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Fri, 14 Oct 2022 12:47:18 +0200 Subject: [PATCH 15/17] Format code --- src/install-pypy.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/install-pypy.ts b/src/install-pypy.ts index eb0e02ae9..9028c257b 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -207,7 +207,8 @@ export function pypyVersionToSemantic(versionSpec: string) { export function isArchPresentForWindows(item: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return item.files.some((file: any) => + return item.files.some( + (file: any) => file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) ); } @@ -224,7 +225,8 @@ export function isArchPresentForMacOrLinux( export function findAssetForWindows(releases: any, architecture: string) { architecture = ReplaceX32toX86(architecture); - return releases.files.find((item: any) => + return releases.files.find( + (item: any) => item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform) ); } From d1ffee02d7c4997f49bb13b50c4898cd5f0d2272 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 17 Oct 2022 11:44:19 +0200 Subject: [PATCH 16/17] Minor fixes --- dist/setup/index.js | 2 +- src/install-pypy.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index f270dac00..3bc2f3203 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66632,7 +66632,7 @@ function findAssetForMacOrLinux(releases, architecture, platform) { } exports.findAssetForMacOrLinux = findAssetForMacOrLinux; function ReplaceX32toX86(architecture) { - // convert x32 to x86 because os.arch() return x32 for 32-bit systems but PyPy releases json has x86 arch value. + // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (architecture === 'x32') { architecture = 'x86'; } diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 9028c257b..1ab48ab4c 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -8,7 +8,6 @@ import fs from 'fs'; import { IS_WINDOWS, - WINDOWS_ARCHS, WINDOWS_PLATFORMS, IPyPyManifestRelease, createSymlinkInFolder, @@ -242,7 +241,7 @@ export function findAssetForMacOrLinux( } function ReplaceX32toX86(architecture: string): string { - // convert x32 to x86 because os.arch() return x32 for 32-bit systems but PyPy releases json has x86 arch value. + // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (architecture === 'x32') { architecture = 'x86'; } From 9854107d3e16d5a2ca2e41d29af4261360251292 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Mon, 17 Oct 2022 12:48:42 +0200 Subject: [PATCH 17/17] Check platform firstly --- dist/setup/index.js | 10 +++++----- src/install-pypy.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 3bc2f3203..f153c3c24 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66614,8 +66614,8 @@ function pypyVersionToSemantic(versionSpec) { } exports.pypyVersionToSemantic = pypyVersionToSemantic; function isArchPresentForWindows(item, architecture) { - architecture = ReplaceX32toX86(architecture); - return item.files.some((file) => file.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(file.platform)); + architecture = replaceX32toX86(architecture); + return item.files.some((file) => utils_1.WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture); } exports.isArchPresentForWindows = isArchPresentForWindows; function isArchPresentForMacOrLinux(item, architecture, platform) { @@ -66623,15 +66623,15 @@ function isArchPresentForMacOrLinux(item, architecture, platform) { } exports.isArchPresentForMacOrLinux = isArchPresentForMacOrLinux; function findAssetForWindows(releases, architecture) { - architecture = ReplaceX32toX86(architecture); - return releases.files.find((item) => item.arch === architecture && utils_1.WINDOWS_PLATFORMS.includes(item.platform)); + architecture = replaceX32toX86(architecture); + return releases.files.find((item) => utils_1.WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture); } exports.findAssetForWindows = findAssetForWindows; function findAssetForMacOrLinux(releases, architecture, platform) { return releases.files.find((item) => item.arch === architecture && item.platform === platform); } exports.findAssetForMacOrLinux = findAssetForMacOrLinux; -function ReplaceX32toX86(architecture) { +function replaceX32toX86(architecture) { // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (architecture === 'x32') { architecture = 'x86'; diff --git a/src/install-pypy.ts b/src/install-pypy.ts index 1ab48ab4c..d8594ba6b 100644 --- a/src/install-pypy.ts +++ b/src/install-pypy.ts @@ -205,10 +205,10 @@ export function pypyVersionToSemantic(versionSpec: string) { } export function isArchPresentForWindows(item: any, architecture: string) { - architecture = ReplaceX32toX86(architecture); + architecture = replaceX32toX86(architecture); return item.files.some( (file: any) => - file.arch === architecture && WINDOWS_PLATFORMS.includes(file.platform) + WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture ); } @@ -223,10 +223,10 @@ export function isArchPresentForMacOrLinux( } export function findAssetForWindows(releases: any, architecture: string) { - architecture = ReplaceX32toX86(architecture); + architecture = replaceX32toX86(architecture); return releases.files.find( (item: any) => - item.arch === architecture && WINDOWS_PLATFORMS.includes(item.platform) + WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture ); } @@ -240,7 +240,7 @@ export function findAssetForMacOrLinux( ); } -function ReplaceX32toX86(architecture: string): string { +function replaceX32toX86(architecture: string): string { // convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value. if (architecture === 'x32') { architecture = 'x86';