From 9c4f82dc575f6c0b885dd9263954056835443922 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Tue, 11 Feb 2020 16:21:01 -0500 Subject: [PATCH] add retries and error handling --- .github/workflows/workflow.yml | 16 ++++++++-------- dist/index.js | Bin 167825 -> 168248 bytes src/installer.ts | 27 ++++++++++++++++++++------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 45b8626f..805d4117 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -9,12 +9,12 @@ jobs: operating-system: [ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - - name: Set Node.js 10.x - uses: actions/setup-node@master + - name: Setup Node.js 12.x + uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: npm install run: npm install @@ -40,12 +40,12 @@ jobs: 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 - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - - name: Set Node.js 10.x - uses: actions/setup-node@master + - name: Setup Node.js 12.x + uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: npm install run: npm install diff --git a/dist/index.js b/dist/index.js index 12c71d3d4c096aa205861f240af6e91e33efe695..9663265367c82ea787bffe9122dd3970af3e1aad 100644 GIT binary patch delta 2897 zcmY*bdu&tZ71wu?IKi73u#4&OZ+!I=7t<}RZlzX# zb+MeKy~k55LuacJBjKpSR^!kn(d1@TxZTbA9M50vCSgZZip2tR*4poIq?WRwk;nZgSx21&!nzcmeo7Ba`g>v?#+V8O7MwDF73Gh`_ScKTXD1( zth!*>EAq6~)Cfa3=V9%5=T(aKlWBT<bDeqeQ=P0GjdR1F!{+2VqOjYDwjIs9G5>-m7fbnU6OQ z!aBuVYsCE{kga@WGvdShEEDw|uthPSvnrtq4N4ubT@fqH_^S?RRTr90aN?d$ctMq> zI_V`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@wFQ;L!-cT|FZ8i?A4#4Ah)PVqWwmcAG z=G0O|jW+txGFgWO$N21L`occD8i4(eayV3CsD%x4u(jFnose}g zf~op$DvZw&x^%hF+wdH)xAy8BG&}Iy7%v3cIuC7?x}+4ibMlu2u#u)zqk$euLT$O4l;lGhN8Dc| z!BsB3o8ch|0D%nCFiz!84H}<_LCH_>2D+rY_>Bm&0gk;h{n5@ z-|mAntGAV#+ghlo@Kg>fEJ`cO8=L7Bz5aJVSl_}ygsbyx>OKxC(_(ZB^7p}@v;j214b&X%^00#S1M(coZ!A&g9a1! zbuVc!$oiR&h@WauhoXOJy!EW~HX49lG`X<40aQJQDKtI*PiQtxAr`=W6Kl|N;ni3(Y$v;pI# zEKdAGSy+bw8OgG`F|kv@gSAW#CR(;Al@C#?WXf5A1(ZaS4avck@t7nfc)(STo`jnJ!}@C zv~4ytSSCXm^%*r`p?X_^x8rC5T*=UEx}RLKyCI2Ge!ElCD{1T4gS8w x$A_k~9Nf_a|9GB-R(k_Sv$$P!d9&8r#VW)~gg}EIk$NKz{6ES+&cf4G{{w5h@GSrU diff --git a/src/installer.ts b/src/installer.ts index 9cc16a5f..cce8fa3d 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -39,15 +39,28 @@ export async function getJava( } else { let compressedFileExtension = ''; if (!jdkFile) { - core.debug('Downloading Jdk from Azul'); - let http: httpm.HttpClient = new httpm.HttpClient('setup-java'); - let contents = await ( - await http.get('https://static.azul.com/zulu/bin/') - ).readBody(); - let refs = contents.match(//gi) || []; + core.debug('Downloading JDK from Azul'); + const http = new httpm.HttpClient('setup-java', undefined, { + allowRetries: true, + maxRetries: 3 + }); + 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(//gi) || []; const downloadInfo = getDownloadInfo(refs, version, javaPackage); - jdkFile = await tc.downloadTool(downloadInfo.url); version = downloadInfo.version; compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';