From 59a78899a90b6def5f13ccbcf54f583d63283d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Ifr=C3=A1n?= Date: Wed, 18 Jan 2023 10:00:38 -0300 Subject: [PATCH] Fix style issues and build Build the project using `npm run build` and run prettier using `npm run format` --- __tests__/utils.test.ts | 12 +++++++++--- docs/advanced-usage.md | 2 +- src/find-pypy.ts | 19 +++++++++++-------- src/setup-python.ts | 11 +++++++++-- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 7722fb35f..87f4d7785 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -12,15 +12,21 @@ jest.mock('@actions/core'); describe('parsePythonVersionFile', () => { it('handle the content of a .python-version file', () => { - expect(parsePythonVersionFile('3.6')).toEqual('3.6') + expect(parsePythonVersionFile('3.6')).toEqual('3.6'); }); it('trims extra spaces at the end of the content', () => { - expect(parsePythonVersionFile('3.7 ')).toEqual('3.7') + expect(parsePythonVersionFile('3.7 ')).toEqual('3.7'); }); it('parses correctly the content of .tool-version files', () => { - expect(parsePythonVersionFile('python 3.7')).toEqual('3.7') + expect(parsePythonVersionFile('python 3.7')).toEqual('3.7'); + }); + + it('parses correctly pypy version content of the .tool-version files', () => { + expect(parsePythonVersionFile('python pypy3.9-7.3.10')).toEqual( + 'pypy3.9-7.3.10' + ); }); }); diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 9bdd45632..174b6dfa3 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -242,7 +242,7 @@ jobs: The python-version-file input accepts a path to a file containing the version of Python to be used by a project, for example .python-version, or .tool-versions. If both the python-version and the python-version-file inputs are provided then the python-version input is used. -> In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority. +>In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority. ```yaml steps: diff --git a/src/find-pypy.ts b/src/find-pypy.ts index a87dc844d..77b3b5bab 100644 --- a/src/find-pypy.ts +++ b/src/find-pypy.ts @@ -65,14 +65,17 @@ export async function findPyPyVersion( )); if (!installDir) { - ({installDir, resolvedPythonVersion, resolvedPyPyVersion} = - await pypyInstall.installPyPy( - pypyVersionSpec.pypyVersion, - pypyVersionSpec.pythonVersion, - architecture, - allowPreReleases, - releases - )); + ({ + installDir, + resolvedPythonVersion, + resolvedPyPyVersion + } = await pypyInstall.installPyPy( + pypyVersionSpec.pypyVersion, + pypyVersionSpec.pythonVersion, + architecture, + allowPreReleases, + releases + )); } const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; diff --git a/src/setup-python.ts b/src/setup-python.ts index a10b75160..e64dda388 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -5,7 +5,12 @@ import * as path from 'path'; import * as os from 'os'; import fs from 'fs'; import {getCacheDistributor} from './cache-distributions/cache-factory'; -import {parsePythonVersionFile, isCacheFeatureAvailable, logWarning, IS_MAC} from './utils'; +import { + parsePythonVersionFile, + isCacheFeatureAvailable, + logWarning, + IS_MAC +} from './utils'; function isPyPyVersion(versionSpec: string) { return versionSpec.startsWith('pypy'); @@ -43,7 +48,9 @@ function resolveVersionInput() { ); } - const version = parsePythonVersionFile(fs.readFileSync(versionFile, 'utf8')); + const version = parsePythonVersionFile( + fs.readFileSync(versionFile, 'utf8') + ); core.info(`Resolved ${versionFile} as ${version}`); return [version];