mirror of
https://github.com/actions/setup-python.git
synced 2025-04-14 16:03:31 +00:00
Compare commits
9 Commits
136656e10d
...
69dec13035
Author | SHA1 | Date | |
---|---|---|---|
![]() |
69dec13035 | ||
![]() |
e348410e00 | ||
![]() |
ba50e5ed8e | ||
![]() |
d148396753 | ||
![]() |
da830ea0e9 | ||
![]() |
658d90b402 | ||
![]() |
6aeae83a71 | ||
![]() |
996d9604f2 | ||
![]() |
c4b81dc3e7 |
2
.github/workflows/e2e-cache.yml
vendored
2
.github/workflows/e2e-cache.yml
vendored
@ -78,6 +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
|
||||||
steps:
|
steps:
|
||||||
|
1
.github/workflows/e2e-tests.yml
vendored
1
.github/workflows/e2e-tests.yml
vendored
@ -19,7 +19,6 @@ 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,
|
||||||
|
2
.github/workflows/test-graalpy.yml
vendored
2
.github/workflows/test-graalpy.yml
vendored
@ -21,7 +21,6 @@ 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,
|
||||||
@ -77,7 +76,6 @@ 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,
|
||||||
|
4
.github/workflows/test-pypy.yml
vendored
4
.github/workflows/test-pypy.yml
vendored
@ -24,7 +24,6 @@ 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,
|
||||||
@ -142,7 +141,6 @@ 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,
|
||||||
@ -177,7 +175,6 @@ 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,
|
||||||
@ -220,7 +217,6 @@ 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,
|
||||||
|
8
.github/workflows/test-python.yml
vendored
8
.github/workflows/test-python.yml
vendored
@ -24,7 +24,6 @@ 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,
|
||||||
@ -69,7 +68,6 @@ 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,
|
||||||
@ -117,7 +115,6 @@ 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,
|
||||||
@ -163,7 +160,6 @@ 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,
|
||||||
@ -214,7 +210,6 @@ 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,
|
||||||
@ -265,7 +260,6 @@ 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,
|
||||||
@ -300,7 +294,6 @@ 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,
|
||||||
@ -419,7 +412,6 @@ 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,
|
||||||
|
@ -9,7 +9,25 @@ 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');
|
||||||
|
|
||||||
const mockManifest = [{version: '1.0.0'}];
|
const mockManifest = [
|
||||||
|
{
|
||||||
|
version: '3.9.0',
|
||||||
|
stable: true,
|
||||||
|
release_url: 'https://example.com/release-url',
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
filename: 'python-3.9.0-macosx10.9.pkg',
|
||||||
|
arch: 'x64',
|
||||||
|
platform: 'darwin',
|
||||||
|
download_url: 'https://example.com/download-url'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
describe('getManifest', () => {
|
describe('getManifest', () => {
|
||||||
it('should return manifest from repo', async () => {
|
it('should return manifest from repo', async () => {
|
||||||
|
75
dist/setup/index.js
vendored
75
dist/setup/index.js
vendored
@ -97464,20 +97464,49 @@ exports.findReleaseFromManifest = findReleaseFromManifest;
|
|||||||
function getManifest() {
|
function getManifest() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
return yield getManifestFromRepo();
|
const manifestFromRepo = yield getManifestFromRepo();
|
||||||
|
core.info('Successfully fetched the manifest from the repo.');
|
||||||
|
validateManifest(manifestFromRepo);
|
||||||
|
return manifestFromRepo;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.debug('Fetching the manifest via the API failed.');
|
logError('Fetching the manifest via the API failed.', err);
|
||||||
if (err instanceof Error) {
|
}
|
||||||
core.debug(err.message);
|
try {
|
||||||
}
|
const manifestFromURL = yield getManifestFromURL();
|
||||||
|
core.info('Successfully fetched the manifest from the URL.');
|
||||||
|
return manifestFromURL;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
logError('Fetching the manifest via the URL failed.', err);
|
||||||
|
// Rethrow the error or return a default value
|
||||||
|
throw new Error('Failed to fetch the manifest from both the repo and the URL.');
|
||||||
}
|
}
|
||||||
return yield getManifestFromURL();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getManifest = getManifest;
|
exports.getManifest = getManifest;
|
||||||
|
function validateManifest(manifest) {
|
||||||
|
if (!Array.isArray(manifest) || !manifest.every(isValidManifestEntry)) {
|
||||||
|
throw new Error('Invalid manifest response');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function isValidManifestEntry(entry) {
|
||||||
|
return (typeof entry.version === 'string' &&
|
||||||
|
typeof entry.stable === 'boolean' &&
|
||||||
|
typeof entry.release_url === 'string' &&
|
||||||
|
Array.isArray(entry.files) &&
|
||||||
|
entry.files.every(isValidFileEntry));
|
||||||
|
}
|
||||||
|
function isValidFileEntry(file) {
|
||||||
|
return (typeof file.filename === 'string' &&
|
||||||
|
typeof file.arch === 'string' &&
|
||||||
|
typeof file.platform === 'string' &&
|
||||||
|
(typeof file.platform_version === 'string' ||
|
||||||
|
file.platform_version === undefined) &&
|
||||||
|
typeof file.download_url === 'string');
|
||||||
|
}
|
||||||
function getManifestFromRepo() {
|
function getManifestFromRepo() {
|
||||||
core.debug(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`);
|
core.info(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`);
|
||||||
return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
|
return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
|
||||||
}
|
}
|
||||||
exports.getManifestFromRepo = getManifestFromRepo;
|
exports.getManifestFromRepo = getManifestFromRepo;
|
||||||
@ -97508,34 +97537,29 @@ function installPython(workingDirectory) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (utils_1.IS_WINDOWS) {
|
const script = utils_1.IS_WINDOWS ? 'powershell ./setup.ps1' : 'bash ./setup.sh';
|
||||||
yield exec.exec('powershell', ['./setup.ps1'], options);
|
yield exec.exec(script, [], options);
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield exec.exec('bash', ['./setup.sh'], options);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function installCpythonFromRelease(release) {
|
function installCpythonFromRelease(release) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const downloadUrl = release.files[0].download_url;
|
const downloadUrl = release.files[0].download_url;
|
||||||
core.info(`Download from "${downloadUrl}"`);
|
core.info(`Download from "${downloadUrl}"`);
|
||||||
let pythonPath = '';
|
|
||||||
try {
|
try {
|
||||||
const fileName = (0, utils_1.getDownloadFileName)(downloadUrl);
|
const fileName = (0, utils_1.getDownloadFileName)(downloadUrl);
|
||||||
pythonPath = yield tc.downloadTool(downloadUrl, fileName, AUTH);
|
const pythonPath = yield tc.downloadTool(downloadUrl, fileName, AUTH);
|
||||||
core.info('Extract downloaded archive');
|
core.info('Extract downloaded archive');
|
||||||
let pythonExtractedFolder;
|
const pythonExtractedFolder = utils_1.IS_WINDOWS
|
||||||
if (utils_1.IS_WINDOWS) {
|
? yield tc.extractZip(pythonPath)
|
||||||
pythonExtractedFolder = yield tc.extractZip(pythonPath);
|
: yield tc.extractTar(pythonPath);
|
||||||
}
|
|
||||||
else {
|
|
||||||
pythonExtractedFolder = yield tc.extractTar(pythonPath);
|
|
||||||
}
|
|
||||||
core.info('Execute installation script');
|
core.info('Execute installation script');
|
||||||
yield installPython(pythonExtractedFolder);
|
yield installPython(pythonExtractedFolder);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
handleDownloadError(err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
function handleDownloadError(err) {
|
||||||
if (err instanceof tc.HTTPError) {
|
if (err instanceof tc.HTTPError) {
|
||||||
// Rate limit?
|
// Rate limit?
|
||||||
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
||||||
@ -97548,11 +97572,16 @@ function installCpythonFromRelease(release) {
|
|||||||
core.debug(err.stack);
|
core.debug(err.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw err;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.installCpythonFromRelease = installCpythonFromRelease;
|
exports.installCpythonFromRelease = installCpythonFromRelease;
|
||||||
|
function logError(message, err) {
|
||||||
|
core.info(message);
|
||||||
|
if (err instanceof Error) {
|
||||||
|
core.info(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -28,24 +28,60 @@ export async function findReleaseFromManifest(
|
|||||||
manifest,
|
manifest,
|
||||||
architecture
|
architecture
|
||||||
);
|
);
|
||||||
|
|
||||||
return foundRelease;
|
return foundRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getManifest(): Promise<tc.IToolRelease[]> {
|
export async function getManifest(): Promise<tc.IToolRelease[]> {
|
||||||
try {
|
try {
|
||||||
return await getManifestFromRepo();
|
const manifestFromRepo = await getManifestFromRepo();
|
||||||
|
core.info('Successfully fetched the manifest from the repo.');
|
||||||
|
validateManifest(manifestFromRepo);
|
||||||
|
return manifestFromRepo;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.debug('Fetching the manifest via the API failed.');
|
logError('Fetching the manifest via the API failed.', err);
|
||||||
if (err instanceof Error) {
|
|
||||||
core.debug(err.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return await getManifestFromURL();
|
try {
|
||||||
|
const manifestFromURL = await getManifestFromURL();
|
||||||
|
core.info('Successfully fetched the manifest from the URL.');
|
||||||
|
return manifestFromURL;
|
||||||
|
} catch (err) {
|
||||||
|
logError('Fetching the manifest via the URL failed.', err);
|
||||||
|
// Rethrow the error or return a default value
|
||||||
|
throw new Error(
|
||||||
|
'Failed to fetch the manifest from both the repo and the URL.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateManifest(manifest: any): void {
|
||||||
|
if (!Array.isArray(manifest) || !manifest.every(isValidManifestEntry)) {
|
||||||
|
throw new Error('Invalid manifest response');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidManifestEntry(entry: any): boolean {
|
||||||
|
return (
|
||||||
|
typeof entry.version === 'string' &&
|
||||||
|
typeof entry.stable === 'boolean' &&
|
||||||
|
typeof entry.release_url === 'string' &&
|
||||||
|
Array.isArray(entry.files) &&
|
||||||
|
entry.files.every(isValidFileEntry)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isValidFileEntry(file: any): boolean {
|
||||||
|
return (
|
||||||
|
typeof file.filename === 'string' &&
|
||||||
|
typeof file.arch === 'string' &&
|
||||||
|
typeof file.platform === 'string' &&
|
||||||
|
(typeof file.platform_version === 'string' ||
|
||||||
|
file.platform_version === undefined) &&
|
||||||
|
typeof file.download_url === 'string'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getManifestFromRepo(): Promise<tc.IToolRelease[]> {
|
export function getManifestFromRepo(): Promise<tc.IToolRelease[]> {
|
||||||
core.debug(
|
core.info(
|
||||||
`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`
|
`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`
|
||||||
);
|
);
|
||||||
return tc.getManifestFromRepo(
|
return tc.getManifestFromRepo(
|
||||||
@ -85,32 +121,30 @@ async function installPython(workingDirectory: string) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
const script = IS_WINDOWS ? 'powershell ./setup.ps1' : 'bash ./setup.sh';
|
||||||
await exec.exec('powershell', ['./setup.ps1'], options);
|
await exec.exec(script, [], options);
|
||||||
} else {
|
|
||||||
await exec.exec('bash', ['./setup.sh'], options);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
||||||
const downloadUrl = release.files[0].download_url;
|
const downloadUrl = release.files[0].download_url;
|
||||||
|
|
||||||
core.info(`Download from "${downloadUrl}"`);
|
core.info(`Download from "${downloadUrl}"`);
|
||||||
let pythonPath = '';
|
|
||||||
try {
|
try {
|
||||||
const fileName = getDownloadFileName(downloadUrl);
|
const fileName = getDownloadFileName(downloadUrl);
|
||||||
pythonPath = await tc.downloadTool(downloadUrl, fileName, AUTH);
|
const pythonPath = await tc.downloadTool(downloadUrl, fileName, AUTH);
|
||||||
core.info('Extract downloaded archive');
|
core.info('Extract downloaded archive');
|
||||||
let pythonExtractedFolder;
|
const pythonExtractedFolder = IS_WINDOWS
|
||||||
if (IS_WINDOWS) {
|
? await tc.extractZip(pythonPath)
|
||||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
: await tc.extractTar(pythonPath);
|
||||||
} else {
|
|
||||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info('Execute installation script');
|
core.info('Execute installation script');
|
||||||
await installPython(pythonExtractedFolder);
|
await installPython(pythonExtractedFolder);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
handleDownloadError(err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDownloadError(err: any): void {
|
||||||
if (err instanceof tc.HTTPError) {
|
if (err instanceof tc.HTTPError) {
|
||||||
// Rate limit?
|
// Rate limit?
|
||||||
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
||||||
@ -124,6 +158,12 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
|||||||
core.debug(err.stack);
|
core.debug(err.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw err;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function logError(message: string, err: any): void {
|
||||||
|
core.info(message);
|
||||||
|
if (err instanceof Error) {
|
||||||
|
core.info(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user