mirror of
https://code.forgejo.org/actions/setup-python
synced 2025-06-08 04:18:19 +02:00
feature: fallback to pre-release when no stable version is found (#414)
This allows to specify version like `3.11` or `pypy3.10` in workflows before those versions are released. This lessen the burden for users of `setup-python` by not having to modify their workflow twice: once when a pre-release is available (e.g. `3.11-dev`) and once when the first stable release is published (e.g. `3.11`)
This commit is contained in:
parent
a6eba85bba
commit
2652534ead
14 changed files with 524 additions and 61 deletions
|
@ -1,4 +1,94 @@
|
|||
[
|
||||
{
|
||||
"pypy_version": "7.3.8rc2",
|
||||
"python_version": "3.8.12",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"date": "2022-02-11",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-darwin64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-darwin64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-s390x.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-win64.zip",
|
||||
"arch": "x64",
|
||||
"platform": "win64",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-win64.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.8-v7.3.8rc2-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.8-v7.3.8rc2-win32.zip"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.4.0rc1",
|
||||
"python_version": "3.6.12",
|
||||
"stable": false,
|
||||
"latest_pypy": false,
|
||||
"date": "2021-11-11",
|
||||
"files": [
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-aarch64.tar.bz2",
|
||||
"arch": "aarch64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-aarch64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-linux32.tar.bz2",
|
||||
"arch": "i686",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-linux32.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-linux64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-linux64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-darwin64.tar.bz2",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-darwin64.tar.bz2"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-win32.zip",
|
||||
"arch": "x86",
|
||||
"platform": "win32",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-win32.zip"
|
||||
},
|
||||
{
|
||||
"filename": "pypy3.6-v7.4.0rc1-s390x.tar.bz2",
|
||||
"arch": "s390x",
|
||||
"platform": "linux",
|
||||
"download_url": "https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-s390x.tar.bz2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"pypy_version": "7.3.3",
|
||||
"python_version": "3.6.12",
|
||||
|
@ -530,4 +620,4 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -1,4 +1,29 @@
|
|||
[
|
||||
{
|
||||
"version": "1.2.4-beta.2",
|
||||
"stable": false,
|
||||
"release_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5",
|
||||
"files": [
|
||||
{
|
||||
"filename": "sometool-1.2.4-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.4-darwin-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-darwin-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.4-win32-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.4-beta.2-20200402.5/sometool-1.2.4-win32-x64.tar.gz"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.2.3",
|
||||
"stable": true,
|
||||
|
@ -25,28 +50,28 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"version": "1.2.3-beta.2",
|
||||
"version": "1.1.0-beta.2",
|
||||
"stable": false,
|
||||
"release_url": "https://github.com/actions/sometool/releases/tag/1.2.3-beta.2-20200402.5",
|
||||
"release_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5",
|
||||
"files": [
|
||||
{
|
||||
"filename": "sometool-1.2.3-linux-x64.tar.gz",
|
||||
"filename": "sometool-1.1.0-linux-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "linux",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-beta.2-20200402.5/sometool-1.2.3-linux-x64.tar.gz"
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-linux-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-darwin-x64.tar.gz",
|
||||
"filename": "sometool-1.1.0-darwin-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "darwin",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.5/sometool-1.2.3-darwin-x64.tar.gz"
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-darwin-x64.tar.gz"
|
||||
},
|
||||
{
|
||||
"filename": "sometool-1.2.3-win32-x64.tar.gz",
|
||||
"filename": "sometool-1.1.0-win32-x64.tar.gz",
|
||||
"arch": "x64",
|
||||
"platform": "win32",
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.2.3-20200402.5/sometool-1.2.3-win32-x64.tar.gz"
|
||||
"download_url": "https://github.com/actions/sometool/releases/tag/1.1.0-beta.2-20200402.5/sometool-1.1.0-win32-x64.tar.gz"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -273,7 +273,13 @@ describe('findPyPyVersion', () => {
|
|||
|
||||
it('found PyPy in toolcache', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture, true, false)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.6-v7.3.x',
|
||||
architecture,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -291,13 +297,13 @@ describe('findPyPyVersion', () => {
|
|||
|
||||
it('throw on invalid input format', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false)
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false, false)
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('throw on invalid input format pypy3.7-7.3.x', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false)
|
||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true, false, false)
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
|
@ -309,7 +315,13 @@ describe('findPyPyVersion', () => {
|
|||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, true, false)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.7-v7.3.x',
|
||||
architecture,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.7.9',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -333,7 +345,13 @@ describe('findPyPyVersion', () => {
|
|||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, false, false)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.7-v7.3.x',
|
||||
architecture,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.7.9',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -344,7 +362,13 @@ describe('findPyPyVersion', () => {
|
|||
|
||||
it('throw if release is not found', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture, true, false)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.7-v7.5.x',
|
||||
architecture,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
)
|
||||
).rejects.toThrowError(
|
||||
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
|
||||
);
|
||||
|
@ -352,7 +376,13 @@ describe('findPyPyVersion', () => {
|
|||
|
||||
it('check-latest enabled version found and used from toolcache', async () => {
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture, false, true)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.6-v7.3.x',
|
||||
architecture,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -371,7 +401,13 @@ describe('findPyPyVersion', () => {
|
|||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, false, true)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.7-v7.3.x',
|
||||
architecture,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.7.9',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -391,7 +427,13 @@ describe('findPyPyVersion', () => {
|
|||
return pypyPath;
|
||||
});
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy-3.8-v7.3.x', architecture, false, true)
|
||||
finder.findPyPyVersion(
|
||||
'pypy-3.8-v7.3.x',
|
||||
architecture,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.8.8',
|
||||
resolvedPyPyVersion: '7.3.3'
|
||||
|
@ -401,4 +443,22 @@ describe('findPyPyVersion', () => {
|
|||
'Failed to resolve PyPy v7.3.x with Python (3.8) from manifest'
|
||||
);
|
||||
});
|
||||
|
||||
it('found and install successfully, pre-release fallback', async () => {
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(() =>
|
||||
path.join(toolDir, 'PyPy', '3.8.12', architecture)
|
||||
);
|
||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.8', architecture, false, false, false)
|
||||
).rejects.toThrowError();
|
||||
await expect(
|
||||
finder.findPyPyVersion('pypy3.8', architecture, false, false, true)
|
||||
).resolves.toEqual({
|
||||
resolvedPythonVersion: '3.8.12',
|
||||
resolvedPyPyVersion: '7.3.8rc2'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('Finder tests', () => {
|
|||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('3.x', 'x64', true, false);
|
||||
await finder.useCpythonVersion('3.x', 'x64', true, false, false);
|
||||
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||
'pythonLocation',
|
||||
|
@ -73,7 +73,7 @@ describe('Finder tests', () => {
|
|||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('3.x', 'x64', false, false);
|
||||
await finder.useCpythonVersion('3.x', 'x64', false, false, false);
|
||||
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -95,7 +95,12 @@ describe('Finder tests', () => {
|
|||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('1.2.3', 'x64', true, false);
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.2.3', 'x64', true, false, false)
|
||||
).resolves.toEqual({
|
||||
impl: 'CPython',
|
||||
version: '1.2.3'
|
||||
});
|
||||
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||
'pythonLocation',
|
||||
|
@ -122,14 +127,19 @@ describe('Finder tests', () => {
|
|||
const pythonDir: string = path.join(
|
||||
toolDir,
|
||||
'Python',
|
||||
'1.2.3-beta.2',
|
||||
'1.2.4-beta.2',
|
||||
'x64'
|
||||
);
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('1.2.3-beta.2', 'x64', false, false);
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.2.4-beta.2', 'x64', false, false, false)
|
||||
).resolves.toEqual({
|
||||
impl: 'CPython',
|
||||
version: '1.2.4-beta.2'
|
||||
});
|
||||
});
|
||||
|
||||
it('Check-latest true, finds the latest version in the manifest', async () => {
|
||||
|
@ -176,7 +186,7 @@ describe('Finder tests', () => {
|
|||
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('1.2', 'x64', true, true);
|
||||
await finder.useCpythonVersion('1.2', 'x64', true, true, false);
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'");
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
|
@ -187,7 +197,7 @@ describe('Finder tests', () => {
|
|||
);
|
||||
expect(installSpy).toHaveBeenCalled();
|
||||
expect(addPathSpy).toHaveBeenCalledWith(expPath);
|
||||
await finder.useCpythonVersion('1.2.3-beta.2', 'x64', false, true);
|
||||
await finder.useCpythonVersion('1.2.4-beta.2', 'x64', false, true, false);
|
||||
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||
'pythonLocation',
|
||||
|
@ -199,11 +209,67 @@ describe('Finder tests', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('Finds stable Python version if it is not installed, but exists in the manifest, skipping newer pre-release', async () => {
|
||||
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
|
||||
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
|
||||
|
||||
const installSpy: jest.SpyInstance = jest.spyOn(
|
||||
installer,
|
||||
'installCpythonFromRelease'
|
||||
);
|
||||
installSpy.mockImplementation(async () => {
|
||||
const pythonDir: string = path.join(toolDir, 'Python', '1.2.3', 'x64');
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.2', 'x64', false, false, false)
|
||||
).resolves.toEqual({
|
||||
impl: 'CPython',
|
||||
version: '1.2.3'
|
||||
});
|
||||
});
|
||||
|
||||
it('Finds Python version if it is not installed, but exists in the manifest, pre-release fallback', async () => {
|
||||
const findSpy: jest.SpyInstance = jest.spyOn(tc, 'getManifestFromRepo');
|
||||
findSpy.mockImplementation(() => <tc.IToolRelease[]>manifestData);
|
||||
|
||||
const installSpy: jest.SpyInstance = jest.spyOn(
|
||||
installer,
|
||||
'installCpythonFromRelease'
|
||||
);
|
||||
installSpy.mockImplementation(async () => {
|
||||
const pythonDir: string = path.join(
|
||||
toolDir,
|
||||
'Python',
|
||||
'1.1.0-beta.2',
|
||||
'x64'
|
||||
);
|
||||
await io.mkdirP(pythonDir);
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
});
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.1', 'x64', false, false, false)
|
||||
).rejects.toThrowError();
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.1', 'x64', false, false, true)
|
||||
).resolves.toEqual({
|
||||
impl: 'CPython',
|
||||
version: '1.1.0-beta.2'
|
||||
});
|
||||
// Check 1.1.0 version specifier does not fallback to '1.1.0-beta.2'
|
||||
await expect(
|
||||
finder.useCpythonVersion('1.1.0', 'x64', false, false, true)
|
||||
).rejects.toThrowError();
|
||||
});
|
||||
|
||||
it('Errors if Python is not installed', async () => {
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
let thrown = false;
|
||||
try {
|
||||
await finder.useCpythonVersion('3.300000', 'x64', true, false);
|
||||
await finder.useCpythonVersion('3.300000', 'x64', true, false, false);
|
||||
} catch {
|
||||
thrown = true;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ describe('findRelease', () => {
|
|||
platform: process.platform,
|
||||
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}`
|
||||
};
|
||||
const filesRC1: IPyPyManifestAsset = {
|
||||
filename: `pypy3.6-v7.4.0rc1-${extensionName}`,
|
||||
arch: architecture,
|
||||
platform: process.platform,
|
||||
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.4.0rc1-${extensionName}`
|
||||
};
|
||||
|
||||
let getBooleanInputSpy: jest.SpyInstance;
|
||||
let warningSpy: jest.SpyInstance;
|
||||
|
@ -72,7 +78,13 @@ describe('findRelease', () => {
|
|||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.3.7';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual(null);
|
||||
});
|
||||
|
||||
|
@ -80,7 +92,13 @@ describe('findRelease', () => {
|
|||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.3.3';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
|
@ -92,7 +110,13 @@ describe('findRelease', () => {
|
|||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.x';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
|
@ -104,7 +128,13 @@ describe('findRelease', () => {
|
|||
const pythonVersion = '3.7';
|
||||
const pypyVersion = installer.pypyVersionToSemantic('7.3.3rc2');
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: {
|
||||
filename: `test${extension}`,
|
||||
|
@ -121,7 +151,13 @@ describe('findRelease', () => {
|
|||
const pythonVersion = '3.6';
|
||||
const pypyVersion = 'x';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: files,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
|
@ -129,12 +165,45 @@ describe('findRelease', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('Python version and PyPy version matches semver (pre-release)', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = '7.4.x';
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toBeNull();
|
||||
expect(
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
true
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: filesRC1,
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.4.0rc1'
|
||||
});
|
||||
});
|
||||
|
||||
it('Nightly release is found', () => {
|
||||
const pythonVersion = '3.6';
|
||||
const pypyVersion = 'nightly';
|
||||
const filename = IS_WINDOWS ? 'filename.zip' : 'filename.tar.bz2';
|
||||
expect(
|
||||
installer.findRelease(releases, pythonVersion, pypyVersion, architecture)
|
||||
installer.findRelease(
|
||||
releases,
|
||||
pythonVersion,
|
||||
pypyVersion,
|
||||
architecture,
|
||||
false
|
||||
)
|
||||
).toEqual({
|
||||
foundAsset: {
|
||||
filename: filename,
|
||||
|
@ -224,7 +293,7 @@ describe('installPyPy', () => {
|
|||
|
||||
it('throw if release is not found', async () => {
|
||||
await expect(
|
||||
installer.installPyPy('7.3.3', '3.6.17', architecture, undefined)
|
||||
installer.installPyPy('7.3.3', '3.6.17', architecture, false, undefined)
|
||||
).rejects.toThrowError(
|
||||
`PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found`
|
||||
);
|
||||
|
@ -244,7 +313,7 @@ describe('installPyPy', () => {
|
|||
spyChmodSync.mockImplementation(() => undefined);
|
||||
|
||||
await expect(
|
||||
installer.installPyPy('7.3.x', '3.6.12', architecture, undefined)
|
||||
installer.installPyPy('7.x', '3.6.12', architecture, false, undefined)
|
||||
).resolves.toEqual({
|
||||
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
|
@ -257,4 +326,31 @@ describe('installPyPy', () => {
|
|||
expect(spyCacheDir).toHaveBeenCalled();
|
||||
expect(spyExec).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('found and install PyPy, pre-release fallback', async () => {
|
||||
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||
spyCacheDir.mockImplementation(() =>
|
||||
path.join(toolDir, 'PyPy', '3.6.12', architecture)
|
||||
);
|
||||
|
||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||
spyChmodSync.mockImplementation(() => undefined);
|
||||
|
||||
await expect(
|
||||
installer.installPyPy('7.4.x', '3.6.12', architecture, false, undefined)
|
||||
).rejects.toThrowError();
|
||||
await expect(
|
||||
installer.installPyPy('7.4.x', '3.6.12', architecture, true, undefined)
|
||||
).resolves.toEqual({
|
||||
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
|
||||
resolvedPythonVersion: '3.6.12',
|
||||
resolvedPyPyVersion: '7.4.0rc1'
|
||||
});
|
||||
|
||||
expect(spyHttpClient).toHaveBeenCalled();
|
||||
expect(spyDownloadTool).toHaveBeenCalled();
|
||||
expect(spyExistsSync).toHaveBeenCalled();
|
||||
expect(spyCacheDir).toHaveBeenCalled();
|
||||
expect(spyExec).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue