1
0
Fork 0
mirror of https://code.forgejo.org/actions/download-artifact synced 2025-06-08 04:58:20 +02:00

Refactor loop, break for testing

This commit is contained in:
Ryan Ghadimi 2025-03-12 15:40:05 +00:00
parent a8a786b097
commit 503e7a18ae
2 changed files with 33 additions and 21 deletions

26
dist/index.js vendored
View file

@ -118769,21 +118769,27 @@ function run() {
core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size})`);
});
}
const downloadPromises = artifacts.map(artifact => artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest })));
const downloadPromises = artifacts.map(artifact => ({
name: artifact.name,
promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))
}));
const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS);
for (const chunk of chunkedPromises) {
const result = yield Promise.all(chunk);
for (const outcome of result) {
if (outcome.digestMismatch) {
core.warning(`Artifact digest validation failed. Please verify the integrity of the artifact.`);
const chunkPromises = chunk.map(item => item.promise);
const results = yield 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 '${artifactName}' digest validation failed. Please verify the integrity of the artifact.`);
}
}
core.info(`Total of ${artifacts.length} artifact(s) downloaded`);
core.setOutput(constants_1.Outputs.DownloadPath, resolvedPath);
core.info('Download artifact has finished successfully');
}
core.info(`Total of ${artifacts.length} artifact(s) downloaded`);
core.setOutput(constants_1.Outputs.DownloadPath, resolvedPath);
core.info('Download artifact has finished successfully');
});
}
run().catch(err => core.setFailed(`Unable to download artifact(s): ${err.message}`));