Compare commits

..

No commits in common. "main" and "v5.5.0" have entirely different histories.
main ... v5.5.0

17 changed files with 999 additions and 425 deletions

View File

@ -78,12 +78,8 @@ jobs:
python-version: pypy-3.11-v7.x python-version: pypy-3.11-v7.x
- os: ubuntu-22.04 - os: ubuntu-22.04
python-version: pypy-3.11-v7.x python-version: pypy-3.11-v7.x
- os: ubuntu-22.04-arm
python-version: pypy-3.10-v7.x
- os: ubuntu-22.04-arm - os: ubuntu-22.04-arm
python-version: pypy-3.11-v7.x python-version: pypy-3.11-v7.x
- os: ubuntu-22.04-arm
python-version: pypy-3.10-v7.x
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Python - name: Setup Python

View File

@ -19,6 +19,7 @@ jobs:
matrix: matrix:
operating-system: operating-system:
[ [
ubuntu-20.04,
windows-latest, windows-latest,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,

View File

@ -21,6 +21,7 @@ jobs:
os: os:
[ [
macos-latest, macos-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,
@ -76,6 +77,7 @@ jobs:
os: os:
[ [
macos-latest, macos-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,

View File

@ -24,6 +24,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,
@ -141,6 +142,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,
@ -175,6 +177,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,
@ -217,6 +220,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
ubuntu-24.04-arm, ubuntu-24.04-arm,

View File

@ -24,6 +24,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -61,6 +62,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -101,6 +103,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -139,6 +142,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -180,6 +184,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -221,6 +226,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -252,6 +258,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -364,6 +371,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -453,6 +461,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,

View File

@ -24,6 +24,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -68,6 +69,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -115,6 +117,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -160,6 +163,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -210,6 +214,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -260,6 +265,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -294,6 +300,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,
@ -412,6 +419,7 @@ jobs:
[ [
macos-latest, macos-latest,
windows-latest, windows-latest,
ubuntu-20.04,
ubuntu-22.04, ubuntu-22.04,
ubuntu-22.04-arm, ubuntu-22.04-arm,
macos-13, macos-13,

26
.licenses/npm/lru-cache.dep.yml generated Normal file
View File

@ -0,0 +1,26 @@
---
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: []

View File

@ -1,6 +1,6 @@
--- ---
name: semver name: semver
version: 7.7.1 version: 7.6.0
type: npm type: npm
summary: The semantic version parser used by npm. summary: The semantic version parser used by npm.
homepage: homepage:

26
.licenses/npm/yallist.dep.yml generated Normal file
View File

@ -0,0 +1,26 @@
---
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: []

View File

@ -8,29 +8,10 @@ import * as tc from '@actions/tool-cache';
jest.mock('@actions/http-client'); jest.mock('@actions/http-client');
jest.mock('@actions/tool-cache'); jest.mock('@actions/tool-cache');
jest.mock('@actions/tool-cache', () => ({
getManifestFromRepo: jest.fn() const mockManifest = [{version: '1.0.0'}];
}));
const mockManifest = [
{
version: '1.0.0',
stable: true,
files: [
{
filename: 'tool-v1.0.0-linux-x64.tar.gz',
platform: 'linux',
arch: 'x64',
download_url: 'https://example.com/tool-v1.0.0-linux-x64.tar.gz'
}
]
}
];
describe('getManifest', () => { describe('getManifest', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('should return manifest from repo', async () => { it('should return manifest from repo', async () => {
(tc.getManifestFromRepo as jest.Mock).mockResolvedValue(mockManifest); (tc.getManifestFromRepo as jest.Mock).mockResolvedValue(mockManifest);
const manifest = await getManifest(); const manifest = await getManifest();

View File

@ -10,7 +10,7 @@ import {
validatePythonVersionFormatForPyPy, validatePythonVersionFormatForPyPy,
isCacheFeatureAvailable, isCacheFeatureAvailable,
getVersionInputFromFile, getVersionInputFromFile,
getVersionsInputFromPlainFile, getVersionInputFromPlainFile,
getVersionInputFromTomlFile, getVersionInputFromTomlFile,
getNextPageUrl, getNextPageUrl,
isGhes, isGhes,
@ -24,10 +24,10 @@ jest.mock('@actions/core');
describe('validatePythonVersionFormatForPyPy', () => { describe('validatePythonVersionFormatForPyPy', () => {
it.each([ it.each([
['3.12', true], ['3.6', true],
['3.13', true], ['3.7', true],
['3.12.x', false], ['3.6.x', false],
['3.13.x', false], ['3.7.x', false],
['3.x', false], ['3.x', false],
['3', false] ['3', false]
])('%s -> %s', (input, expected) => { ])('%s -> %s', (input, expected) => {
@ -95,52 +95,24 @@ const tempDir = path.join(
); );
describe('Version from file test', () => { describe('Version from file test', () => {
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])( it.each([getVersionInputFromPlainFile, getVersionInputFromFile])(
'Version from plain file test', 'Version from plain file test',
async _fn => { async _fn => {
await io.mkdirP(tempDir); await io.mkdirP(tempDir);
const pythonVersionFileName = 'python-version.file'; const pythonVersionFileName = 'python-version.file';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersionFileContent = '3.13'; const pythonVersionFileContent = '3.7';
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([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])( it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
'Version from standard pyproject.toml test', 'Version from standard pyproject.toml test',
async _fn => { async _fn => {
await io.mkdirP(tempDir); await io.mkdirP(tempDir);
const pythonVersionFileName = 'pyproject.toml'; const pythonVersionFileName = 'pyproject.toml';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '>=3.13.0'; const pythonVersion = '>=3.7.0';
const pythonVersionFileContent = `[project]\nrequires-python = "${pythonVersion}"`; const pythonVersionFileContent = `[project]\nrequires-python = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]); expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
@ -152,7 +124,7 @@ describe('Version from file test', () => {
await io.mkdirP(tempDir); await io.mkdirP(tempDir);
const pythonVersionFileName = 'pyproject.toml'; const pythonVersionFileName = 'pyproject.toml';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '>=3.13.0'; const pythonVersion = '>=3.7.0';
const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${pythonVersion}"`; const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]); expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
@ -173,9 +145,9 @@ describe('Version from file test', () => {
async _fn => { async _fn => {
const toolVersionFileName = '.tool-versions'; const toolVersionFileName = '.tool-versions';
const toolVersionFilePath = path.join(tempDir, toolVersionFileName); const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
const toolVersionContent = 'python 3.13.2\nnodejs 16'; const toolVersionContent = 'python 3.9.10\nnodejs 16';
fs.writeFileSync(toolVersionFilePath, toolVersionContent); fs.writeFileSync(toolVersionFilePath, toolVersionContent);
expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']); expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']);
} }
); );
@ -184,9 +156,9 @@ describe('Version from file test', () => {
async _fn => { async _fn => {
const toolVersionFileName = '.tool-versions'; const toolVersionFileName = '.tool-versions';
const toolVersionFilePath = path.join(tempDir, toolVersionFileName); const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
const toolVersionContent = '# python 3.13\npython 3.12'; const toolVersionContent = '# python 3.8\npython 3.9';
fs.writeFileSync(toolVersionFilePath, toolVersionContent); fs.writeFileSync(toolVersionFilePath, toolVersionContent);
expect(_fn(toolVersionFilePath)).toEqual(['3.12']); expect(_fn(toolVersionFilePath)).toEqual(['3.9']);
} }
); );
@ -195,9 +167,9 @@ describe('Version from file test', () => {
async _fn => { async _fn => {
const toolVersionFileName = '.tool-versions'; const toolVersionFileName = '.tool-versions';
const toolVersionFilePath = path.join(tempDir, toolVersionFileName); const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
const toolVersionContent = ' python 3.13 '; const toolVersionContent = ' python 3.10 ';
fs.writeFileSync(toolVersionFilePath, toolVersionContent); fs.writeFileSync(toolVersionFilePath, toolVersionContent);
expect(_fn(toolVersionFilePath)).toEqual(['3.13']); expect(_fn(toolVersionFilePath)).toEqual(['3.10']);
} }
); );
@ -206,9 +178,9 @@ describe('Version from file test', () => {
async _fn => { async _fn => {
const toolVersionFileName = '.tool-versions'; const toolVersionFileName = '.tool-versions';
const toolVersionFilePath = path.join(tempDir, toolVersionFileName); const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
const toolVersionContent = 'python v3.13.2'; const toolVersionContent = 'python v3.9.10';
fs.writeFileSync(toolVersionFilePath, toolVersionContent); fs.writeFileSync(toolVersionFilePath, toolVersionContent);
expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']); expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']);
} }
); );
@ -217,9 +189,9 @@ describe('Version from file test', () => {
async _fn => { async _fn => {
const toolVersionFileName = '.tool-versions'; const toolVersionFileName = '.tool-versions';
const toolVersionFilePath = path.join(tempDir, toolVersionFileName); const toolVersionFilePath = path.join(tempDir, toolVersionFileName);
const toolVersionContent = 'python pypy3.10-7.3.19'; const toolVersionContent = 'python pypy3.10-7.3.14';
fs.writeFileSync(toolVersionFilePath, toolVersionContent); fs.writeFileSync(toolVersionFilePath, toolVersionContent);
expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.19']); expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.14']);
} }
); );

998
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

169
package-lock.json generated
View File

@ -17,12 +17,12 @@
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^3.0.0", "@iarna/toml": "^3.0.0",
"semver": "^7.7.1" "semver": "^7.6.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/node": "^20.11.25", "@types/node": "^20.11.25",
"@types/semver": "^7.7.0", "@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
@ -32,8 +32,8 @@
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-circus": "^29.7.0", "jest-circus": "^29.7.0",
"prettier": "^3.5.3", "prettier": "^2.8.4",
"ts-jest": "^29.3.2", "ts-jest": "^29.1.2",
"typescript": "^5.4.2" "typescript": "^5.4.2"
} }
}, },
@ -1620,11 +1620,10 @@
} }
}, },
"node_modules/@types/semver": { "node_modules/@types/semver": {
"version": "7.7.0", "version": "7.5.8",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz",
"integrity": "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==", "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
"dev": true, "dev": true
"license": "MIT"
}, },
"node_modules/@types/stack-utils": { "node_modules/@types/stack-utils": {
"version": "2.0.3", "version": "2.0.3",
@ -1986,13 +1985,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/async": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
"integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
"dev": true,
"license": "MIT"
},
"node_modules/asynckit": { "node_modules/asynckit": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
@ -2484,22 +2476,6 @@
"node": ">=6.0.0" "node": ">=6.0.0"
} }
}, },
"node_modules/ejs": {
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"jake": "^10.8.5"
},
"bin": {
"ejs": "bin/cli.js"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.4.587", "version": "1.4.587",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.587.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.587.tgz",
@ -2998,39 +2974,6 @@
"node": "^10.12.0 || >=12.0.0" "node": "^10.12.0 || >=12.0.0"
} }
}, },
"node_modules/filelist": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
"integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"minimatch": "^5.0.1"
}
},
"node_modules/filelist/node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/filelist/node_modules/minimatch": {
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/fill-range": { "node_modules/fill-range": {
"version": "7.1.1", "version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
@ -3503,25 +3446,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/jake": {
"version": "10.9.2",
"resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz",
"integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"async": "^3.2.3",
"chalk": "^4.0.2",
"filelist": "^1.0.4",
"minimatch": "^3.1.2"
},
"bin": {
"jake": "bin/cli.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/jest": { "node_modules/jest": {
"version": "29.7.0", "version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
@ -4645,16 +4569,15 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "3.5.3", "version": "2.8.8",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"dev": true, "dev": true,
"license": "MIT",
"bin": { "bin": {
"prettier": "bin/prettier.cjs" "prettier": "bin-prettier.js"
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=10.13.0"
}, },
"funding": { "funding": {
"url": "https://github.com/prettier/prettier?sponsor=1" "url": "https://github.com/prettier/prettier?sponsor=1"
@ -4889,10 +4812,12 @@
"integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA=="
}, },
"node_modules/semver": { "node_modules/semver": {
"version": "7.7.1", "version": "7.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
"license": "ISC", "dependencies": {
"lru-cache": "^6.0.0"
},
"bin": { "bin": {
"semver": "bin/semver.js" "semver": "bin/semver.js"
}, },
@ -4900,6 +4825,22 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/semver/node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/semver/node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"node_modules/shebang-command": { "node_modules/shebang-command": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@ -5125,32 +5066,28 @@
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
}, },
"node_modules/ts-jest": { "node_modules/ts-jest": {
"version": "29.3.2", "version": "29.1.2",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.2.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz",
"integrity": "sha512-bJJkrWc6PjFVz5g2DGCNUo8z7oFEYaz1xP1NpeDU7KNLMWPpEyV8Chbpkn8xjzgRDpQhnGMyvyldoL7h8JXyug==", "integrity": "sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==",
"dev": true, "dev": true,
"license": "MIT",
"dependencies": { "dependencies": {
"bs-logger": "^0.2.6", "bs-logger": "0.x",
"ejs": "^3.1.10", "fast-json-stable-stringify": "2.x",
"fast-json-stable-stringify": "^2.1.0",
"jest-util": "^29.0.0", "jest-util": "^29.0.0",
"json5": "^2.2.3", "json5": "^2.2.3",
"lodash.memoize": "^4.1.2", "lodash.memoize": "4.x",
"make-error": "^1.3.6", "make-error": "1.x",
"semver": "^7.7.1", "semver": "^7.5.3",
"type-fest": "^4.39.1", "yargs-parser": "^21.0.1"
"yargs-parser": "^21.1.1"
}, },
"bin": { "bin": {
"ts-jest": "cli.js" "ts-jest": "cli.js"
}, },
"engines": { "engines": {
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" "node": "^16.10.0 || ^18.0.0 || >=20.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": ">=7.0.0-beta.0 <8", "@babel/core": ">=7.0.0-beta.0 <8",
"@jest/transform": "^29.0.0",
"@jest/types": "^29.0.0", "@jest/types": "^29.0.0",
"babel-jest": "^29.0.0", "babel-jest": "^29.0.0",
"jest": "^29.0.0", "jest": "^29.0.0",
@ -5160,9 +5097,6 @@
"@babel/core": { "@babel/core": {
"optional": true "optional": true
}, },
"@jest/transform": {
"optional": true
},
"@jest/types": { "@jest/types": {
"optional": true "optional": true
}, },
@ -5174,19 +5108,6 @@
} }
} }
}, },
"node_modules/ts-jest/node_modules/type-fest": {
"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": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.6.2", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",

View File

@ -33,12 +33,12 @@
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^3.0.0", "@iarna/toml": "^3.0.0",
"semver": "^7.7.1" "semver": "^7.6.0"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/node": "^20.11.25", "@types/node": "^20.11.25",
"@types/semver": "^7.7.0", "@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0", "@typescript-eslint/parser": "^5.54.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
@ -48,8 +48,8 @@
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"jest-circus": "^29.7.0", "jest-circus": "^29.7.0",
"prettier": "^3.5.3", "prettier": "^2.8.4",
"ts-jest": "^29.3.2", "ts-jest": "^29.1.2",
"typescript": "^5.4.2" "typescript": "^5.4.2"
} }
} }

View File

@ -5,7 +5,6 @@ import * as exec from '@actions/exec';
import * as httpm from '@actions/http-client'; import * as httpm from '@actions/http-client';
import {ExecOptions} from '@actions/exec/lib/interfaces'; import {ExecOptions} from '@actions/exec/lib/interfaces';
import {IS_WINDOWS, IS_LINUX, getDownloadFileName} from './utils'; import {IS_WINDOWS, IS_LINUX, getDownloadFileName} from './utils';
import {IToolRelease} from '@actions/tool-cache';
const TOKEN = core.getInput('token'); const TOKEN = core.getInput('token');
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`; const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
@ -32,41 +31,14 @@ export async function findReleaseFromManifest(
return foundRelease; return foundRelease;
} }
function isIToolRelease(obj: any): obj is IToolRelease {
return (
typeof obj === 'object' &&
obj !== null &&
typeof obj.version === 'string' &&
typeof obj.stable === 'boolean' &&
Array.isArray(obj.files) &&
obj.files.every(
(file: any) =>
typeof file.filename === 'string' &&
typeof file.platform === 'string' &&
typeof file.arch === 'string' &&
typeof file.download_url === 'string'
)
);
}
export async function getManifest(): Promise<tc.IToolRelease[]> { export async function getManifest(): Promise<tc.IToolRelease[]> {
try { try {
const repoManifest = await getManifestFromRepo(); return await getManifestFromRepo();
if (
Array.isArray(repoManifest) &&
repoManifest.length &&
repoManifest.every(isIToolRelease)
) {
return repoManifest;
}
throw new Error(
'The repository manifest is invalid or does not include any valid tool release (IToolRelease) entries.'
);
} catch (err) { } catch (err) {
core.debug('Fetching the manifest via the API failed.'); core.debug('Fetching the manifest via the API failed.');
if (err instanceof Error) { if (err instanceof Error) {
core.debug(err.message); core.debug(err.message);
} else {
core.error('An unexpected error occurred while fetching the manifest.');
} }
} }
return await getManifestFromURL(); return await getManifestFromURL();
@ -121,9 +93,6 @@ async function installPython(workingDirectory: string) {
} }
export async function installCpythonFromRelease(release: tc.IToolRelease) { export async function installCpythonFromRelease(release: tc.IToolRelease) {
if (!release.files || release.files.length === 0) {
throw new Error('No files found in the release to download.');
}
const downloadUrl = release.files[0].download_url; const downloadUrl = release.files[0].download_url;
core.info(`Download from "${downloadUrl}"`); core.info(`Download from "${downloadUrl}"`);
@ -144,13 +113,9 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
} catch (err) { } catch (err) {
if (err instanceof tc.HTTPError) { if (err instanceof tc.HTTPError) {
// Rate limit? // Rate limit?
if (err.httpStatusCode === 403) { if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
core.error(
`Received HTTP status code 403. This indicates a permission issue or restricted access.`
);
} else if (err.httpStatusCode === 429) {
core.info( core.info(
`Received HTTP status code 429. This usually indicates the rate limit has been exceeded` `Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
); );
} else { } else {
core.info(err.message); core.info(err.message);

View File

@ -11,7 +11,7 @@ import {
logWarning, logWarning,
IS_MAC, IS_MAC,
getVersionInputFromFile, getVersionInputFromFile,
getVersionsInputFromPlainFile getVersionInputFromPlainFile
} from './utils'; } from './utils';
function isPyPyVersion(versionSpec: string) { function isPyPyVersion(versionSpec: string) {
@ -35,7 +35,7 @@ async function cacheDependencies(cache: string, pythonVersion: string) {
function resolveVersionInputFromDefaultFile(): string[] { function resolveVersionInputFromDefaultFile(): string[] {
const couples: [string, (versionFile: string) => string[]][] = [ const couples: [string, (versionFile: string) => string[]][] = [
['.python-version', getVersionsInputFromPlainFile] ['.python-version', getVersionInputFromPlainFile]
]; ];
for (const [versionFile, _fn] of couples) { for (const [versionFile, _fn] of couples) {
logWarning( logWarning(

View File

@ -228,7 +228,7 @@ function extractValue(obj: any, keys: string[]): string | undefined {
* If none is present, returns an empty list. * If none is present, returns an empty list.
*/ */
export function getVersionInputFromTomlFile(versionFile: string): string[] { export function getVersionInputFromTomlFile(versionFile: string): string[] {
core.debug(`Trying to resolve version from ${versionFile}`); core.debug(`Trying to resolve version form ${versionFile}`);
let pyprojectFile = fs.readFileSync(versionFile, 'utf8'); let pyprojectFile = fs.readFileSync(versionFile, 'utf8');
// Normalize the line endings in the pyprojectFile // Normalize the line endings in the pyprojectFile
@ -269,28 +269,13 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
} }
/** /**
* Python versions extracted from a plain text file. * Python version 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 getVersionsInputFromPlainFile(versionFile: string): string[] { export function getVersionInputFromPlainFile(versionFile: string): string[] {
core.debug(`Trying to resolve versions from ${versionFile}`); core.debug(`Trying to resolve version form ${versionFile}`);
const content = fs.readFileSync(versionFile, 'utf8').trim(); const version = fs.readFileSync(versionFile, 'utf8').trim();
const lines = content.split(/\r\n|\r|\n/); core.info(`Resolved ${versionFile} as ${version}`);
const versions = lines return [version];
.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;
} }
/** /**
@ -334,7 +319,7 @@ export function getVersionInputFromFile(versionFile: string): string[] {
} else if (versionFile.match('.tool-versions')) { } else if (versionFile.match('.tool-versions')) {
return getVersionInputFromToolVersions(versionFile); return getVersionInputFromToolVersions(versionFile);
} else { } else {
return getVersionsInputFromPlainFile(versionFile); return getVersionInputFromPlainFile(versionFile);
} }
} }