Add log messages at INFO level about which artifact version used

This commit is contained in:
Angela P Wen
2024-09-26 13:33:43 -07:00
parent bca51cd79e
commit ce99e3489b
9 changed files with 77 additions and 25 deletions
+16 -7
View File
@@ -70,7 +70,7 @@ async function uploadCombinedSarifArtifacts(logger, gitHubVariant, features) {
}
}
try {
await uploadDebugArtifacts(toUpload, baseTempDir, "combined-sarif-artifacts", gitHubVariant, features);
await uploadDebugArtifacts(logger, toUpload, baseTempDir, "combined-sarif-artifacts", gitHubVariant, features);
}
catch (e) {
logger.warning(`Failed to upload combined SARIF files as Actions debugging artifact. Reason: ${(0, util_1.getErrorMessage)(e)}`);
@@ -170,13 +170,13 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger, features) {
return;
}
try {
await (0, logging_1.withGroup)("Uploading debug artifacts", async () => uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName, config.gitHubVersion.type, features));
await (0, logging_1.withGroup)("Uploading debug artifacts", async () => uploadDebugArtifacts(logger, filesToUpload, config.dbLocation, config.debugArtifactName, config.gitHubVersion.type, features));
}
catch (e) {
logger.warning(`Failed to upload debug artifacts. Reason: ${(0, util_1.getErrorMessage)(e)}`);
}
}
async function uploadDebugArtifacts(toUpload, rootDir, artifactName, ghVariant, features) {
async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghVariant, features) {
if (toUpload.length === 0) {
return;
}
@@ -193,10 +193,19 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName, ghVariant,
}
// `@actions/artifact@v2` is not yet supported on GHES so the legacy version of the client will be used on GHES
// until it is supported. We also use the legacy version of the client if the feature flag is disabled.
const artifactUploader = ghVariant !== util_1.GitHubVariant.GHES &&
(await features.getValue(feature_flags_1.Feature.ArtifactV2Upgrade))
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
let artifactUploader;
if (ghVariant === util_1.GitHubVariant.GHES) {
logger.info("Uploading debug artifacts using the `@actions/artifact@v1` client because the `v2` version is not yet supported on GHES.");
artifactUploader = artifactLegacy.create();
}
else if (!(await features.getValue(feature_flags_1.Feature.ArtifactV2Upgrade))) {
logger.info("Uploading debug artifacts using the `@actions/artifact@v1` client because the value of the relevant feature flag is false. To use the `v2` version of the client, set the `CODEQL_ACTION_ARTIFACT_V2_UPGRADE` environment variable to true.");
artifactUploader = artifactLegacy.create();
}
else {
logger.info("Uploading debug artifacts using the `@actions/artifact@v2` client.");
artifactUploader = new artifact.DefaultArtifactClient();
}
try {
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.