Add version parsing from Pipfile (#1067)

* feature: add version parsing from Pipfile

* Update utils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/utils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/utils.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: update dist/setup/index.js

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Aramís Segovia 2025-07-24 18:40:39 -04:00 committed by GitHub
parent 3c6f142cc0
commit 36da51d563
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 308 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import {
getVersionInputFromFile,
getVersionsInputFromPlainFile,
getVersionInputFromTomlFile,
getVersionInputFromPipfileFile,
getNextPageUrl,
isGhes,
IS_WINDOWS,
@ -244,6 +245,44 @@ describe('Version from file test', () => {
expect(_fn(toolVersionFilePath)).toEqual(['3.14t-dev']);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13';
const pythonVersionFileContent = `[requires]\npython_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_full_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13.0';
const pythonVersionFileContent = `[requires]\npython_full_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Pipfile undefined version',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersionFileContent = ``;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([]);
}
);
});
describe('getNextPageUrl', () => {