mirror of
https://github.com/actions/setup-java.git
synced 2025-11-20 15:24:07 +00:00
Merge remote-tracking branch 'origin/main' into fix/graalvm-api-rate-limit
This commit is contained in:
commit
67460fe541
18
.github/workflows/e2e-cache.yml
vendored
18
.github/workflows/e2e-cache.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@ -46,7 +46,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
needs: gradle-save
|
needs: gradle-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -70,7 +70,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@ -93,7 +93,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
needs: maven-save
|
needs: maven-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -121,7 +121,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-22.04]
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@ -133,7 +133,7 @@ jobs:
|
|||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: sbt
|
cache: sbt
|
||||||
- name: Setup SBT
|
- name: Setup SBT
|
||||||
if: matrix.os == 'macos-13'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: |
|
run: |
|
||||||
echo ""Installing SBT...""
|
echo ""Installing SBT...""
|
||||||
brew install sbt
|
brew install sbt
|
||||||
@ -141,7 +141,7 @@ jobs:
|
|||||||
run: sbt update
|
run: sbt update
|
||||||
|
|
||||||
- name: Check files to cache on macos-latest
|
- name: Check files to cache on macos-latest
|
||||||
if: matrix.os == 'macos-13'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
@ -170,7 +170,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-22.04]
|
os: [macos-15-intel, windows-latest, ubuntu-22.04]
|
||||||
needs: sbt-save
|
needs: sbt-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -184,7 +184,7 @@ jobs:
|
|||||||
cache: sbt
|
cache: sbt
|
||||||
|
|
||||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||||
if: matrix.os == 'macos-13'
|
if: matrix.os == 'macos-15-intel'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
|
|||||||
10
.github/workflows/e2e-versions.yml
vendored
10
.github/workflows/e2e-versions.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
distribution: [
|
distribution: [
|
||||||
'temurin',
|
'temurin',
|
||||||
'adopt',
|
'adopt',
|
||||||
@ -39,7 +39,7 @@ jobs:
|
|||||||
- distribution: microsoft
|
- distribution: microsoft
|
||||||
version: 8
|
version: 8
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-13
|
os: macos-15-intel
|
||||||
include:
|
include:
|
||||||
- distribution: microsoft
|
- distribution: microsoft
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
@ -51,7 +51,7 @@ jobs:
|
|||||||
os: macos-latest
|
os: macos-latest
|
||||||
version: 25
|
version: 25
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-13
|
os: macos-15-intel
|
||||||
version: 17
|
version: 17
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
@ -229,7 +229,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
version: ['17-ea', '15.0.0-ea.14']
|
version: ['17-ea', '15.0.0-ea.14']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -295,7 +295,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-13, windows-latest, ubuntu-latest]
|
os: [macos-15-intel, windows-latest, ubuntu-latest]
|
||||||
distribution:
|
distribution:
|
||||||
['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine', 'jetbrains']
|
['temurin', 'zulu', 'liberica', 'semeru', 'sapmachine', 'jetbrains']
|
||||||
java-package: ['jre']
|
java-package: ['jre']
|
||||||
|
|||||||
123
dist/setup/index.js
vendored
123
dist/setup/index.js
vendored
@ -129856,6 +129856,7 @@ class JavaBase {
|
|||||||
this.checkLatest = installerOptions.checkLatest;
|
this.checkLatest = installerOptions.checkLatest;
|
||||||
}
|
}
|
||||||
setupJava() {
|
setupJava() {
|
||||||
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let foundJava = this.findInToolcache();
|
let foundJava = this.findInToolcache();
|
||||||
if (foundJava && !this.checkLatest) {
|
if (foundJava && !this.checkLatest) {
|
||||||
@ -129863,40 +129864,106 @@ class JavaBase {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info('Trying to resolve the latest version from remote');
|
core.info('Trying to resolve the latest version from remote');
|
||||||
try {
|
const MAX_RETRIES = 4;
|
||||||
const javaRelease = yield this.findPackageForDownload(this.version);
|
const RETRY_DELAY_MS = 2000;
|
||||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
const retryableCodes = [
|
||||||
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
|
'ETIMEDOUT',
|
||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
'ECONNRESET',
|
||||||
}
|
'ENOTFOUND',
|
||||||
else {
|
'ECONNREFUSED'
|
||||||
core.info('Trying to download...');
|
];
|
||||||
foundJava = yield this.downloadTool(javaRelease);
|
let retries = MAX_RETRIES;
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
while (retries > 0) {
|
||||||
}
|
try {
|
||||||
}
|
// Clear console timers before each attempt to prevent conflicts
|
||||||
catch (error) {
|
if (retries < MAX_RETRIES && core.isDebug()) {
|
||||||
if (error instanceof tc.HTTPError) {
|
const consoleAny = console;
|
||||||
if (error.httpStatusCode === 403) {
|
(_b = (_a = consoleAny._times) === null || _a === void 0 ? void 0 : _a.clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
||||||
core.error('HTTP 403: Permission denied or access restricted.');
|
|
||||||
}
|
}
|
||||||
else if (error.httpStatusCode === 429) {
|
const javaRelease = yield this.findPackageForDownload(this.version);
|
||||||
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
|
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||||
|
if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) {
|
||||||
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
core.info('Trying to download...');
|
||||||
|
foundJava = yield this.downloadTool(javaRelease);
|
||||||
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
catch (error) {
|
||||||
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
retries--;
|
||||||
core.error(`Java setup failed due to network issue or timeout: ${message}`);
|
// Check if error is retryable (including aggregate errors)
|
||||||
|
const isRetryable = (error instanceof tc.HTTPError &&
|
||||||
|
error.httpStatusCode &&
|
||||||
|
[429, 502, 503, 504].includes(error.httpStatusCode)) ||
|
||||||
|
retryableCodes.includes(error === null || error === void 0 ? void 0 : error.code) ||
|
||||||
|
((error === null || error === void 0 ? void 0 : error.errors) &&
|
||||||
|
Array.isArray(error.errors) &&
|
||||||
|
error.errors.some((err) => retryableCodes.includes(err === null || err === void 0 ? void 0 : err.code)));
|
||||||
|
if (retries > 0 && isRetryable) {
|
||||||
|
core.debug(`Attempt failed due to network or timeout issues, initiating retry... (${retries} attempts left)`);
|
||||||
|
yield new Promise(r => setTimeout(r, RETRY_DELAY_MS));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (error instanceof tc.HTTPError) {
|
||||||
|
if (error.httpStatusCode === 403) {
|
||||||
|
core.error('HTTP 403: Permission denied or access restricted.');
|
||||||
|
}
|
||||||
|
else if (error.httpStatusCode === 429) {
|
||||||
|
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (error && error.errors && Array.isArray(error.errors)) {
|
||||||
|
core.error(`Java setup failed due to network or configuration error(s)`);
|
||||||
|
if (error instanceof Error && error.stack) {
|
||||||
|
core.debug(error.stack);
|
||||||
|
}
|
||||||
|
for (const err of error.errors) {
|
||||||
|
const endpoint = (err === null || err === void 0 ? void 0 : err.address) || (err === null || err === void 0 ? void 0 : err.hostname) || '';
|
||||||
|
const port = (err === null || err === void 0 ? void 0 : err.port) ? `:${err.port}` : '';
|
||||||
|
const message = (err === null || err === void 0 ? void 0 : err.message) || 'Aggregate error';
|
||||||
|
const endpointInfo = !message.includes(endpoint)
|
||||||
|
? ` ${endpoint}${port}`
|
||||||
|
: '';
|
||||||
|
const localInfo = err.localAddress && err.localPort
|
||||||
|
? ` - Local (${err.localAddress}:${err.localPort})`
|
||||||
|
: '';
|
||||||
|
const logMessage = `${message}${endpointInfo}${localInfo}`;
|
||||||
|
core.error(logMessage);
|
||||||
|
core.debug(`${err.stack || err.message}`);
|
||||||
|
Object.entries(err).forEach(([key, value]) => {
|
||||||
|
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
||||||
|
core.error(`Java setup process failed due to: ${message}`);
|
||||||
|
if (typeof (error === null || error === void 0 ? void 0 : error.code) === 'string') {
|
||||||
|
core.debug(error.stack);
|
||||||
|
}
|
||||||
|
const errorDetails = Object.assign({ name: error.name, message: error.message }, Object.getOwnPropertyNames(error)
|
||||||
|
.filter(prop => !['name', 'message', 'stack'].includes(prop))
|
||||||
|
.reduce((acc, prop) => {
|
||||||
|
acc[prop] = error[prop];
|
||||||
|
return acc;
|
||||||
|
}, {}));
|
||||||
|
Object.entries(errorDetails).forEach(([key, value]) => {
|
||||||
|
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
if (error instanceof Error && error.stack) {
|
|
||||||
core.debug(error.stack);
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!foundJava) {
|
||||||
|
throw new Error('Failed to resolve Java version');
|
||||||
|
}
|
||||||
// JDK folder may contain postfix "Contents/Home" on macOS
|
// JDK folder may contain postfix "Contents/Home" on macOS
|
||||||
const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
|
const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX);
|
||||||
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) {
|
||||||
@ -131562,9 +131629,9 @@ class SapMachineDistribution extends base_installer_1.JavaBase {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const platform = this.getPlatformOption();
|
const platform = this.getPlatformOption();
|
||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
let fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
|
let fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sapmachine.io/assets/data/sapmachine-releases-all.json');
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages', (0, util_1.getGitHubHttpHeaders)());
|
fetchedReleasesJson = yield this.fetchReleasesFromUrl('https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json');
|
||||||
}
|
}
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
|
throw new Error(`Couldn't fetch SapMachine versions information from both primary and backup urls`);
|
||||||
|
|||||||
9
package-lock.json
generated
9
package-lock.json
generated
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"name": "setup-java",
|
"name": "setup-java",
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
@ -367,6 +366,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.3.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.3.tgz",
|
||||||
"integrity": "sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew==",
|
"integrity": "sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ampproject/remapping": "^2.2.0",
|
"@ampproject/remapping": "^2.2.0",
|
||||||
"@babel/code-frame": "^7.22.13",
|
"@babel/code-frame": "^7.22.13",
|
||||||
@ -1758,6 +1758,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.43.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.43.0.tgz",
|
||||||
"integrity": "sha512-B7RIQiTsCBBmY+yW4+ILd6mF5h1FUwJsVvpqkrgpszYifetQ2Ke+Z4u6aZh0CblkUGIdR59iYVyXqqZGkZ3aBw==",
|
"integrity": "sha512-B7RIQiTsCBBmY+yW4+ILd6mF5h1FUwJsVvpqkrgpszYifetQ2Ke+Z4u6aZh0CblkUGIdR59iYVyXqqZGkZ3aBw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.43.0",
|
"@typescript-eslint/scope-manager": "8.43.0",
|
||||||
"@typescript-eslint/types": "8.43.0",
|
"@typescript-eslint/types": "8.43.0",
|
||||||
@ -2003,6 +2005,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
|
||||||
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
"integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@ -2278,6 +2281,7 @@
|
|||||||
"url": "https://github.com/sponsors/ai"
|
"url": "https://github.com/sponsors/ai"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"caniuse-lite": "^1.0.30001541",
|
"caniuse-lite": "^1.0.30001541",
|
||||||
"electron-to-chromium": "^1.4.535",
|
"electron-to-chromium": "^1.4.535",
|
||||||
@ -2733,6 +2737,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz",
|
||||||
"integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==",
|
"integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.2.0",
|
"@eslint-community/eslint-utils": "^4.2.0",
|
||||||
"@eslint-community/regexpp": "^4.6.1",
|
"@eslint-community/regexpp": "^4.6.1",
|
||||||
@ -3729,6 +3734,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
||||||
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/core": "^29.7.0",
|
"@jest/core": "^29.7.0",
|
||||||
"@jest/types": "^29.6.3",
|
"@jest/types": "^29.6.3",
|
||||||
@ -5479,6 +5485,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||||
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|||||||
@ -51,39 +51,115 @@ export abstract class JavaBase {
|
|||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
} else {
|
} else {
|
||||||
core.info('Trying to resolve the latest version from remote');
|
core.info('Trying to resolve the latest version from remote');
|
||||||
try {
|
const MAX_RETRIES = 4;
|
||||||
const javaRelease = await this.findPackageForDownload(this.version);
|
const RETRY_DELAY_MS = 2000;
|
||||||
core.info(`Resolved latest version as ${javaRelease.version}`);
|
const retryableCodes = [
|
||||||
if (foundJava?.version === javaRelease.version) {
|
'ETIMEDOUT',
|
||||||
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
'ECONNRESET',
|
||||||
} else {
|
'ENOTFOUND',
|
||||||
core.info('Trying to download...');
|
'ECONNREFUSED'
|
||||||
foundJava = await this.downloadTool(javaRelease);
|
];
|
||||||
core.info(`Java ${foundJava.version} was downloaded`);
|
let retries = MAX_RETRIES;
|
||||||
}
|
while (retries > 0) {
|
||||||
} catch (error: any) {
|
try {
|
||||||
if (error instanceof tc.HTTPError) {
|
// Clear console timers before each attempt to prevent conflicts
|
||||||
if (error.httpStatusCode === 403) {
|
if (retries < MAX_RETRIES && core.isDebug()) {
|
||||||
core.error('HTTP 403: Permission denied or access restricted.');
|
const consoleAny = console as any;
|
||||||
} else if (error.httpStatusCode === 429) {
|
consoleAny._times?.clear?.();
|
||||||
core.warning('HTTP 429: Rate limit exceeded. Please retry later.');
|
|
||||||
} else {
|
|
||||||
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
|
||||||
}
|
}
|
||||||
} else {
|
const javaRelease = await this.findPackageForDownload(this.version);
|
||||||
const message =
|
core.info(`Resolved latest version as ${javaRelease.version}`);
|
||||||
error instanceof Error ? error.message : JSON.stringify(error);
|
if (foundJava?.version === javaRelease.version) {
|
||||||
core.error(
|
core.info(`Resolved Java ${foundJava.version} from tool-cache`);
|
||||||
`Java setup failed due to network issue or timeout: ${message}`
|
} else {
|
||||||
);
|
core.info('Trying to download...');
|
||||||
|
foundJava = await this.downloadTool(javaRelease);
|
||||||
|
core.info(`Java ${foundJava.version} was downloaded`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} catch (error: any) {
|
||||||
|
retries--;
|
||||||
|
// Check if error is retryable (including aggregate errors)
|
||||||
|
const isRetryable =
|
||||||
|
(error instanceof tc.HTTPError &&
|
||||||
|
error.httpStatusCode &&
|
||||||
|
[429, 502, 503, 504].includes(error.httpStatusCode)) ||
|
||||||
|
retryableCodes.includes(error?.code) ||
|
||||||
|
(error?.errors &&
|
||||||
|
Array.isArray(error.errors) &&
|
||||||
|
error.errors.some((err: any) =>
|
||||||
|
retryableCodes.includes(err?.code)
|
||||||
|
));
|
||||||
|
if (retries > 0 && isRetryable) {
|
||||||
|
core.debug(
|
||||||
|
`Attempt failed due to network or timeout issues, initiating retry... (${retries} attempts left)`
|
||||||
|
);
|
||||||
|
await new Promise(r => setTimeout(r, RETRY_DELAY_MS));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (error instanceof tc.HTTPError) {
|
||||||
|
if (error.httpStatusCode === 403) {
|
||||||
|
core.error('HTTP 403: Permission denied or access restricted.');
|
||||||
|
} else if (error.httpStatusCode === 429) {
|
||||||
|
core.warning(
|
||||||
|
'HTTP 429: Rate limit exceeded. Please retry later.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.error(`HTTP ${error.httpStatusCode}: ${error.message}`);
|
||||||
|
}
|
||||||
|
} else if (error && error.errors && Array.isArray(error.errors)) {
|
||||||
|
core.error(
|
||||||
|
`Java setup failed due to network or configuration error(s)`
|
||||||
|
);
|
||||||
|
if (error instanceof Error && error.stack) {
|
||||||
|
core.debug(error.stack);
|
||||||
|
}
|
||||||
|
for (const err of error.errors) {
|
||||||
|
const endpoint = err?.address || err?.hostname || '';
|
||||||
|
const port = err?.port ? `:${err.port}` : '';
|
||||||
|
const message = err?.message || 'Aggregate error';
|
||||||
|
const endpointInfo = !message.includes(endpoint)
|
||||||
|
? ` ${endpoint}${port}`
|
||||||
|
: '';
|
||||||
|
const localInfo =
|
||||||
|
err.localAddress && err.localPort
|
||||||
|
? ` - Local (${err.localAddress}:${err.localPort})`
|
||||||
|
: '';
|
||||||
|
const logMessage = `${message}${endpointInfo}${localInfo}`;
|
||||||
|
core.error(logMessage);
|
||||||
|
core.debug(`${err.stack || err.message}`);
|
||||||
|
Object.entries(err).forEach(([key, value]) => {
|
||||||
|
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const message =
|
||||||
|
error instanceof Error ? error.message : JSON.stringify(error);
|
||||||
|
core.error(`Java setup process failed due to: ${message}`);
|
||||||
|
if (typeof error?.code === 'string') {
|
||||||
|
core.debug(error.stack);
|
||||||
|
}
|
||||||
|
const errorDetails = {
|
||||||
|
name: error.name,
|
||||||
|
message: error.message,
|
||||||
|
...Object.getOwnPropertyNames(error)
|
||||||
|
.filter(prop => !['name', 'message', 'stack'].includes(prop))
|
||||||
|
.reduce<{[key: string]: any}>((acc, prop) => {
|
||||||
|
acc[prop] = error[prop];
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
};
|
||||||
|
Object.entries(errorDetails).forEach(([key, value]) => {
|
||||||
|
core.debug(`"${key}": ${JSON.stringify(value)}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
if (error instanceof Error && error.stack) {
|
|
||||||
core.debug(error.stack);
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!foundJava) {
|
||||||
|
throw new Error('Failed to resolve Java version');
|
||||||
|
}
|
||||||
// JDK folder may contain postfix "Contents/Home" on macOS
|
// JDK folder may contain postfix "Contents/Home" on macOS
|
||||||
const macOSPostfixPath = path.join(
|
const macOSPostfixPath = path.join(
|
||||||
foundJava.path,
|
foundJava.path,
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import {
|
|||||||
convertVersionToSemver,
|
convertVersionToSemver,
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
getGitHubHttpHeaders,
|
|
||||||
isVersionSatisfies,
|
isVersionSatisfies,
|
||||||
renameWinArchive
|
renameWinArchive
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
@ -64,13 +63,12 @@ export class SapMachineDistribution extends JavaBase {
|
|||||||
const arch = this.distributionArchitecture();
|
const arch = this.distributionArchitecture();
|
||||||
|
|
||||||
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
let fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
||||||
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
|
'https://sapmachine.io/assets/data/sapmachine-releases-all.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!fetchedReleasesJson) {
|
if (!fetchedReleasesJson) {
|
||||||
fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
fetchedReleasesJson = await this.fetchReleasesFromUrl(
|
||||||
'https://api.github.com/repos/SAP/SapMachine/contents/assets/data/sapmachine-releases-all.json?ref=gh-pages',
|
'https://sap.github.io/SapMachine/assets/data/sapmachine-releases-all.json'
|
||||||
getGitHubHttpHeaders()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user