mirror of
https://github.com/actions/setup-python.git
synced 2025-06-24 04:38:00 +02:00
Compare commits
5 Commits
dependabot
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
fc0e5f6942 | |||
5db1cf9a59 | |||
a26af69be9 | |||
30eafe9548 | |||
5d95bc16d4 |
@ -24,7 +24,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -62,7 +61,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -103,7 +101,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -142,7 +139,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -184,7 +180,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -226,7 +221,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -258,7 +252,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -371,7 +364,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
@ -461,7 +453,6 @@ jobs:
|
||||
[
|
||||
macos-latest,
|
||||
windows-latest,
|
||||
ubuntu-20.04,
|
||||
ubuntu-22.04,
|
||||
ubuntu-22.04-arm,
|
||||
macos-13,
|
||||
|
26
.licenses/npm/lru-cache.dep.yml
generated
26
.licenses/npm/lru-cache.dep.yml
generated
@ -1,26 +0,0 @@
|
||||
---
|
||||
name: lru-cache
|
||||
version: 6.0.0
|
||||
type: npm
|
||||
summary: A cache object that deletes the least-recently-used items.
|
||||
homepage:
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.6.0
|
||||
version: 7.7.1
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
26
.licenses/npm/yallist.dep.yml
generated
26
.licenses/npm/yallist.dep.yml
generated
@ -1,26 +0,0 @@
|
||||
---
|
||||
name: yallist
|
||||
version: 4.0.0
|
||||
type: npm
|
||||
summary: Yet Another Linked List
|
||||
homepage:
|
||||
license: isc
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
notices: []
|
@ -7,6 +7,6 @@ Kivy-Garden==0.1.4
|
||||
packaging==20.7
|
||||
pdf2image==1.12.1
|
||||
Pygments==2.6.1
|
||||
requests==2.32.2
|
||||
requests==2.32.4
|
||||
urllib3==1.26.19
|
||||
xlrd==1.2.0
|
@ -40,7 +40,7 @@ pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3
|
||||
|
||||
pywin32-ctypes==0.2.0
|
||||
|
||||
requests==2.32.2
|
||||
requests==2.32.4
|
||||
|
||||
urllib3==1.26.19
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
validatePythonVersionFormatForPyPy,
|
||||
isCacheFeatureAvailable,
|
||||
getVersionInputFromFile,
|
||||
getVersionInputFromPlainFile,
|
||||
getVersionsInputFromPlainFile,
|
||||
getVersionInputFromTomlFile,
|
||||
getNextPageUrl,
|
||||
isGhes,
|
||||
@ -24,10 +24,10 @@ jest.mock('@actions/core');
|
||||
|
||||
describe('validatePythonVersionFormatForPyPy', () => {
|
||||
it.each([
|
||||
['3.6', true],
|
||||
['3.7', true],
|
||||
['3.6.x', false],
|
||||
['3.7.x', false],
|
||||
['3.12', true],
|
||||
['3.13', true],
|
||||
['3.12.x', false],
|
||||
['3.13.x', false],
|
||||
['3.x', false],
|
||||
['3', false]
|
||||
])('%s -> %s', (input, expected) => {
|
||||
@ -95,24 +95,52 @@ const tempDir = path.join(
|
||||
);
|
||||
|
||||
describe('Version from file test', () => {
|
||||
it.each([getVersionInputFromPlainFile, getVersionInputFromFile])(
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Version from plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'python-version.file';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersionFileContent = '3.7';
|
||||
const pythonVersionFileContent = '3.13';
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersionFileContent]);
|
||||
}
|
||||
);
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Versions from multiline plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'python-version.file';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersionFileContent = '3.13\r\n3.12';
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual(['3.13', '3.12']);
|
||||
}
|
||||
);
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Version from complex plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'python-version.file';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersionFileContent =
|
||||
'3.13/envs/virtualenv\r# 3.12\n3.11\r\n3.10\r\n 3.9 \r\n';
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual([
|
||||
'3.13',
|
||||
'3.11',
|
||||
'3.10',
|
||||
'3.9'
|
||||
]);
|
||||
}
|
||||
);
|
||||
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
|
||||
'Version from standard pyproject.toml test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'pyproject.toml';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersion = '>=3.7.0';
|
||||
const pythonVersion = '>=3.13.0';
|
||||
const pythonVersionFileContent = `[project]\nrequires-python = "${pythonVersion}"`;
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
|
||||
@ -124,7 +152,7 @@ describe('Version from file test', () => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'pyproject.toml';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersion = '>=3.7.0';
|
||||
const pythonVersion = '>=3.13.0';
|
||||
const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${pythonVersion}"`;
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
|
||||
@ -145,9 +173,9 @@ describe('Version from file test', () => {
|
||||
async _fn => {
|
||||
const toolVersionFileName = '.tool-versions';
|
||||
const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
|
||||
const toolVersionContent = 'python 3.9.10\nnodejs 16';
|
||||
const toolVersionContent = 'python 3.13.2\nnodejs 16';
|
||||
fs.writeFileSync(toolVersionFilePath, toolVersionContent);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -156,9 +184,9 @@ describe('Version from file test', () => {
|
||||
async _fn => {
|
||||
const toolVersionFileName = '.tool-versions';
|
||||
const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
|
||||
const toolVersionContent = '# python 3.8\npython 3.9';
|
||||
const toolVersionContent = '# python 3.13\npython 3.12';
|
||||
fs.writeFileSync(toolVersionFilePath, toolVersionContent);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.9']);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.12']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -167,9 +195,9 @@ describe('Version from file test', () => {
|
||||
async _fn => {
|
||||
const toolVersionFileName = '.tool-versions';
|
||||
const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
|
||||
const toolVersionContent = ' python 3.10 ';
|
||||
const toolVersionContent = ' python 3.13 ';
|
||||
fs.writeFileSync(toolVersionFilePath, toolVersionContent);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.10']);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.13']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -178,9 +206,9 @@ describe('Version from file test', () => {
|
||||
async _fn => {
|
||||
const toolVersionFileName = '.tool-versions';
|
||||
const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
|
||||
const toolVersionContent = 'python v3.9.10';
|
||||
const toolVersionContent = 'python v3.13.2';
|
||||
fs.writeFileSync(toolVersionFilePath, toolVersionContent);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -189,9 +217,9 @@ describe('Version from file test', () => {
|
||||
async _fn => {
|
||||
const toolVersionFileName = '.tool-versions';
|
||||
const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
|
||||
const toolVersionContent = 'python pypy3.10-7.3.14';
|
||||
const toolVersionContent = 'python pypy3.10-7.3.19';
|
||||
fs.writeFileSync(toolVersionFilePath, toolVersionContent);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.14']);
|
||||
expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.19']);
|
||||
}
|
||||
);
|
||||
|
||||
|
966
dist/setup/index.js
vendored
966
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
42
package-lock.json
generated
42
package-lock.json
generated
@ -17,12 +17,12 @@
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@iarna/toml": "^3.0.0",
|
||||
"semver": "^7.6.0"
|
||||
"semver": "^7.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.11.25",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
@ -32,8 +32,8 @@
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^29.3.0",
|
||||
"prettier": "^3.5.3",
|
||||
"ts-jest": "^29.3.2",
|
||||
"typescript": "^5.4.2"
|
||||
}
|
||||
},
|
||||
@ -1620,10 +1620,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/semver": {
|
||||
"version": "7.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz",
|
||||
"integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
|
||||
"dev": true
|
||||
"version": "7.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz",
|
||||
"integrity": "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/stack-utils": {
|
||||
"version": "2.0.3",
|
||||
@ -4644,15 +4645,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"version": "3.5.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
|
||||
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
@ -5123,9 +5125,9 @@
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
"version": "29.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.0.tgz",
|
||||
"integrity": "sha512-4bfGBX7Gd1Aqz3SyeDS9O276wEU/BInZxskPrbhZLyv+c1wskDCqDFMJQJLWrIr/fKoAH4GE5dKUlrdyvo+39A==",
|
||||
"version": "29.3.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.2.tgz",
|
||||
"integrity": "sha512-bJJkrWc6PjFVz5g2DGCNUo8z7oFEYaz1xP1NpeDU7KNLMWPpEyV8Chbpkn8xjzgRDpQhnGMyvyldoL7h8JXyug==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -5137,7 +5139,7 @@
|
||||
"lodash.memoize": "^4.1.2",
|
||||
"make-error": "^1.3.6",
|
||||
"semver": "^7.7.1",
|
||||
"type-fest": "^4.37.0",
|
||||
"type-fest": "^4.39.1",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"bin": {
|
||||
@ -5173,9 +5175,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ts-jest/node_modules/type-fest": {
|
||||
"version": "4.38.0",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.38.0.tgz",
|
||||
"integrity": "sha512-2dBz5D5ycHIoliLYLi0Q2V7KRaDlH0uWIvmk7TYlAg5slqwiPv1ezJdZm1QEM0xgk29oYWMCbIG7E6gHpvChlg==",
|
||||
"version": "4.40.0",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.40.0.tgz",
|
||||
"integrity": "sha512-ABHZ2/tS2JkvH1PEjxFDTUWC8dB5OsIGZP4IFLhR293GqT5Y5qB1WwL2kMPYhQW9DVgVD8Hd7I8gjwPIf5GFkw==",
|
||||
"dev": true,
|
||||
"license": "(MIT OR CC0-1.0)",
|
||||
"engines": {
|
||||
|
@ -33,12 +33,12 @@
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"@iarna/toml": "^3.0.0",
|
||||
"semver": "^7.6.0"
|
||||
"semver": "^7.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^20.11.25",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
@ -48,8 +48,8 @@
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^29.3.0",
|
||||
"prettier": "^3.5.3",
|
||||
"ts-jest": "^29.3.2",
|
||||
"typescript": "^5.4.2"
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
logWarning,
|
||||
IS_MAC,
|
||||
getVersionInputFromFile,
|
||||
getVersionInputFromPlainFile
|
||||
getVersionsInputFromPlainFile
|
||||
} from './utils';
|
||||
|
||||
function isPyPyVersion(versionSpec: string) {
|
||||
@ -35,7 +35,7 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
|
||||
|
||||
function resolveVersionInputFromDefaultFile(): string[] {
|
||||
const couples: [string, (versionFile: string) => string[]][] = [
|
||||
['.python-version', getVersionInputFromPlainFile]
|
||||
['.python-version', getVersionsInputFromPlainFile]
|
||||
];
|
||||
for (const [versionFile, _fn] of couples) {
|
||||
logWarning(
|
||||
|
31
src/utils.ts
31
src/utils.ts
@ -228,7 +228,7 @@ function extractValue(obj: any, keys: string[]): string | undefined {
|
||||
* If none is present, returns an empty list.
|
||||
*/
|
||||
export function getVersionInputFromTomlFile(versionFile: string): string[] {
|
||||
core.debug(`Trying to resolve version form ${versionFile}`);
|
||||
core.debug(`Trying to resolve version from ${versionFile}`);
|
||||
|
||||
let pyprojectFile = fs.readFileSync(versionFile, 'utf8');
|
||||
// Normalize the line endings in the pyprojectFile
|
||||
@ -269,13 +269,28 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Python version extracted from a plain text file.
|
||||
* Python versions extracted from a plain text file.
|
||||
* - Resolves multiple versions from multiple lines.
|
||||
* - Handles pyenv-virtualenv pointers (e.g. `3.10/envs/virtualenv`).
|
||||
* - Ignores empty lines and lines starting with `#`
|
||||
* - Trims whitespace.
|
||||
*/
|
||||
export function getVersionInputFromPlainFile(versionFile: string): string[] {
|
||||
core.debug(`Trying to resolve version form ${versionFile}`);
|
||||
const version = fs.readFileSync(versionFile, 'utf8').trim();
|
||||
core.info(`Resolved ${versionFile} as ${version}`);
|
||||
return [version];
|
||||
export function getVersionsInputFromPlainFile(versionFile: string): string[] {
|
||||
core.debug(`Trying to resolve versions from ${versionFile}`);
|
||||
const content = fs.readFileSync(versionFile, 'utf8').trim();
|
||||
const lines = content.split(/\r\n|\r|\n/);
|
||||
const versions = lines
|
||||
.map(line => {
|
||||
if (line.startsWith('#') || line.trim() === '') {
|
||||
return undefined;
|
||||
}
|
||||
let version: string = line.trim();
|
||||
version = version.split('/')[0];
|
||||
return version;
|
||||
})
|
||||
.filter(version => version !== undefined) as string[];
|
||||
core.info(`Resolved ${versionFile} as ${versions.join(', ')}`);
|
||||
return versions;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,7 +334,7 @@ export function getVersionInputFromFile(versionFile: string): string[] {
|
||||
} else if (versionFile.match('.tool-versions')) {
|
||||
return getVersionInputFromToolVersions(versionFile);
|
||||
} else {
|
||||
return getVersionInputFromPlainFile(versionFile);
|
||||
return getVersionsInputFromPlainFile(versionFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user