fix: retry tool download process in case of errors

This commit is contained in:
Amin Yahyaabadi 2022-12-21 13:46:00 -08:00
parent 17b183c6e3
commit 84ecfb4b29
7 changed files with 20 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -69,6 +69,7 @@
"path-exists": "^4.0.0", "path-exists": "^4.0.0",
"patha": "^0.4.1", "patha": "^0.4.1",
"quote-unquote": "^1.0.0", "quote-unquote": "^1.0.0",
"retry-as-promised": "^7.0.3",
"semver": "7.3.8", "semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.1", "setup-python": "github:actions/setup-python#v4.3.1",
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e", "time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",

View File

@ -32,7 +32,7 @@ importers:
escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3 escape-path-with-spaces: github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3
escape-quotes: ^1.0.2 escape-quotes: ^1.0.2
escape-string-regexp: ^5.0.0 escape-string-regexp: ^5.0.0
eslint: ^8.29.0 eslint: ^8.28.0
eslint-config-atomic: ^1.18.1 eslint-config-atomic: ^1.18.1
exec-powershell: workspace:1.0.0 exec-powershell: workspace:1.0.0
execa: ^5.1.1 execa: ^5.1.1
@ -51,6 +51,7 @@ importers:
prettier-config-atomic: ^3.1.0 prettier-config-atomic: ^3.1.0
quote-unquote: ^1.0.0 quote-unquote: ^1.0.0
readme-md-generator: ^1.0.0 readme-md-generator: ^1.0.0
retry-as-promised: ^7.0.3
semver: 7.3.8 semver: 7.3.8
setup-python: github:actions/setup-python#v4.3.1 setup-python: github:actions/setup-python#v4.3.1
shx: 0.3.4 shx: 0.3.4
@ -84,6 +85,7 @@ importers:
path-exists: 4.0.0 path-exists: 4.0.0
patha: 0.4.1 patha: 0.4.1
quote-unquote: 1.0.0 quote-unquote: 1.0.0
retry-as-promised: 7.0.3
semver: 7.3.8 semver: 7.3.8
setup-python: github.com/actions/setup-python/2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 setup-python: github.com/actions/setup-python/2c3dd9e7e29afd70cc0950079bde6c979d1f69f9
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
@ -8479,6 +8481,10 @@ packages:
signal-exit: 3.0.7 signal-exit: 3.0.7
dev: true dev: true
/retry-as-promised/7.0.3:
resolution: {integrity: sha512-SEvMa4khHvpU/o6zgh7sK24qm6rxVgKnrSyzb5POeDvZx5N9Bf0s5sQsQ4Fl+HjRp0X+w2UzACGfUnXtx6cJ9Q==}
dev: false
/retry/0.12.0: /retry/0.12.0:
resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==}
engines: {node: '>= 4'} engines: {node: '>= 4'}

View File

@ -12,6 +12,7 @@ import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack" import { setupDnfPack } from "./setupDnfPack"
import { isUbuntu } from "../env/isUbuntu" import { isUbuntu } from "../env/isUbuntu"
import pathExists from "path-exists" import pathExists from "path-exists"
import retry from "retry-as-promised"
/** A type that describes a package */ /** A type that describes a package */
export type PackageInfo = { export type PackageInfo = {
@ -91,7 +92,13 @@ export async function setupBin(
if ((await Promise.all([pathExists(binDir), pathExists(binFile)])).includes(false)) { if ((await Promise.all([pathExists(binDir), pathExists(binFile)])).includes(false)) {
try { try {
info(`Download ${name} ${version}`) info(`Download ${name} ${version}`)
const downloaded = await downloadTool(url) // try to download the package 4 times with 2 seconds delay
const downloaded = await retry(
() => {
return downloadTool(url)
},
{ max: 4, backoffBase: 2000, report: (err) => info(err) }
)
if (!didInit) { if (!didInit) {
info(`Installing extraction dependencies`) info(`Installing extraction dependencies`)