mirror of
https://github.com/actions/download-artifact.git
synced 2025-07-21 14:08:23 +02:00
Refactor loop, break for testing
This commit is contained in:
parent
a8a786b097
commit
503e7a18ae
2 changed files with 33 additions and 21 deletions
|
@ -111,8 +111,9 @@ async function run(): Promise<void> {
|
|||
})
|
||||
}
|
||||
|
||||
const downloadPromises = artifacts.map(artifact =>
|
||||
artifactClient.downloadArtifact(artifact.id, {
|
||||
const downloadPromises = artifacts.map(artifact => ({
|
||||
name: artifact.name,
|
||||
promise: artifactClient.downloadArtifact(artifact.id, {
|
||||
...options,
|
||||
path:
|
||||
isSingleArtifactDownload || inputs.mergeMultiple
|
||||
|
@ -120,23 +121,28 @@ async function run(): Promise<void> {
|
|||
: path.join(resolvedPath, artifact.name),
|
||||
expectedHash: artifact.digest
|
||||
})
|
||||
)
|
||||
}))
|
||||
|
||||
const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS)
|
||||
for (const chunk of chunkedPromises) {
|
||||
const result = await Promise.all(chunk)
|
||||
for (const outcome of result) {
|
||||
if (outcome.digestMismatch) {
|
||||
const chunkPromises = chunk.map(item => item.promise)
|
||||
const results = await Promise.all(chunkPromises)
|
||||
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const outcome = results[i]
|
||||
const artifactName = chunk[i].name
|
||||
|
||||
if (!outcome.digestMismatch) {
|
||||
core.warning(
|
||||
`Artifact digest validation failed. Please verify the integrity of the artifact.`
|
||||
`Artifact '${artifactName}' digest validation failed. Please verify the integrity of the artifact.`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.info(`Total of ${artifacts.length} artifact(s) downloaded`)
|
||||
core.setOutput(Outputs.DownloadPath, resolvedPath)
|
||||
core.info('Download artifact has finished successfully')
|
||||
core.info(`Total of ${artifacts.length} artifact(s) downloaded`)
|
||||
core.setOutput(Outputs.DownloadPath, resolvedPath)
|
||||
core.info('Download artifact has finished successfully')
|
||||
}
|
||||
}
|
||||
|
||||
run().catch(err =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue