* Download a tool from an url and stream it into a file * * @param url url of tool to download * @param dest path to download tool * @param auth authorization header * @param headers other headers * @returns path to downloaded tool
(url, dest, auth, headers)
| 3958 | * @returns path to downloaded tool |
| 3959 | */ |
| 3960 | function downloadTool(url, dest, auth, headers) { |
| 3961 | return __awaiter(this, void 0, void 0, function* () { |
| 3962 | dest = dest || path.join(_getTempDirectory(), v4_1.default()); |
| 3963 | yield io.mkdirP(path.dirname(dest)); |
| 3964 | core.debug(`Downloading ${url}`); |
| 3965 | core.debug(`Destination ${dest}`); |
| 3966 | const maxAttempts = 3; |
| 3967 | const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); |
| 3968 | const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); |
| 3969 | const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); |
| 3970 | return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { |
| 3971 | return yield downloadToolAttempt(url, dest || '', auth, headers); |
| 3972 | }), (err) => { |
| 3973 | if (err instanceof HTTPError && err.httpStatusCode) { |
| 3974 | // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests |
| 3975 | if (err.httpStatusCode < 500 && |
| 3976 | err.httpStatusCode !== 408 && |
| 3977 | err.httpStatusCode !== 429) { |
| 3978 | return false; |
| 3979 | } |
| 3980 | } |
| 3981 | // Otherwise retry |
| 3982 | return true; |
| 3983 | }); |
| 3984 | }); |
| 3985 | } |
| 3986 | exports.downloadTool = downloadTool; |
| 3987 | function downloadToolAttempt(url, dest, auth, headers) { |
| 3988 | return __awaiter(this, void 0, void 0, function* () { |
nothing calls this directly
no test coverage detected
searching dependent graphs…