Refactor artifact suffix computation into getArtifactSuffix

This commit is contained in:
Michael B. Gale
2026-01-20 12:41:22 +00:00
parent 044ff10e29
commit 69173ea009
4 changed files with 79 additions and 57 deletions

View File

@@ -125707,6 +125707,22 @@ async function uploadCombinedSarifArtifacts(logger, gitHubVariant, codeQlVersion
});
}
}
function getArtifactSuffix(matrix) {
let suffix = "";
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
return suffix;
}
async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) {
if (toUpload.length === 0) {
return "no-artifacts-to-upload";
@@ -125722,20 +125738,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
await scanArtifactsForTokens(toUpload, logger);
core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true");
}
let suffix = "";
const matrix = getOptionalInput("matrix");
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
const suffix = getArtifactSuffix(getOptionalInput("matrix"));
const artifactUploader = await getArtifactUploaderClient(logger, ghVariant);
try {
await artifactUploader.uploadArtifact(

View File

@@ -130430,6 +130430,22 @@ async function tryUploadAllAvailableDebugArtifacts(codeql, config, logger, codeQ
);
}
}
function getArtifactSuffix(matrix) {
let suffix = "";
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
return suffix;
}
async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) {
if (toUpload.length === 0) {
return "no-artifacts-to-upload";
@@ -130445,20 +130461,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
await scanArtifactsForTokens(toUpload, logger);
core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true");
}
let suffix = "";
const matrix = getOptionalInput("matrix");
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
const suffix = getArtifactSuffix(getOptionalInput("matrix"));
const artifactUploader = await getArtifactUploaderClient(logger, ghVariant);
try {
await artifactUploader.uploadArtifact(

View File

@@ -124642,6 +124642,22 @@ async function uploadCombinedSarifArtifacts(logger, gitHubVariant, codeQlVersion
});
}
}
function getArtifactSuffix(matrix) {
let suffix = "";
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
return suffix;
}
async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, codeQlVersion) {
if (toUpload.length === 0) {
return "no-artifacts-to-upload";
@@ -124657,20 +124673,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
await scanArtifactsForTokens(toUpload, logger);
core12.exportVariable("CODEQL_ACTION_ARTIFACT_SCAN_FINISHED", "true");
}
let suffix = "";
const matrix = getOptionalInput("matrix");
if (matrix) {
try {
for (const [, matrixVal] of Object.entries(
JSON.parse(matrix)
).sort())
suffix += `-${matrixVal}`;
} catch {
core12.info(
"Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."
);
}
}
const suffix = getArtifactSuffix(getOptionalInput("matrix"));
const artifactUploader = await getArtifactUploaderClient(logger, ghVariant);
try {
await artifactUploader.uploadArtifact(