resolved comments, update readme, add e2e tests.

This commit is contained in:
Dmitry Shibanov 2020-12-15 16:27:56 +03:00 committed by GitHub
parent 739154f76b
commit 3d613a97df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 180 additions and 38 deletions

View file

@ -1,6 +1,6 @@
import * as path from 'path';
import * as pypyInstall from './install-pypy';
import {IS_WINDOWS} from './utils';
import {IS_WINDOWS, validateVersion} from './utils';
import * as semver from 'semver';
import * as core from '@actions/core';
@ -93,10 +93,12 @@ function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
const versions = versionSpec.split('-').filter(item => !!item);
if (versions.length < 2) {
throw new Error(
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See readme for more examples."
core.setFailed(
"Invalid 'version' property for PyPy. PyPy version should be specified as 'pypy-<python-version>'. See README for examples and documentation."
);
process.exit();
}
const pythonVersion = versions[1];
let pypyVersion: string;
if (versions.length > 2) {
@ -105,6 +107,13 @@ function parsePyPyVersion(versionSpec: string): IPyPyVersionSpec {
pypyVersion = 'x';
}
if (!validateVersion(pythonVersion) || !validateVersion(pypyVersion)) {
core.setFailed(
"Invalid 'version' property for PyPy. Both Python version and PyPy versions should satisfy SemVer notation. See README for examples and documentation."
);
process.exit();
}
return {
pypyVersion: pypyVersion,
pythonVersion: pythonVersion