Skip to content

Commit 722bbb3

Browse files
revert
1 parent f451e9f commit 722bbb3

File tree

2 files changed

+45
-108
lines changed

2 files changed

+45
-108
lines changed

dist/setup/index.js

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -97333,6 +97333,7 @@ function installGraalPy(graalpyVersion, architecture, allowPreReleases, releases
9733397333
}
9733497334
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
9733597335
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
97336+
// check for pre-release
9733697337
core.info([
9733797338
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
9733897339
`Trying pre-release versions`
@@ -97345,64 +97346,36 @@ function installGraalPy(graalpyVersion, architecture, allowPreReleases, releases
9734597346
const { foundAsset, resolvedGraalPyVersion } = releaseData;
9734697347
const downloadUrl = `${foundAsset.browser_download_url}`;
9734797348
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
97348-
function performInstall(downloadPath) {
97349-
return __awaiter(this, void 0, void 0, function* () {
97350-
core.info('Extracting downloaded archive...');
97351-
if (utils_1.IS_WINDOWS) {
97352-
downloadDir = yield tc.extractZip(downloadPath);
97353-
}
97354-
else {
97355-
downloadDir = yield tc.extractTar(downloadPath);
97356-
}
97357-
const archiveName = fs_1.default.readdirSync(downloadDir)[0];
97358-
const toolDir = path.join(downloadDir, archiveName);
97359-
let installDir = toolDir;
97360-
if (!(0, utils_1.isNightlyKeyword)(resolvedGraalPyVersion)) {
97361-
installDir = yield tc.cacheDir(toolDir, 'GraalPy', resolvedGraalPyVersion, architecture);
97362-
}
97363-
const binaryPath = (0, utils_1.getBinaryDirectory)(installDir);
97364-
yield createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
97365-
yield installPip(binaryPath);
97366-
return { installDir, resolvedGraalPyVersion };
97367-
});
97368-
}
9736997349
try {
9737097350
const graalpyPath = yield tc.downloadTool(downloadUrl, undefined, AUTH);
97371-
return yield performInstall(graalpyPath);
97351+
core.info('Extracting downloaded archive...');
97352+
downloadDir = yield tc.extractTar(graalpyPath);
97353+
// root folder in archive can have unpredictable name so just take the first folder
97354+
// downloadDir is unique folder under TEMP and can't contain any other folders
97355+
const archiveName = fs_1.default.readdirSync(downloadDir)[0];
97356+
const toolDir = path.join(downloadDir, archiveName);
97357+
let installDir = toolDir;
97358+
if (!(0, utils_1.isNightlyKeyword)(resolvedGraalPyVersion)) {
97359+
installDir = yield tc.cacheDir(toolDir, 'GraalPy', resolvedGraalPyVersion, architecture);
97360+
}
97361+
const binaryPath = (0, utils_1.getBinaryDirectory)(installDir);
97362+
yield createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
97363+
yield installPip(binaryPath);
97364+
return { installDir, resolvedGraalPyVersion };
9737297365
}
9737397366
catch (err) {
9737497367
if (err instanceof Error) {
97375-
const isRateLimit = err instanceof tc.HTTPError &&
97376-
(err.httpStatusCode === 403 || err.httpStatusCode === 429);
97377-
if (isRateLimit) {
97378-
core.warning(`Rate limit or restricted access response received: HTTP ${err.httpStatusCode}`);
97379-
let lastStatus;
97380-
for (let attempt = 1; attempt <= 3; attempt++) {
97381-
core.info(`Retry attempt ${attempt} of 3 due to rate limit...`);
97382-
yield new Promise(res => setTimeout(res, 2000 * attempt));
97383-
try {
97384-
const retryPath = yield tc.downloadTool(downloadUrl, undefined, AUTH);
97385-
core.info(`Retry succeeded.`);
97386-
return yield performInstall(retryPath);
97387-
}
97388-
catch (retryErr) {
97389-
if (retryErr instanceof tc.HTTPError) {
97390-
lastStatus = retryErr.httpStatusCode;
97391-
core.warning(`Retry ${attempt} failed. HTTP ${lastStatus}`);
97392-
}
97393-
else {
97394-
core.warning(`Retry ${attempt} failed: ${retryErr}`);
97395-
}
97396-
if (attempt === 3) {
97397-
core.error(`All retries failed. Last HTTP status code: ${lastStatus !== null && lastStatus !== void 0 ? lastStatus : 'unknown'}`);
97398-
throw retryErr;
97399-
}
97400-
}
97401-
}
97368+
// Rate limit?
97369+
if (err instanceof tc.HTTPError &&
97370+
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
97371+
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
9740297372
}
97403-
core.info(err.message);
97404-
if (err.stack)
97373+
else {
97374+
core.info(err.message);
97375+
}
97376+
if (err.stack !== undefined) {
9740597377
core.debug(err.stack);
97378+
}
9740697379
}
9740797380
throw err;
9740897381
}

src/install-graalpy.ts

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121

2222
const TOKEN = core.getInput('token');
2323
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
24+
2425
export async function installGraalPy(
2526
graalpyVersion: string,
2627
architecture: string,
@@ -30,13 +31,15 @@ export async function installGraalPy(
3031
let downloadDir;
3132

3233
releases = releases ?? (await getAvailableGraalPyVersions());
34+
3335
if (!releases || !releases.length) {
3436
throw new Error('No release was found in GraalPy version.json');
3537
}
3638

3739
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
3840

3941
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
42+
// check for pre-release
4043
core.info(
4144
[
4245
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
@@ -57,18 +60,17 @@ export async function installGraalPy(
5760

5861
core.info(`Downloading GraalPy from "${downloadUrl}" ...`);
5962

60-
async function performInstall(downloadPath: string) {
61-
core.info('Extracting downloaded archive...');
63+
try {
64+
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
6265

63-
if (IS_WINDOWS) {
64-
downloadDir = await tc.extractZip(downloadPath);
65-
} else {
66-
downloadDir = await tc.extractTar(downloadPath);
67-
}
66+
core.info('Extracting downloaded archive...');
67+
downloadDir = await tc.extractTar(graalpyPath);
6868

69+
// root folder in archive can have unpredictable name so just take the first folder
70+
// downloadDir is unique folder under TEMP and can't contain any other folders
6971
const archiveName = fs.readdirSync(downloadDir)[0];
70-
const toolDir = path.join(downloadDir, archiveName);
7172

73+
const toolDir = path.join(downloadDir, archiveName);
7274
let installDir = toolDir;
7375
if (!isNightlyKeyword(resolvedGraalPyVersion)) {
7476
installDir = await tc.cacheDir(
@@ -84,61 +86,23 @@ export async function installGraalPy(
8486
await installPip(binaryPath);
8587

8688
return {installDir, resolvedGraalPyVersion};
87-
}
88-
89-
try {
90-
const graalpyPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
91-
return await performInstall(graalpyPath);
9289
} catch (err) {
9390
if (err instanceof Error) {
94-
const isRateLimit =
91+
// Rate limit?
92+
if (
9593
err instanceof tc.HTTPError &&
96-
(err.httpStatusCode === 403 || err.httpStatusCode === 429);
97-
98-
if (isRateLimit) {
99-
core.warning(
100-
`Rate limit or restricted access response received: HTTP ${err.httpStatusCode}`
94+
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
95+
) {
96+
core.info(
97+
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
10198
);
102-
103-
let lastStatus: number | undefined;
104-
105-
for (let attempt = 1; attempt <= 3; attempt++) {
106-
core.info(`Retry attempt ${attempt} of 3 due to rate limit...`);
107-
await new Promise(res => setTimeout(res, 2000 * attempt));
108-
109-
try {
110-
const retryPath = await tc.downloadTool(
111-
downloadUrl,
112-
undefined,
113-
AUTH
114-
);
115-
core.info(`Retry succeeded.`);
116-
117-
return await performInstall(retryPath);
118-
} catch (retryErr) {
119-
if (retryErr instanceof tc.HTTPError) {
120-
lastStatus = retryErr.httpStatusCode;
121-
core.warning(`Retry ${attempt} failed. HTTP ${lastStatus}`);
122-
} else {
123-
core.warning(`Retry ${attempt} failed: ${retryErr}`);
124-
}
125-
126-
if (attempt === 3) {
127-
core.error(
128-
`All retries failed. Last HTTP status code: ${
129-
lastStatus ?? 'unknown'
130-
}`
131-
);
132-
throw retryErr;
133-
}
134-
}
135-
}
99+
} else {
100+
core.info(err.message);
101+
}
102+
if (err.stack !== undefined) {
103+
core.debug(err.stack);
136104
}
137-
138-
core.info(err.message);
139-
if (err.stack) core.debug(err.stack);
140105
}
141-
142106
throw err;
143107
}
144108
}

0 commit comments

Comments
 (0)