Refactor: remove argument array indirection and pass directly instead

This commit is contained in:
Angela P Wen
2024-09-26 13:19:49 -07:00
parent 4a5884aaa5
commit 8e4d3c2dba
6 changed files with 20 additions and 46 deletions
+9 -16
View File
@@ -268,23 +268,16 @@ export async function uploadDebugArtifacts(
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
const artifactUploaderArgs: [
string, // artifact name
string[], // file paths to upload
string, // root directory
artifact.UploadArtifactOptions,
] = [
sanitizeArtifactName(`${artifactName}${suffix}`),
toUpload.map((file) => path.normalize(file)),
path.normalize(rootDir),
{
// ensure we don't keep the debug artifacts around for too long since they can be large.
retentionDays: 7,
},
];
try {
await artifactUploader.uploadArtifact(...artifactUploaderArgs);
await artifactUploader.uploadArtifact(
sanitizeArtifactName(`${artifactName}${suffix}`),
toUpload.map((file) => path.normalize(file)),
path.normalize(rootDir),
{
// ensure we don't keep the debug artifacts around for too long since they can be large.
retentionDays: 7,
},
);
} catch (e) {
// A failure to upload debug artifacts should not fail the entire action.
core.warning(`Failed to upload debug artifacts: ${e}`);
+2 -9
View File
@@ -70,12 +70,7 @@ async function runWrapper() {
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
const artifactUploaderArgs: [
string, // artifact name
string[], // file paths to upload
string, // root directory
artifact.UploadArtifactOptions,
] = [
await artifactUploader.uploadArtifact(
"proxy-log-file",
[logFilePath],
actionsUtil.getTemporaryDirectory(),
@@ -83,9 +78,7 @@ async function runWrapper() {
// ensure we don't keep the debug artifacts around for too long since they can be large.
retentionDays: 7,
},
];
await artifactUploader.uploadArtifact(...artifactUploaderArgs);
);
} catch (e) {
// A failure to upload debug artifacts should not fail the entire action.
core.warning(`Failed to upload debug artifacts: ${e}`);