mirror of
https://github.com/actions/setup-java
synced 2024-11-09 23:22:40 +00:00
Merge pull request #48 from ericsciple/users/ericsciple/m166retry
add retries and error handling
This commit is contained in:
commit
f63b906f27
3 changed files with 428 additions and 398 deletions
16
.github/workflows/workflow.yml
vendored
16
.github/workflows/workflow.yml
vendored
|
@ -9,12 +9,12 @@ jobs:
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
- name: Setup Node.js 12.x
|
||||||
uses: actions/setup-node@master
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 10.x
|
node-version: 12.x
|
||||||
|
|
||||||
- name: npm install
|
- name: npm install
|
||||||
run: npm install
|
run: npm install
|
||||||
|
@ -40,12 +40,12 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "127.0.0.0 registry.npm.js nodejs.org github.com api.github.com download.java.net static.azul.com" | sudo tee -a /etc/hosts
|
echo "127.0.0.0 registry.npm.js nodejs.org github.com api.github.com download.java.net static.azul.com" | sudo tee -a /etc/hosts
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
- name: Setup Node.js 12.x
|
||||||
uses: actions/setup-node@master
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 10.x
|
node-version: 12.x
|
||||||
|
|
||||||
- name: npm install
|
- name: npm install
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
27
dist/index.js
generated
vendored
27
dist/index.js
generated
vendored
|
@ -4644,11 +4644,11 @@ let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const io = __importStar(__webpack_require__(1));
|
const io = __importStar(__webpack_require__(1));
|
||||||
const exec = __importStar(__webpack_require__(986));
|
const exec = __importStar(__webpack_require__(986));
|
||||||
|
const httpm = __importStar(__webpack_require__(539));
|
||||||
const tc = __importStar(__webpack_require__(533));
|
const tc = __importStar(__webpack_require__(533));
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(280));
|
const semver = __importStar(__webpack_require__(280));
|
||||||
const httpm = __importStar(__webpack_require__(539));
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
if (!tempDirectory) {
|
if (!tempDirectory) {
|
||||||
let baseLocation;
|
let baseLocation;
|
||||||
|
@ -4675,10 +4675,27 @@ function getJava(version, arch, jdkFile, javaPackage) {
|
||||||
else {
|
else {
|
||||||
let compressedFileExtension = '';
|
let compressedFileExtension = '';
|
||||||
if (!jdkFile) {
|
if (!jdkFile) {
|
||||||
core.debug('Downloading Jdk from Azul');
|
core.debug('Downloading JDK from Azul');
|
||||||
let http = new httpm.HttpClient('setup-java');
|
const http = new httpm.HttpClient('setup-java', undefined, {
|
||||||
let contents = yield (yield http.get('https://static.azul.com/zulu/bin/')).readBody();
|
allowRetries: true,
|
||||||
let refs = contents.match(/<a href.*\">/gi) || [];
|
maxRetries: 3
|
||||||
|
});
|
||||||
|
const url = 'https://static.azul.com/zulu/bin/';
|
||||||
|
const response = yield http.get(url);
|
||||||
|
const statusCode = response.message.statusCode || 0;
|
||||||
|
if (statusCode < 200 || statusCode > 299) {
|
||||||
|
let body = '';
|
||||||
|
try {
|
||||||
|
body = yield response.readBody();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
core.debug(`Unable to read body: ${err.message}`);
|
||||||
|
}
|
||||||
|
const message = `Unexpected HTTP status code '${response.message.statusCode}' when retrieving versions from '${url}'. ${body}`.trim();
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
const contents = yield response.readBody();
|
||||||
|
const refs = contents.match(/<a href.*\">/gi) || [];
|
||||||
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
||||||
jdkFile = yield tc.downloadTool(downloadInfo.url);
|
jdkFile = yield tc.downloadTool(downloadInfo.url);
|
||||||
version = downloadInfo.version;
|
version = downloadInfo.version;
|
||||||
|
|
|
@ -39,15 +39,28 @@ export async function getJava(
|
||||||
} else {
|
} else {
|
||||||
let compressedFileExtension = '';
|
let compressedFileExtension = '';
|
||||||
if (!jdkFile) {
|
if (!jdkFile) {
|
||||||
core.debug('Downloading Jdk from Azul');
|
core.debug('Downloading JDK from Azul');
|
||||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-java');
|
const http = new httpm.HttpClient('setup-java', undefined, {
|
||||||
let contents = await (
|
allowRetries: true,
|
||||||
await http.get('https://static.azul.com/zulu/bin/')
|
maxRetries: 3
|
||||||
).readBody();
|
});
|
||||||
let refs = contents.match(/<a href.*\">/gi) || [];
|
const url = 'https://static.azul.com/zulu/bin/';
|
||||||
|
const response = await http.get(url);
|
||||||
|
const statusCode = response.message.statusCode || 0;
|
||||||
|
if (statusCode < 200 || statusCode > 299) {
|
||||||
|
let body = '';
|
||||||
|
try {
|
||||||
|
body = await response.readBody();
|
||||||
|
} catch (err) {
|
||||||
|
core.debug(`Unable to read body: ${err.message}`);
|
||||||
|
}
|
||||||
|
const message = `Unexpected HTTP status code '${response.message.statusCode}' when retrieving versions from '${url}'. ${body}`.trim();
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const contents = await response.readBody();
|
||||||
|
const refs = contents.match(/<a href.*\">/gi) || [];
|
||||||
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
const downloadInfo = getDownloadInfo(refs, version, javaPackage);
|
||||||
|
|
||||||
jdkFile = await tc.downloadTool(downloadInfo.url);
|
jdkFile = await tc.downloadTool(downloadInfo.url);
|
||||||
version = downloadInfo.version;
|
version = downloadInfo.version;
|
||||||
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';
|
||||||
|
|
Loading…
Reference in a new issue