@@ -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 }
0 commit comments