From 3e285fed99383747108bd58abe5463bf8b8f7439 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Fri, 30 Jun 2023 18:12:19 +0200 Subject: [PATCH] format, lint and build --- __tests__/find-graalpy.test.ts | 24 +-- __tests__/install-graalpy.test.ts | 50 +---- dist/setup/index.js | 327 ++++++++++++++++++++++++++++++ src/find-graalpy.ts | 29 ++- src/install-graalpy.ts | 45 ++-- src/setup-python.ts | 4 +- 6 files changed, 387 insertions(+), 92 deletions(-) diff --git a/__tests__/find-graalpy.test.ts b/__tests__/find-graalpy.test.ts index 5775ab3b1..bfb731ec4 100644 --- a/__tests__/find-graalpy.test.ts +++ b/__tests__/find-graalpy.test.ts @@ -10,13 +10,11 @@ import * as path from 'path'; import * as semver from 'semver'; import * as finder from '../src/find-graalpy'; -import { - IGraalPyManifestRelease, -} from '../src/utils'; +import {IGraalPyManifestRelease} from '../src/utils'; import manifestData from './data/graalpy.json'; -let architecture = 'x64'; +const architecture = 'x64'; const toolDir = path.join(__dirname, 'runner', 'tools'); const tempDir = path.join(__dirname, 'runner', 'temp'); @@ -25,7 +23,7 @@ describe('parseGraalPyVersion', () => { it.each([ ['graalpy-23', '23'], ['graalpy-23.0', '23.0'], - ['graalpy23.0', '23.0'], + ['graalpy23.0', '23.0'] ])('%s -> %s', (input, expected) => { expect(finder.parseGraalPyVersion(input)).toEqual(expected); }); @@ -308,9 +306,7 @@ describe('findGraalPyVersion', () => { ) ).resolves.toEqual('23.0.0'); - expect(infoSpy).toHaveBeenCalledWith( - 'Resolved as GraalPy 23.0.0' - ); + expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0'); }); it('check-latest enabled version found and install successfully', async () => { @@ -329,9 +325,7 @@ describe('findGraalPyVersion', () => { false ) ).resolves.toEqual('23.0.0'); - expect(infoSpy).toHaveBeenCalledWith( - 'Resolved as GraalPy 23.0.0' - ); + expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0'); }); it('check-latest enabled version is not found and used from toolcache', async () => { @@ -366,7 +360,13 @@ describe('findGraalPyVersion', () => { spyChmodSync = jest.spyOn(fs, 'chmodSync'); spyChmodSync.mockImplementation(() => undefined); await expect( - finder.findGraalPyVersion('graalpy23.1', architecture, false, false, false) + finder.findGraalPyVersion( + 'graalpy23.1', + architecture, + false, + false, + false + ) ).rejects.toThrow(); await expect( finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true) diff --git a/__tests__/install-graalpy.test.ts b/__tests__/install-graalpy.test.ts index 346ba6c71..f75851aef 100644 --- a/__tests__/install-graalpy.test.ts +++ b/__tests__/install-graalpy.test.ts @@ -16,7 +16,7 @@ import { import manifestData from './data/graalpy.json'; -let architecture: string = 'x64'; +const architecture = 'x64'; const toolDir = path.join(__dirname, 'runner', 'tools'); const tempDir = path.join(__dirname, 'runner', 'temp'); @@ -36,7 +36,7 @@ describe('findRelease', () => { const result = JSON.stringify(manifestData); const releases = JSON.parse(result) as IGraalPyManifestRelease[]; const extension = 'tar.gz'; - const arch = architecture === 'x64' ? 'amd64' : 'aarch64'; + const arch = architecture === 'x64' ? 'amd64' : 'aarch64'; const extensionName = IS_WINDOWS ? `windows-${arch}.${extension}` : `${process.platform}-${arch}.${extension}`; @@ -67,24 +67,14 @@ describe('findRelease', () => { it("GraalPy version doesn't match", () => { const graalpyVersion = '12.0.0'; expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - false - ) + installer.findRelease(releases, graalpyVersion, architecture, false) ).toEqual(null); }); it('GraalPy version matches', () => { const graalpyVersion = '23.0.0'; expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - false - ) + installer.findRelease(releases, graalpyVersion, architecture, false) ).toMatchObject({ foundAsset: files, resolvedGraalPyVersion: graalpyVersion @@ -94,12 +84,7 @@ describe('findRelease', () => { it('Preview version of GraalPy is found', () => { const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1'); expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - false - ) + installer.findRelease(releases, graalpyVersion, architecture, false) ).toMatchObject({ foundAsset: { name: `graalpython-23.1.0a1-${extensionName}`, @@ -112,12 +97,7 @@ describe('findRelease', () => { it('Latest GraalPy is found', () => { const graalpyVersion = 'x'; expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - false - ) + installer.findRelease(releases, graalpyVersion, architecture, false) ).toMatchObject({ foundAsset: files, resolvedGraalPyVersion: '23.0.0' @@ -127,20 +107,10 @@ describe('findRelease', () => { it('GraalPy version matches semver (pre-release)', () => { const graalpyVersion = '23.1.x'; expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - false - ) + installer.findRelease(releases, graalpyVersion, architecture, false) ).toBeNull(); expect( - installer.findRelease( - releases, - graalpyVersion, - architecture, - true - ) + installer.findRelease(releases, graalpyVersion, architecture, true) ).toMatchObject({ foundAsset: filesRC1, resolvedGraalPyVersion: '23.1.0-a.1' @@ -167,7 +137,9 @@ describe('installGraalPy', () => { beforeEach(() => { tcFind = jest.spyOn(tc, 'find'); - tcFind.mockImplementation(() => path.join('GraalPy', '3.6.12', architecture)); + tcFind.mockImplementation(() => + path.join('GraalPy', '3.6.12', architecture) + ); spyDownloadTool = jest.spyOn(tc, 'downloadTool'); spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy')); diff --git a/dist/setup/index.js b/dist/setup/index.js index a72f2d279..38e8e611e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -66831,6 +66831,132 @@ class PoetryCache extends cache_distributor_1.default { exports["default"] = PoetryCache; +/***/ }), + +/***/ 8040: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.parseGraalPyVersion = exports.findGraalPyToolCache = exports.findGraalPyVersion = void 0; +const path = __importStar(__nccwpck_require__(1017)); +const graalpyInstall = __importStar(__nccwpck_require__(8265)); +const utils_1 = __nccwpck_require__(1314); +const semver = __importStar(__nccwpck_require__(1383)); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +function findGraalPyVersion(versionSpec, architecture, updateEnvironment, checkLatest, allowPreReleases) { + return __awaiter(this, void 0, void 0, function* () { + let resolvedGraalPyVersion = ''; + let installDir; + let releases; + let graalpyVersionSpec = parseGraalPyVersion(versionSpec); + if (checkLatest) { + releases = yield graalpyInstall.getAvailableGraalPyVersions(); + if (releases && releases.length > 0) { + const releaseData = graalpyInstall.findRelease(releases, graalpyVersionSpec, architecture, false); + if (releaseData) { + core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`); + graalpyVersionSpec = releaseData.resolvedGraalPyVersion; + } + else { + core.info(`Failed to resolve GraalPy ${graalpyVersionSpec} from manifest`); + } + } + } + ({ installDir, resolvedGraalPyVersion } = findGraalPyToolCache(graalpyVersionSpec, architecture)); + if (!installDir) { + ({ installDir, resolvedGraalPyVersion } = yield graalpyInstall.installGraalPy(graalpyVersionSpec, architecture, allowPreReleases, releases)); + } + const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin'; + const _binDir = path.join(installDir, pipDir); + const binaryExtension = utils_1.IS_WINDOWS ? '.exe' : ''; + const pythonPath = path.join(utils_1.IS_WINDOWS ? installDir : _binDir, `python${binaryExtension}`); + const pythonLocation = graalpyInstall.getGraalPyBinaryPath(installDir); + if (updateEnvironment) { + core.exportVariable('pythonLocation', installDir); + // https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython + core.exportVariable('Python_ROOT_DIR', installDir); + // https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2 + core.exportVariable('Python2_ROOT_DIR', installDir); + // https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3 + core.exportVariable('Python3_ROOT_DIR', installDir); + core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig'); + core.addPath(pythonLocation); + core.addPath(_binDir); + } + core.setOutput('python-version', 'graalpy' + resolvedGraalPyVersion); + core.setOutput('python-path', pythonPath); + return resolvedGraalPyVersion; + }); +} +exports.findGraalPyVersion = findGraalPyVersion; +function findGraalPyToolCache(graalpyVersion, architecture) { + let resolvedGraalPyVersion = ''; + let installDir = tc.find('GraalPy', graalpyVersion, architecture); + if (installDir) { + // 'tc.find' finds tool based on Python version but we also need to check + // whether GraalPy version satisfies requested version. + resolvedGraalPyVersion = path.basename(path.dirname(installDir)); + const isGraalPyVersionSatisfies = semver.satisfies(resolvedGraalPyVersion, graalpyVersion); + if (!isGraalPyVersionSatisfies) { + installDir = null; + resolvedGraalPyVersion = ''; + } + } + if (!installDir) { + core.info(`GraalPy version ${graalpyVersion} was not found in the local cache`); + } + return { installDir, resolvedGraalPyVersion }; +} +exports.findGraalPyToolCache = findGraalPyToolCache; +function parseGraalPyVersion(versionSpec) { + const versions = versionSpec.split('-').filter(item => !!item); + if (/^(graalpy)(.+)/.test(versions[0])) { + const version = versions[0].replace('graalpy', ''); + versions.splice(0, 1, 'graalpy', version); + } + if (versions.length < 2 || versions[0] != 'graalpy') { + throw new Error("Invalid 'version' property for GraalPy. GraalPy version should be specified as 'graalpy' or 'graalpy-'. See README for examples and documentation."); + } + const pythonVersion = versions[1]; + if (!utils_1.validateVersion(pythonVersion)) { + throw new Error("Invalid 'version' property for GraalPy. GraalPy versions should satisfy SemVer notation. See README for examples and documentation."); + } + return pythonVersion; +} +exports.parseGraalPyVersion = parseGraalPyVersion; + + /***/ }), /***/ 4003: @@ -67159,6 +67285,198 @@ function pythonVersionToSemantic(versionSpec, allowPreReleases) { exports.pythonVersionToSemantic = pythonVersionToSemantic; +/***/ }), + +/***/ 8265: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.findAsset = exports.getGraalPyBinaryPath = exports.findRelease = exports.graalPyTagToVersion = exports.getAvailableGraalPyVersions = exports.installGraalPy = void 0; +const os = __importStar(__nccwpck_require__(2037)); +const path = __importStar(__nccwpck_require__(1017)); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const semver = __importStar(__nccwpck_require__(1383)); +const httpm = __importStar(__nccwpck_require__(9925)); +const exec = __importStar(__nccwpck_require__(1514)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const utils_1 = __nccwpck_require__(1314); +function installGraalPy(graalpyVersion, architecture, allowPreReleases, releases) { + return __awaiter(this, void 0, void 0, function* () { + let downloadDir; + releases = releases !== null && releases !== void 0 ? releases : (yield getAvailableGraalPyVersions()); + if (!releases || releases.length === 0) { + throw new Error('No release was found in GraalPy version.json'); + } + let releaseData = findRelease(releases, graalpyVersion, architecture, false); + if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) { + // check for pre-release + core.info([ + `Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`, + `Trying pre-release versions` + ].join(os.EOL)); + releaseData = findRelease(releases, graalpyVersion, architecture, true); + } + if (!releaseData || !releaseData.foundAsset) { + throw new Error(`GraalPy version ${graalpyVersion} with arch ${architecture} not found`); + } + const { foundAsset, resolvedGraalPyVersion } = releaseData; + const downloadUrl = `${foundAsset.browser_download_url}`; + core.info(`Downloading GraalPy from "${downloadUrl}" ...`); + try { + const graalpyPath = yield tc.downloadTool(downloadUrl); + core.info('Extracting downloaded archive...'); + downloadDir = yield tc.extractTar(graalpyPath); + // root folder in archive can have unpredictable name so just take the first folder + // downloadDir is unique folder under TEMP and can't contain any other folders + const archiveName = fs_1.default.readdirSync(downloadDir)[0]; + const toolDir = path.join(downloadDir, archiveName); + let installDir = toolDir; + if (!utils_1.isNightlyKeyword(resolvedGraalPyVersion)) { + installDir = yield tc.cacheDir(toolDir, 'GraalPy', resolvedGraalPyVersion, architecture); + } + const binaryPath = getGraalPyBinaryPath(installDir); + yield installPip(binaryPath); + return { installDir, resolvedGraalPyVersion }; + } + catch (err) { + if (err instanceof Error) { + // Rate limit? + if (err instanceof tc.HTTPError && + (err.httpStatusCode === 403 || err.httpStatusCode === 429)) { + core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`); + } + else { + core.info(err.message); + } + if (err.stack !== undefined) { + core.debug(err.stack); + } + } + throw err; + } + }); +} +exports.installGraalPy = installGraalPy; +function getAvailableGraalPyVersions() { + return __awaiter(this, void 0, void 0, function* () { + const url = 'https://api.github.com/repos/oracle/graalpython/releases'; + const http = new httpm.HttpClient('tool-cache'); + const response = yield http.getJson(url); + if (!response.result) { + throw new Error(`Unable to retrieve the list of available GraalPy versions from '${url}'`); + } + return response.result; + }); +} +exports.getAvailableGraalPyVersions = getAvailableGraalPyVersions; +function installPip(pythonLocation) { + return __awaiter(this, void 0, void 0, function* () { + core.info('Installing and updating pip'); + const pythonBinary = path.join(pythonLocation, 'python'); + yield exec.exec(`${pythonBinary} -m ensurepip`); + yield exec.exec(`${pythonLocation}/python -m pip install --ignore-installed pip`); + }); +} +function graalPyTagToVersion(tag) { + const versionPattern = /.*-(\d+\.\d+\.\d+(?:\.\d+)?)((?:a|b|rc))?(\d*)?/; + const match = tag.match(versionPattern); + if (match && match[2]) { + return `${match[1]}-${match[2]}.${match[3]}`; + } + else if (match) { + return match[1]; + } + else { + return tag.replace(/.*-/, ''); + } +} +exports.graalPyTagToVersion = graalPyTagToVersion; +function findRelease(releases, graalpyVersion, architecture, includePrerelease) { + const options = { includePrerelease: includePrerelease }; + const filterReleases = releases.filter(item => { + const isVersionSatisfied = semver.satisfies(graalPyTagToVersion(item.tag_name), graalpyVersion, options); + return (isVersionSatisfied && !!findAsset(item, architecture, process.platform)); + }); + if (filterReleases.length === 0) { + return null; + } + const sortedReleases = filterReleases.sort((previous, current) => { + return (semver.compare(semver.coerce(graalPyTagToVersion(current.tag_name)), semver.coerce(graalPyTagToVersion(previous.tag_name))) || + semver.compare(semver.coerce(graalPyTagToVersion(current.tag_name)), semver.coerce(graalPyTagToVersion(previous.tag_name)))); + }); + const foundRelease = sortedReleases[0]; + const foundAsset = findAsset(foundRelease, architecture, process.platform); + return { + foundAsset, + resolvedGraalPyVersion: graalPyTagToVersion(foundRelease.tag_name) + }; +} +exports.findRelease = findRelease; +/** Get GraalPy binary location from the tool of installation directory + * - On Linux and macOS, the Python interpreter is in 'bin'. + * - On Windows, it is in the installation root. + */ +function getGraalPyBinaryPath(installDir) { + const _binDir = path.join(installDir, 'bin'); + return utils_1.IS_WINDOWS ? installDir : _binDir; +} +exports.getGraalPyBinaryPath = getGraalPyBinaryPath; +function findAsset(item, architecture, platform) { + const graalpyArch = architecture === 'x64' + ? 'amd64' + : architecture === 'arm64' + ? 'aarch64' + : architecture; + const graalpyPlatform = platform == 'win32' ? 'windows' : platform; + if (item.assets) { + return item.assets.find((file) => { + const match_data = file.name.match('.*(darwin|linux|windows)-(amd64|aarch64).tar.gz$'); + return (match_data && + match_data[1] === graalpyPlatform && + match_data[2] === graalpyArch); + }); + } + else { + return undefined; + } +} +exports.findAsset = findAsset; + + /***/ }), /***/ 8168: @@ -67544,6 +67862,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); const core = __importStar(__nccwpck_require__(2186)); const finder = __importStar(__nccwpck_require__(9996)); const finderPyPy = __importStar(__nccwpck_require__(4003)); +const finderGraalPy = __importStar(__nccwpck_require__(8040)); const path = __importStar(__nccwpck_require__(1017)); const os = __importStar(__nccwpck_require__(2037)); const fs_1 = __importDefault(__nccwpck_require__(7147)); @@ -67552,6 +67871,9 @@ const utils_1 = __nccwpck_require__(1314); function isPyPyVersion(versionSpec) { return versionSpec.startsWith('pypy'); } +function isGraalPyVersion(versionSpec) { + return versionSpec.startsWith('graalpy'); +} function cacheDependencies(cache, pythonVersion) { return __awaiter(this, void 0, void 0, function* () { const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined; @@ -67611,6 +67933,11 @@ function run() { pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`); } + else if (isGraalPyVersion(version)) { + const installed = yield finderGraalPy.findGraalPyVersion(version, arch, updateEnvironment, checkLatest, allowPreReleases); + pythonVersion = `${installed}`; + core.info(`Successfully set up GraalPy ${installed}`); + } else { if (version.startsWith('2')) { core.warning('The support for python 2.7 will be removed on June 19. Related issue: https://github.com/actions/setup-python/issues/672'); diff --git a/src/find-graalpy.ts b/src/find-graalpy.ts index 10dbeeb08..b1373ca6b 100644 --- a/src/find-graalpy.ts +++ b/src/find-graalpy.ts @@ -1,10 +1,6 @@ import * as path from 'path'; import * as graalpyInstall from './install-graalpy'; -import { - IS_WINDOWS, - validateVersion, - IGraalPyManifestRelease -} from './utils'; +import {IS_WINDOWS, validateVersion, IGraalPyManifestRelease} from './utils'; import * as semver from 'semver'; import * as core from '@actions/core'; @@ -34,9 +30,7 @@ export async function findGraalPyVersion( ); if (releaseData) { - core.info( - `Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}` - ); + core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`); graalpyVersionSpec = releaseData.resolvedGraalPyVersion; } else { core.info( @@ -52,13 +46,12 @@ export async function findGraalPyVersion( )); if (!installDir) { - ({installDir, resolvedGraalPyVersion} = - await graalpyInstall.installGraalPy( - graalpyVersionSpec, - architecture, - allowPreReleases, - releases - )); + ({installDir, resolvedGraalPyVersion} = await graalpyInstall.installGraalPy( + graalpyVersionSpec, + architecture, + allowPreReleases, + releases + )); } const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; @@ -92,7 +85,11 @@ export function findGraalPyToolCache( architecture: string ) { let resolvedGraalPyVersion = ''; - let installDir: string | null = tc.find('GraalPy', graalpyVersion, architecture); + let installDir: string | null = tc.find( + 'GraalPy', + graalpyVersion, + architecture + ); if (installDir) { // 'tc.find' finds tool based on Python version but we also need to check diff --git a/src/install-graalpy.ts b/src/install-graalpy.ts index 6754f26b1..e155db160 100644 --- a/src/install-graalpy.ts +++ b/src/install-graalpy.ts @@ -11,7 +11,7 @@ import { IS_WINDOWS, IGraalPyManifestAsset, IGraalPyManifestRelease, - isNightlyKeyword, + isNightlyKeyword } from './utils'; export async function installGraalPy( @@ -28,12 +28,7 @@ export async function installGraalPy( throw new Error('No release was found in GraalPy version.json'); } - let releaseData = findRelease( - releases, - graalpyVersion, - architecture, - false - ); + let releaseData = findRelease(releases, graalpyVersion, architecture, false); if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) { // check for pre-release @@ -43,12 +38,7 @@ export async function installGraalPy( `Trying pre-release versions` ].join(os.EOL) ); - releaseData = findRelease( - releases, - graalpyVersion, - architecture, - true - ); + releaseData = findRelease(releases, graalpyVersion, architecture, true); } if (!releaseData || !releaseData.foundAsset) { @@ -157,7 +147,9 @@ export function findRelease( graalpyVersion, options ); - return isVersionSatisfied && !!findAsset(item, architecture, process.platform); + return ( + isVersionSatisfied && !!findAsset(item, architecture, process.platform) + ); }); if (filterReleases.length === 0) { @@ -200,15 +192,24 @@ export function findAsset( architecture: string, platform: string ) { - const graalpyArch = architecture === 'x64' ? 'amd64' : (architecture === 'arm64' ? 'aarch64' : architecture); - const graalpyPlatform = platform == "win32" ? "windows" : platform; + const graalpyArch = + architecture === 'x64' + ? 'amd64' + : architecture === 'arm64' + ? 'aarch64' + : architecture; + const graalpyPlatform = platform == 'win32' ? 'windows' : platform; if (item.assets) { - return item.assets.find( - (file: IGraalPyManifestAsset) => { - const match_data = file.name.match(".*(darwin|linux|windows)-(amd64|aarch64).tar.gz$"); - return match_data && match_data[1] === graalpyPlatform && match_data[2] === graalpyArch; - } - ); + return item.assets.find((file: IGraalPyManifestAsset) => { + const match_data = file.name.match( + '.*(darwin|linux|windows)-(amd64|aarch64).tar.gz$' + ); + return ( + match_data && + match_data[1] === graalpyPlatform && + match_data[2] === graalpyArch + ); + }); } else { return undefined; } diff --git a/src/setup-python.ts b/src/setup-python.ts index b7f9e7b9d..dfe772a1b 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -111,9 +111,7 @@ async function run() { allowPreReleases ); pythonVersion = `${installed}`; - core.info( - `Successfully set up GraalPy ${installed}` - ); + core.info(`Successfully set up GraalPy ${installed}`); } else { if (version.startsWith('2')) { core.warning(