Skip to content

Commit c67fa74

Browse files
merge update
1 parent 718f927 commit c67fa74

File tree

2 files changed

+28
-116
lines changed

2 files changed

+28
-116
lines changed

dist/setup/index.js

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -97299,6 +97299,7 @@ async function installGraalPy(graalpyVersion, architecture, allowPreReleases, re
9729997299
}
9730097300
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
9730197301
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
97302+
// check for pre-release
9730297303
core.info([
9730397304
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
9730497305
`Trying pre-release versions`
@@ -97320,7 +97321,8 @@ async function installGraalPy(graalpyVersion, architecture, allowPreReleases, re
9732097321
else {
9732197322
downloadDir = await tc.extractTar(graalpyPath);
9732297323
}
97323-
// folder name in archive is unpredictable
97324+
// root folder in archive can have unpredictable name so just take the first folder
97325+
// downloadDir is unique folder under TEMP and can't contain any other folders
9732497326
const archiveName = fs_1.default.readdirSync(downloadDir)[0];
9732597327
const toolDir = path.join(downloadDir, archiveName);
9732697328
let installDir = toolDir;
@@ -97334,54 +97336,17 @@ async function installGraalPy(graalpyVersion, architecture, allowPreReleases, re
9733497336
}
9733597337
catch (err) {
9733697338
if (err instanceof Error) {
97337-
const isRateLimit = err instanceof tc.HTTPError &&
97338-
(err.httpStatusCode === 403 || err.httpStatusCode === 429);
97339-
if (isRateLimit) {
97340-
core.warning(`Rate limit or restricted access response received: HTTP ${err.httpStatusCode}`);
97341-
let lastStatus;
97342-
for (let attempt = 1; attempt <= 3; attempt++) {
97343-
core.info(`Retry attempt ${attempt} of 3 due to rate limit...`);
97344-
await new Promise(res => setTimeout(res, 2000 * attempt));
97345-
try {
97346-
const retryPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
97347-
core.info(`Retry succeeded.`);
97348-
// Extract retry archive
97349-
let retryExtractDir;
97350-
if (utils_1.IS_WINDOWS) {
97351-
retryExtractDir = await tc.extractZip(retryPath);
97352-
}
97353-
else {
97354-
retryExtractDir = await tc.extractTar(retryPath);
97355-
}
97356-
const archiveName = fs_1.default.readdirSync(retryExtractDir)[0];
97357-
const toolDir = path.join(retryExtractDir, archiveName);
97358-
let installDir = toolDir;
97359-
if (!(0, utils_1.isNightlyKeyword)(resolvedGraalPyVersion)) {
97360-
installDir = await tc.cacheDir(toolDir, 'GraalPy', resolvedGraalPyVersion, architecture);
97361-
}
97362-
const binaryPath = path.join(installDir, 'bin');
97363-
await createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
97364-
await installPip(binaryPath);
97365-
return { installDir, resolvedGraalPyVersion };
97366-
}
97367-
catch (retryErr) {
97368-
if (retryErr instanceof tc.HTTPError) {
97369-
lastStatus = retryErr.httpStatusCode;
97370-
core.warning(`Retry ${attempt} failed. HTTP ${lastStatus}`);
97371-
}
97372-
else {
97373-
core.warning(`Retry ${attempt} failed: ${retryErr}`);
97374-
}
97375-
if (attempt === 3) {
97376-
core.error(`All retries failed. Last HTTP status code: ${lastStatus ?? 'unknown'}`);
97377-
throw retryErr;
97378-
}
97379-
}
97380-
}
97339+
// Rate limit?
97340+
if (err instanceof tc.HTTPError &&
97341+
(err.httpStatusCode === 403 || err.httpStatusCode === 429)) {
97342+
core.info(`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`);
97343+
}
97344+
else {
97345+
core.info(err.message);
9738197346
}
97382-
core.info(err.message);
97383-
if (err.stack)
97347+
if (err.stack !== undefined) {
9738497348
core.debug(err.stack);
97349+
}
9738597350
}
9738697351
throw err;
9738797352
}

src/install-graalpy.ts

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020

2121
const TOKEN = core.getInput('token');
2222
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
23+
2324
export async function installGraalPy(
2425
graalpyVersion: string,
2526
architecture: string,
@@ -37,6 +38,7 @@ export async function installGraalPy(
3738
let releaseData = findRelease(releases, graalpyVersion, architecture, false);
3839

3940
if (allowPreReleases && (!releaseData || !releaseData.foundAsset)) {
41+
// check for pre-release
4042
core.info(
4143
[
4244
`Stable GraalPy version ${graalpyVersion} with arch ${architecture} not found`,
@@ -67,11 +69,12 @@ export async function installGraalPy(
6769
downloadDir = await tc.extractTar(graalpyPath);
6870
}
6971

70-
// folder name in archive is unpredictable
72+
// root folder in archive can have unpredictable name so just take the first folder
73+
// downloadDir is unique folder under TEMP and can't contain any other folders
7174
const archiveName = fs.readdirSync(downloadDir)[0];
75+
7276
const toolDir = path.join(downloadDir, archiveName);
7377
let installDir = toolDir;
74-
7578
if (!isNightlyKeyword(resolvedGraalPyVersion)) {
7679
installDir = await tc.cacheDir(
7780
toolDir,
@@ -88,77 +91,21 @@ export async function installGraalPy(
8891
return {installDir, resolvedGraalPyVersion};
8992
} catch (err) {
9093
if (err instanceof Error) {
91-
const isRateLimit =
94+
// Rate limit?
95+
if (
9296
err instanceof tc.HTTPError &&
93-
(err.httpStatusCode === 403 || err.httpStatusCode === 429);
94-
95-
if (isRateLimit) {
96-
core.warning(
97-
`Rate limit or restricted access response received: HTTP ${err.httpStatusCode}`
97+
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
98+
) {
99+
core.info(
100+
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
98101
);
99-
100-
let lastStatus: number | undefined;
101-
102-
for (let attempt = 1; attempt <= 3; attempt++) {
103-
core.info(`Retry attempt ${attempt} of 3 due to rate limit...`);
104-
await new Promise(res => setTimeout(res, 2000 * attempt));
105-
106-
try {
107-
const retryPath = await tc.downloadTool(
108-
downloadUrl,
109-
undefined,
110-
AUTH
111-
);
112-
core.info(`Retry succeeded.`);
113-
114-
// Extract retry archive
115-
let retryExtractDir;
116-
if (IS_WINDOWS) {
117-
retryExtractDir = await tc.extractZip(retryPath);
118-
} else {
119-
retryExtractDir = await tc.extractTar(retryPath);
120-
}
121-
122-
const archiveName = fs.readdirSync(retryExtractDir)[0];
123-
const toolDir = path.join(retryExtractDir, archiveName);
124-
let installDir = toolDir;
125-
126-
if (!isNightlyKeyword(resolvedGraalPyVersion)) {
127-
installDir = await tc.cacheDir(
128-
toolDir,
129-
'GraalPy',
130-
resolvedGraalPyVersion,
131-
architecture
132-
);
133-
}
134-
135-
const binaryPath = path.join(installDir, 'bin');
136-
await createGraalPySymlink(binaryPath, resolvedGraalPyVersion);
137-
await installPip(binaryPath);
138-
139-
return {installDir, resolvedGraalPyVersion};
140-
} catch (retryErr) {
141-
if (retryErr instanceof tc.HTTPError) {
142-
lastStatus = retryErr.httpStatusCode;
143-
core.warning(`Retry ${attempt} failed. HTTP ${lastStatus}`);
144-
} else {
145-
core.warning(`Retry ${attempt} failed: ${retryErr}`);
146-
}
147-
148-
if (attempt === 3) {
149-
core.error(
150-
`All retries failed. Last HTTP status code: ${lastStatus ?? 'unknown'}`
151-
);
152-
throw retryErr;
153-
}
154-
}
155-
}
102+
} else {
103+
core.info(err.message);
104+
}
105+
if (err.stack !== undefined) {
106+
core.debug(err.stack);
156107
}
157-
158-
core.info(err.message);
159-
if (err.stack) core.debug(err.stack);
160108
}
161-
162109
throw err;
163110
}
164111
}

0 commit comments

Comments
 (0)