add check-latest for pypy

This commit is contained in:
Dmitry Shibanov 2022-05-06 09:50:12 +02:00
parent 58a8109aea
commit 8723b8aa5a
8 changed files with 165 additions and 31 deletions

View file

@ -58,3 +58,36 @@ jobs:
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version ${EXECUTABLE} --version
shell: bash shell: bash
check-latest:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Setup PyPy and check latest
uses: ./
with:
python-version: 'pypy-3.7-v7.3.x'
check-latest: true
- name: PyPy and Python version
run: python --version
- name: Run simple code
run: python -c 'import math; print(math.factorial(5))'
- name: Assert PyPy is running
run: |
import platform
assert platform.python_implementation().lower() == "pypy"
shell: python
- name: Assert expected binaries (or symlinks) are present
run: |
EXECUTABLE=${{ matrix.pypy }}
EXECUTABLE=${EXECUTABLE/-/} # remove the first '-' in "pypy-X.Y" -> "pypyX.Y" to match executable name
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
${EXECUTABLE} --version
shell: bash

View file

@ -5,6 +5,7 @@ import {HttpClient} from '@actions/http-client';
import * as ifm from '@actions/http-client/interfaces'; import * as ifm from '@actions/http-client/interfaces';
import * as tc from '@actions/tool-cache'; import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec'; import * as exec from '@actions/exec';
import * as core from '@actions/core';
import * as path from 'path'; import * as path from 'path';
import * as semver from 'semver'; import * as semver from 'semver';
@ -13,7 +14,6 @@ import * as finder from '../src/find-pypy';
import { import {
IPyPyManifestRelease, IPyPyManifestRelease,
IS_WINDOWS, IS_WINDOWS,
validateVersion,
getPyPyVersionFromPath getPyPyVersionFromPath
} from '../src/utils'; } from '../src/utils';
@ -117,6 +117,8 @@ describe('findPyPyToolCache', () => {
}); });
describe('findPyPyVersion', () => { describe('findPyPyVersion', () => {
let getBooleanInputSpy: jest.SpyInstance;
let infoSpy: jest.SpyInstance;
let tcFind: jest.SpyInstance; let tcFind: jest.SpyInstance;
let spyExtractZip: jest.SpyInstance; let spyExtractZip: jest.SpyInstance;
let spyExtractTar: jest.SpyInstance; let spyExtractTar: jest.SpyInstance;
@ -132,6 +134,12 @@ describe('findPyPyVersion', () => {
let spyChmodSync: jest.SpyInstance; let spyChmodSync: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
getBooleanInputSpy.mockImplementation(() => false);
infoSpy = jest.spyOn(core, 'info');
infoSpy.mockImplementation(() => {});
tcFind = jest.spyOn(tc, 'find'); tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation((tool: string, version: string) => { tcFind.mockImplementation((tool: string, version: string) => {
const semverRange = new semver.Range(version); const semverRange = new semver.Range(version);
@ -193,7 +201,7 @@ describe('findPyPyVersion', () => {
it('found PyPy in toolcache', async () => { it('found PyPy in toolcache', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture) finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture, false)
).resolves.toEqual({ ).resolves.toEqual({
resolvedPythonVersion: '3.6.12', resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.3.3' resolvedPyPyVersion: '7.3.3'
@ -202,13 +210,13 @@ describe('findPyPyVersion', () => {
it('throw on invalid input format', async () => { it('throw on invalid input format', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture) finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, false)
).rejects.toThrow(); ).rejects.toThrow();
}); });
it('throw on invalid input format pypy3.7-7.3.x', async () => { it('throw on invalid input format pypy3.7-7.3.x', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture) finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, false)
).rejects.toThrow(); ).rejects.toThrow();
}); });
@ -220,7 +228,7 @@ describe('findPyPyVersion', () => {
spyChmodSync = jest.spyOn(fs, 'chmodSync'); spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined); spyChmodSync.mockImplementation(() => undefined);
await expect( await expect(
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture) finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, false)
).resolves.toEqual({ ).resolves.toEqual({
resolvedPythonVersion: '3.7.9', resolvedPythonVersion: '3.7.9',
resolvedPyPyVersion: '7.3.3' resolvedPyPyVersion: '7.3.3'
@ -229,9 +237,61 @@ describe('findPyPyVersion', () => {
it('throw if release is not found', async () => { it('throw if release is not found', async () => {
await expect( await expect(
finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture) finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture, false)
).rejects.toThrowError( ).rejects.toThrowError(
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found` `PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
); );
}); });
it('check-latest enabled version found and used from toolcache', async () => {
await expect(
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture, true)
).resolves.toEqual({
resolvedPythonVersion: '3.6.12',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as PyPy 7.3.3 with Python (3.6.12)'
);
});
it('check-latest enabled version found and install successfully', async () => {
spyCacheDir = jest.spyOn(tc, 'cacheDir');
spyCacheDir.mockImplementation(() =>
path.join(toolDir, 'PyPy', '3.7.7', architecture)
);
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, true)
).resolves.toEqual({
resolvedPythonVersion: '3.7.9',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as PyPy 7.3.3 with Python (3.7.9)'
);
});
it('check-latest enabled version is not found and used from toolcache', async () => {
tcFind.mockImplementationOnce((tool: string, version: string) => {
const semverRange = new semver.Range(version);
let pypyPath = '';
if (semver.satisfies('3.8.8', semverRange)) {
pypyPath = path.join(toolDir, 'PyPy', '3.8.8', architecture);
}
return pypyPath;
});
await expect(
finder.findPyPyVersion('pypy-3.8-v7.3.x', architecture, true)
).resolves.toEqual({
resolvedPythonVersion: '3.8.8',
resolvedPyPyVersion: '7.3.3'
});
expect(infoSpy).toHaveBeenCalledWith(
'Failed to resolve PyPy v7.3.x with Python (3.8) from manifest'
);
});
}); });

View file

@ -40,7 +40,7 @@ describe('Finder tests', () => {
await io.mkdirP(pythonDir); await io.mkdirP(pythonDir);
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); fs.writeFileSync(`${pythonDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
await finder.useCpythonVersion('3.x', 'x64'); await finder.useCpythonVersion('3.x', 'x64', false);
}); });
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => { it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
@ -60,7 +60,7 @@ describe('Finder tests', () => {
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); fs.writeFileSync(`${pythonDir}.complete`, 'hello');
}); });
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
await finder.useCpythonVersion('1.2.3', 'x64'); await finder.useCpythonVersion('1.2.3', 'x64', false);
}); });
it('Finds pre-release Python version in the manifest', async () => { it('Finds pre-release Python version in the manifest', async () => {
@ -85,7 +85,7 @@ describe('Finder tests', () => {
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); fs.writeFileSync(`${pythonDir}.complete`, 'hello');
}); });
// This will throw if it doesn't find it in the manifest (because no such version exists) // This will throw if it doesn't find it in the manifest (because no such version exists)
await finder.useCpythonVersion('1.2.3-beta.2', 'x64'); await finder.useCpythonVersion('1.2.3-beta.2', 'x64', false);
}); });
it('Check-latest true, finds the latest version in the manifest', async () => { it('Check-latest true, finds the latest version in the manifest', async () => {
@ -128,7 +128,7 @@ describe('Finder tests', () => {
fs.writeFileSync(`${pythonDir}.complete`, 'hello'); fs.writeFileSync(`${pythonDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
await finder.useCpythonVersion('1.2', 'x64'); await finder.useCpythonVersion('1.2', 'x64', true);
expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'"); expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'");
expect(infoSpy).toHaveBeenCalledWith('Version 1.2.3 was not found in the local cache'); expect(infoSpy).toHaveBeenCalledWith('Version 1.2.3 was not found in the local cache');
@ -139,7 +139,7 @@ describe('Finder tests', () => {
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists) // This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
let thrown = false; let thrown = false;
try { try {
await finder.useCpythonVersion('3.300000', 'x64'); await finder.useCpythonVersion('3.300000', 'x64', false);
} catch { } catch {
thrown = true; thrown = true;
} }

34
dist/setup/index.js vendored
View file

@ -5612,16 +5612,17 @@ function run() {
} }
try { try {
const version = core.getInput('python-version'); const version = core.getInput('python-version');
const checkLatest = core.getBooleanInput('check-latest');
if (version) { if (version) {
let pythonVersion; let pythonVersion;
const arch = core.getInput('architecture') || os.arch(); const arch = core.getInput('architecture') || os.arch();
if (isPyPyVersion(version)) { if (isPyPyVersion(version)) {
const installed = yield finderPyPy.findPyPyVersion(version, arch); const installed = yield finderPyPy.findPyPyVersion(version, arch, checkLatest);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`); core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
} }
else { else {
const installed = yield finder.useCpythonVersion(version, arch); const installed = yield finder.useCpythonVersion(version, arch, checkLatest);
pythonVersion = installed.version; pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`); core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
} }
@ -9739,7 +9740,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.findAssetForMacOrLinux = exports.findAssetForWindows = exports.isArchPresentForMacOrLinux = exports.isArchPresentForWindows = exports.pypyVersionToSemantic = exports.getPyPyBinaryPath = exports.findRelease = exports.installPyPy = void 0; exports.findAssetForMacOrLinux = exports.findAssetForWindows = exports.isArchPresentForMacOrLinux = exports.isArchPresentForWindows = exports.pypyVersionToSemantic = exports.getPyPyBinaryPath = exports.findRelease = exports.getAvailablePyPyVersions = exports.installPyPy = void 0;
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
@ -9748,10 +9749,10 @@ const httpm = __importStar(__webpack_require__(539));
const exec = __importStar(__webpack_require__(986)); const exec = __importStar(__webpack_require__(986));
const fs_1 = __importDefault(__webpack_require__(747)); const fs_1 = __importDefault(__webpack_require__(747));
const utils_1 = __webpack_require__(163); const utils_1 = __webpack_require__(163);
function installPyPy(pypyVersion, pythonVersion, architecture) { function installPyPy(pypyVersion, pythonVersion, architecture, releases) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let downloadDir; let downloadDir;
const releases = yield getAvailablePyPyVersions(); releases !== null && releases !== void 0 ? releases : (releases = yield getAvailablePyPyVersions());
if (!releases || releases.length === 0) { if (!releases || releases.length === 0) {
throw new Error('No release was found in PyPy version.json'); throw new Error('No release was found in PyPy version.json');
} }
@ -9797,6 +9798,7 @@ function getAvailablePyPyVersions() {
return response.result; return response.result;
}); });
} }
exports.getAvailablePyPyVersions = getAvailablePyPyVersions;
function createPyPySymlink(pypyBinaryPath, pythonVersion) { function createPyPySymlink(pypyBinaryPath, pythonVersion) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const version = semver.coerce(pythonVersion); const version = semver.coerce(pythonVersion);
@ -52248,19 +52250,34 @@ const utils_1 = __webpack_require__(163);
const semver = __importStar(__webpack_require__(876)); const semver = __importStar(__webpack_require__(876));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
const tc = __importStar(__webpack_require__(533)); const tc = __importStar(__webpack_require__(533));
function findPyPyVersion(versionSpec, architecture) { function findPyPyVersion(versionSpec, architecture, checkLatest) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let resolvedPyPyVersion = ''; let resolvedPyPyVersion = '';
let resolvedPythonVersion = ''; let resolvedPythonVersion = '';
let installDir; let installDir;
let releases;
const pypyVersionSpec = parsePyPyVersion(versionSpec); const pypyVersionSpec = parsePyPyVersion(versionSpec);
if (checkLatest) {
releases = yield pypyInstall.getAvailablePyPyVersions();
if (releases && releases.length > 0) {
const releaseData = pypyInstall.findRelease(releases, pypyVersionSpec.pythonVersion, pypyVersionSpec.pypyVersion, architecture);
if (releaseData) {
core.info(`Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})`);
pypyVersionSpec.pythonVersion = releaseData.resolvedPythonVersion;
pypyVersionSpec.pypyVersion = releaseData.resolvedPyPyVersion;
}
else {
core.info(`Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest`);
}
}
}
({ installDir, resolvedPythonVersion, resolvedPyPyVersion } = findPyPyToolCache(pypyVersionSpec.pythonVersion, pypyVersionSpec.pypyVersion, architecture)); ({ installDir, resolvedPythonVersion, resolvedPyPyVersion } = findPyPyToolCache(pypyVersionSpec.pythonVersion, pypyVersionSpec.pypyVersion, architecture));
if (!installDir) { if (!installDir) {
({ ({
installDir, installDir,
resolvedPythonVersion, resolvedPythonVersion,
resolvedPyPyVersion resolvedPyPyVersion
} = yield pypyInstall.installPyPy(pypyVersionSpec.pypyVersion, pypyVersionSpec.pythonVersion, architecture)); } = yield pypyInstall.installPyPy(pypyVersionSpec.pypyVersion, pypyVersionSpec.pythonVersion, architecture, releases));
} }
const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin'; const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin';
const _binDir = path.join(installDir, pipDir); const _binDir = path.join(installDir, pipDir);
@ -56880,14 +56897,13 @@ function binDir(installDir) {
return path.join(installDir, 'bin'); return path.join(installDir, 'bin');
} }
} }
function useCpythonVersion(version, architecture) { function useCpythonVersion(version, architecture, checkLatest) {
var _a; var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let manifest = null; let manifest = null;
const desugaredVersionSpec = desugarDevVersion(version); const desugaredVersionSpec = desugarDevVersion(version);
let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec); let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`); core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
const checkLatest = core.getBooleanInput('check-latest');
if (checkLatest) { if (checkLatest) {
manifest = yield installer.getManifest(); manifest = yield installer.getManifest();
const resolvedVersion = (_a = (yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))) === null || _a === void 0 ? void 0 : _a.version; const resolvedVersion = (_a = (yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))) === null || _a === void 0 ? void 0 : _a.version;

View file

@ -6,7 +6,8 @@ import {
validateVersion, validateVersion,
getPyPyVersionFromPath, getPyPyVersionFromPath,
readExactPyPyVersionFile, readExactPyPyVersionFile,
validatePythonVersionFormatForPyPy validatePythonVersionFormatForPyPy,
IPyPyManifestRelease
} from './utils'; } from './utils';
import * as semver from 'semver'; import * as semver from 'semver';
@ -20,14 +21,36 @@ interface IPyPyVersionSpec {
export async function findPyPyVersion( export async function findPyPyVersion(
versionSpec: string, versionSpec: string,
architecture: string architecture: string,
checkLatest: boolean
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> { ): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
let resolvedPyPyVersion = ''; let resolvedPyPyVersion = '';
let resolvedPythonVersion = ''; let resolvedPythonVersion = '';
let installDir: string | null; let installDir: string | null;
let releases: IPyPyManifestRelease[] | undefined;
const pypyVersionSpec = parsePyPyVersion(versionSpec); const pypyVersionSpec = parsePyPyVersion(versionSpec);
if (checkLatest) {
releases = await pypyInstall.getAvailablePyPyVersions();
if (releases && releases.length > 0) {
const releaseData = pypyInstall.findRelease(
releases,
pypyVersionSpec.pythonVersion,
pypyVersionSpec.pypyVersion,
architecture
);
if(releaseData) {
core.info(`Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})`);
pypyVersionSpec.pythonVersion = releaseData.resolvedPythonVersion;
pypyVersionSpec.pypyVersion = releaseData.resolvedPyPyVersion;
} else {
core.info(`Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest`);
}
}
}
({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache( ({installDir, resolvedPythonVersion, resolvedPyPyVersion} = findPyPyToolCache(
pypyVersionSpec.pythonVersion, pypyVersionSpec.pythonVersion,
pypyVersionSpec.pypyVersion, pypyVersionSpec.pypyVersion,
@ -42,7 +65,8 @@ export async function findPyPyVersion(
} = await pypyInstall.installPyPy( } = await pypyInstall.installPyPy(
pypyVersionSpec.pypyVersion, pypyVersionSpec.pypyVersion,
pypyVersionSpec.pythonVersion, pypyVersionSpec.pythonVersion,
architecture architecture,
releases
)); ));
} }

View file

@ -32,15 +32,14 @@ function binDir(installDir: string): string {
export async function useCpythonVersion( export async function useCpythonVersion(
version: string, version: string,
architecture: string architecture: string,
checkLatest: boolean
): Promise<InstalledVersion> { ): Promise<InstalledVersion> {
let manifest: tc.IToolRelease[] | null = null; let manifest: tc.IToolRelease[] | null = null;
const desugaredVersionSpec = desugarDevVersion(version); const desugaredVersionSpec = desugarDevVersion(version);
let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec); let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`); core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
const checkLatest = core.getBooleanInput('check-latest');
if (checkLatest) { if (checkLatest) {
manifest = await installer.getManifest(); manifest = await installer.getManifest();
const resolvedVersion = (await installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))?.version; const resolvedVersion = (await installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))?.version;

View file

@ -19,11 +19,12 @@ import {
export async function installPyPy( export async function installPyPy(
pypyVersion: string, pypyVersion: string,
pythonVersion: string, pythonVersion: string,
architecture: string architecture: string,
releases: IPyPyManifestRelease[] | undefined
) { ) {
let downloadDir; let downloadDir;
const releases = await getAvailablePyPyVersions(); releases ??= await getAvailablePyPyVersions();
if (!releases || releases.length === 0) { if (!releases || releases.length === 0) {
throw new Error('No release was found in PyPy version.json'); throw new Error('No release was found in PyPy version.json');
} }
@ -78,7 +79,7 @@ export async function installPyPy(
return {installDir, resolvedPythonVersion, resolvedPyPyVersion}; return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
} }
async function getAvailablePyPyVersions() { export async function getAvailablePyPyVersions() {
const url = 'https://downloads.python.org/pypy/versions.json'; const url = 'https://downloads.python.org/pypy/versions.json';
const http: httpm.HttpClient = new httpm.HttpClient('tool-cache'); const http: httpm.HttpClient = new httpm.HttpClient('tool-cache');

View file

@ -34,17 +34,18 @@ async function run() {
} }
try { try {
const version = core.getInput('python-version'); const version = core.getInput('python-version');
const checkLatest = core.getBooleanInput('check-latest');
if (version) { if (version) {
let pythonVersion: string; let pythonVersion: string;
const arch: string = core.getInput('architecture') || os.arch(); const arch: string = core.getInput('architecture') || os.arch();
if (isPyPyVersion(version)) { if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion(version, arch); const installed = await finderPyPy.findPyPyVersion(version, arch, checkLatest);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info( core.info(
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})` `Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
); );
} else { } else {
const installed = await finder.useCpythonVersion(version, arch); const installed = await finder.useCpythonVersion(version, arch, checkLatest);
pythonVersion = installed.version; pythonVersion = installed.version;
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`); core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
} }