mirror of
https://github.com/actions/setup-python.git
synced 2025-07-04 00:23:47 +00:00
Add pypy unit tests to cover code
* add tests * Update test-pypy.yml * Update test-python.yml * Update test-python.yml * Update README.md * fixing tests * change order Co-authored-by: Maxim Lobanov <v-malob@microsoft.com>
This commit is contained in:
parent
fed9c7c1fc
commit
e6c917a949
10 changed files with 1063 additions and 84 deletions
69
dist/index.js
vendored
69
dist/index.js
vendored
|
@ -1138,7 +1138,7 @@ function findPyPyToolCache(pythonVersion, pypyVersion, architecture) {
|
|||
// 'tc.find' finds tool based on Python version but we also need to check
|
||||
// whether PyPy version satisfies requested version.
|
||||
resolvedPythonVersion = utils_1.getPyPyVersionFromPath(installDir);
|
||||
resolvedPyPyVersion = pypyInstall.readExactPyPyVersion(installDir);
|
||||
resolvedPyPyVersion = utils_1.readExactPyPyVersionFile(installDir);
|
||||
const isPyPyVersionSatisfies = semver.satisfies(resolvedPyPyVersion, pypyVersion);
|
||||
if (!isPyPyVersionSatisfies) {
|
||||
installDir = null;
|
||||
|
@ -2308,6 +2308,9 @@ exports.debug = debug; // for test
|
|||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
|
@ -2316,11 +2319,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const fs_1 = __importDefault(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const semver = __importStar(__webpack_require__(876));
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
exports.IS_LINUX = process.platform === 'linux';
|
||||
const PYPY_VERSION_FILE = 'PYPY_VERSION';
|
||||
/** create Symlinks for downloaded PyPy
|
||||
* It should be executed only for downloaded versions in runtime, because
|
||||
* toolcache versions have this setup.
|
||||
|
@ -2328,12 +2332,12 @@ exports.IS_LINUX = process.platform === 'linux';
|
|||
function createSymlinkInFolder(folderPath, sourceName, targetName, setExecutable = false) {
|
||||
const sourcePath = path.join(folderPath, sourceName);
|
||||
const targetPath = path.join(folderPath, targetName);
|
||||
if (fs.existsSync(targetPath)) {
|
||||
if (fs_1.default.existsSync(targetPath)) {
|
||||
return;
|
||||
}
|
||||
fs.symlinkSync(sourcePath, targetPath);
|
||||
fs_1.default.symlinkSync(sourcePath, targetPath);
|
||||
if (!exports.IS_WINDOWS && setExecutable) {
|
||||
fs.chmodSync(targetPath, '755');
|
||||
fs_1.default.chmodSync(targetPath, '755');
|
||||
}
|
||||
}
|
||||
exports.createSymlinkInFolder = createSymlinkInFolder;
|
||||
|
@ -2349,6 +2353,28 @@ function getPyPyVersionFromPath(installDir) {
|
|||
return path.basename(path.dirname(installDir));
|
||||
}
|
||||
exports.getPyPyVersionFromPath = getPyPyVersionFromPath;
|
||||
/**
|
||||
* In tool-cache, we put PyPy to '<toolcache_root>/PyPy/<python_version>/x64'
|
||||
* There is no easy way to determine what PyPy version is located in specific folder
|
||||
* 'pypy --version' is not reliable enough since it is not set properly for preview versions
|
||||
* "7.3.3rc1" is marked as '7.3.3' in 'pypy --version'
|
||||
* so we put PYPY_VERSION file to PyPy directory when install it to VM and read it when we need to know version
|
||||
* PYPY_VERSION contains exact version from 'versions.json'
|
||||
*/
|
||||
function readExactPyPyVersionFile(installDir) {
|
||||
let pypyVersion = '';
|
||||
let fileVersion = path.join(installDir, PYPY_VERSION_FILE);
|
||||
if (fs_1.default.existsSync(fileVersion)) {
|
||||
pypyVersion = fs_1.default.readFileSync(fileVersion).toString();
|
||||
}
|
||||
return pypyVersion;
|
||||
}
|
||||
exports.readExactPyPyVersionFile = readExactPyPyVersionFile;
|
||||
function writeExactPyPyVersionFile(installDir, resolvedPyPyVersion) {
|
||||
const pypyFilePath = path.join(installDir, PYPY_VERSION_FILE);
|
||||
fs_1.default.writeFileSync(pypyFilePath, resolvedPyPyVersion);
|
||||
}
|
||||
exports.writeExactPyPyVersionFile = writeExactPyPyVersionFile;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
@ -2767,6 +2793,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
|
@ -2774,9 +2803,8 @@ const tc = __importStar(__webpack_require__(533));
|
|||
const semver = __importStar(__webpack_require__(876));
|
||||
const httpm = __importStar(__webpack_require__(539));
|
||||
const exec = __importStar(__webpack_require__(986));
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const fs_1 = __importDefault(__webpack_require__(747));
|
||||
const utils_1 = __webpack_require__(163);
|
||||
const PYPY_VERSION_FILE = 'PYPY_VERSION';
|
||||
function installPyPy(pypyVersion, pythonVersion, architecture) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let downloadDir;
|
||||
|
@ -2801,13 +2829,13 @@ function installPyPy(pypyVersion, pythonVersion, architecture) {
|
|||
}
|
||||
// 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.readdirSync(downloadDir)[0];
|
||||
const archiveName = fs_1.default.readdirSync(downloadDir)[0];
|
||||
const toolDir = path.join(downloadDir, archiveName);
|
||||
let installDir = toolDir;
|
||||
if (!utils_1.isNightlyKeyword(resolvedPyPyVersion)) {
|
||||
installDir = yield tc.cacheDir(toolDir, 'PyPy', resolvedPythonVersion, architecture);
|
||||
}
|
||||
writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
||||
utils_1.writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
||||
const binaryPath = getPyPyBinaryPath(installDir);
|
||||
yield createPyPySymlink(binaryPath, resolvedPythonVersion);
|
||||
yield installPip(binaryPath);
|
||||
|
@ -2871,29 +2899,6 @@ function findRelease(releases, pythonVersion, pypyVersion, architecture) {
|
|||
};
|
||||
}
|
||||
exports.findRelease = findRelease;
|
||||
// helper functions
|
||||
/**
|
||||
* In tool-cache, we put PyPy to '<toolcache_root>/PyPy/<python_version>/x64'
|
||||
* There is no easy way to determine what PyPy version is located in specific folder
|
||||
* 'pypy --version' is not reliable enough since it is not set properly for preview versions
|
||||
* "7.3.3rc1" is marked as '7.3.3' in 'pypy --version'
|
||||
* so we put PYPY_VERSION file to PyPy directory when install it to VM and read it when we need to know version
|
||||
* PYPY_VERSION contains exact version from 'versions.json'
|
||||
*/
|
||||
function readExactPyPyVersion(installDir) {
|
||||
let pypyVersion = '';
|
||||
let fileVersion = path.join(installDir, PYPY_VERSION_FILE);
|
||||
if (fs.existsSync(fileVersion)) {
|
||||
pypyVersion = fs.readFileSync(fileVersion).toString();
|
||||
core.debug(`Version from ${PYPY_VERSION_FILE} file is ${pypyVersion}`);
|
||||
}
|
||||
return pypyVersion;
|
||||
}
|
||||
exports.readExactPyPyVersion = readExactPyPyVersion;
|
||||
function writeExactPyPyVersionFile(installDir, resolvedPyPyVersion) {
|
||||
const pypyFilePath = path.join(installDir, PYPY_VERSION_FILE);
|
||||
fs.writeFileSync(pypyFilePath, resolvedPyPyVersion);
|
||||
}
|
||||
/** Get PyPy 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue