ci: add retries to downloads for arm testing (#18533)

This commit is contained in:
trop[bot]
2019-05-30 21:08:57 -07:00
committed by Shelley Vohr
parent 851a84d301
commit 7d06861a6d

View File

@@ -49,11 +49,30 @@ async function downloadArtifact (name, buildNum, dest) {
process.exit(1)
} else {
console.log(`Downloading ${artifactToDownload.url}.`)
await downloadFile(artifactToDownload.url, dest)
console.log(`Successfully downloaded ${name}.`)
let downloadError = false
await downloadWithRetry(artifactToDownload.url, dest).catch(err => {
console.log(`Error downnloading ${artifactToDownload.url} :`, err)
downloadError = true
})
if (!downloadError) {
console.log(`Successfully downloaded ${name}.`)
}
}
}
async function downloadWithRetry (url, directory) {
let lastError
for (let i = 0; i < 5; i++) {
console.log(`Attempting to download ${url} - attempt #${(i + 1)}`)
try {
return await downloadFile(url, directory)
} catch (err) {
lastError = err
}
}
throw lastError
}
function downloadFile (url, directory) {
return new Promise((resolve, reject) => {
const nuggetOpts = {