Merge pull request #155 from aminya/retry

This commit is contained in:
Amin Yahyaabadi 2022-12-21 14:04:30 -08:00 committed by GitHub
commit d8f740e0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 8 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",
"patha": "^0.4.1",
"quote-unquote": "^1.0.0",
"retry-as-promised": "^7.0.3",
"semver": "7.3.8",
"setup-python": "github:actions/setup-python#v4.3.1",
"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-quotes: ^1.0.2
escape-string-regexp: ^5.0.0
eslint: ^8.29.0
eslint: ^8.28.0
eslint-config-atomic: ^1.18.1
exec-powershell: workspace:1.0.0
execa: ^5.1.1
@ -51,6 +51,7 @@ importers:
prettier-config-atomic: ^3.1.0
quote-unquote: ^1.0.0
readme-md-generator: ^1.0.0
retry-as-promised: ^7.0.3
semver: 7.3.8
setup-python: github:actions/setup-python#v4.3.1
shx: 0.3.4
@ -84,6 +85,7 @@ importers:
path-exists: 4.0.0
patha: 0.4.1
quote-unquote: 1.0.0
retry-as-promised: 7.0.3
semver: 7.3.8
setup-python: github.com/actions/setup-python/2c3dd9e7e29afd70cc0950079bde6c979d1f69f9
time-delta: github.com/aminya/time-delta/69d91a41cef28e569be9a2991129f5f7d1f0d00e
@ -8479,6 +8481,10 @@ packages:
signal-exit: 3.0.7
dev: true
/retry-as-promised/7.0.3:
resolution: {integrity: sha512-SEvMa4khHvpU/o6zgh7sK24qm6rxVgKnrSyzb5POeDvZx5N9Bf0s5sQsQ4Fl+HjRp0X+w2UzACGfUnXtx6cJ9Q==}
dev: false
/retry/0.12.0:
resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==}
engines: {node: '>= 4'}

View File

@ -6,7 +6,7 @@ import { setupBrewPack } from "../utils/setup/setupBrewPack"
import { setupChocoPack } from "../utils/setup/setupChocoPack"
import { addExeExt, join } from "patha"
import { extractTar, extractZip } from "../utils/setup/extract"
import { notice } from "ci-log"
import { info, notice } from "ci-log"
import { setupGraphviz } from "../graphviz/graphviz"
import { getVersion } from "../versions/versions"
@ -15,6 +15,7 @@ import { hasDnf } from "../utils/env/hasDnf"
import { setupDnfPack } from "../utils/setup/setupDnfPack"
import { isUbuntu } from "../utils/env/isUbuntu"
import pathExists from "path-exists"
import retry from "retry-as-promised"
/** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -48,7 +49,13 @@ function getDoxygenPackageInfo(version: string, platform: NodeJS.Platform, _arch
export async function setupDoxygen(version: string, setupDir: string, arch: string) {
switch (process.platform) {
case "win32": {
await setupChocoPack("doxygen.install", version)
// try to download the package 4 times with 2 seconds delay
await retry(
() => {
return setupChocoPack("doxygen.install", version)
},
{ max: 4, backoffBase: 2000, report: (err) => info(err) }
)
const binDir = await activateWinDoxygen()
const installationInfo = { binDir }
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
@ -100,6 +107,7 @@ async function activateWinDoxygen() {
"C:/Program Files/doxygen/bin",
"C:/Program Files (x86)/doxygen",
]) {
// eslint-disable-next-line no-await-in-loop
if (await pathExists(join(binDir, "doxygen.exe"))) {
// eslint-disable-next-line no-await-in-loop
await addPath(binDir)

View File

@ -12,6 +12,7 @@ import { hasDnf } from "../env/hasDnf"
import { setupDnfPack } from "./setupDnfPack"
import { isUbuntu } from "../env/isUbuntu"
import pathExists from "path-exists"
import retry from "retry-as-promised"
/** A type that describes a package */
export type PackageInfo = {
@ -91,7 +92,13 @@ export async function setupBin(
if ((await Promise.all([pathExists(binDir), pathExists(binFile)])).includes(false)) {
try {
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) {
info(`Installing extraction dependencies`)