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
+3
View File
@@ -4,6 +4,7 @@ import * as debugArtifacts from "./debug-artifacts";
import { Feature } from "./feature-flags";
import { createFeatures } from "./testing-utils";
import { GitHubVariant } from "./util";
import { getActionsLogger } from "./logging";
test("sanitizeArtifactName", (t) => {
t.deepEqual(
@@ -23,9 +24,11 @@ test("sanitizeArtifactName", (t) => {
test("uploadDebugArtifacts", async (t) => {
// Test that no error is thrown if artifacts list is empty.
const logger = getActionsLogger();
const mockFeature = createFeatures([Feature.ArtifactV2Upgrade]);
await t.notThrowsAsync(
debugArtifacts.uploadDebugArtifacts(
logger,
[],
"rootDir",
"artifactName",
+20 -5
View File
@@ -65,6 +65,7 @@ export async function uploadCombinedSarifArtifacts(
try {
await uploadDebugArtifacts(
logger,
toUpload,
baseTempDir,
"combined-sarif-artifacts",
@@ -221,6 +222,7 @@ export async function tryUploadAllAvailableDebugArtifacts(
try {
await withGroup("Uploading debug artifacts", async () =>
uploadDebugArtifacts(
logger,
filesToUpload,
config.dbLocation,
config.debugArtifactName,
@@ -236,6 +238,7 @@ export async function tryUploadAllAvailableDebugArtifacts(
}
export async function uploadDebugArtifacts(
logger: Logger,
toUpload: string[],
rootDir: string,
artifactName: string,
@@ -262,11 +265,23 @@ export async function uploadDebugArtifacts(
// `@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 !== GitHubVariant.GHES &&
(await features.getValue(Feature.ArtifactV2Upgrade))
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
let artifactUploader: artifact.ArtifactClient | artifactLegacy.ArtifactClient;
if (ghVariant === 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.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(
+19 -5
View File
@@ -64,11 +64,25 @@ async function runWrapper() {
try {
// `@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 =
config?.gitHubVersion.type !== GitHubVariant.GHES &&
(await features.getValue(Feature.ArtifactV2Upgrade))
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
let artifactUploader:
| artifact.ArtifactClient
| artifactLegacy.ArtifactClient;
if (gitHubVersion.type === 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.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();
}
await artifactUploader.uploadArtifact(
"proxy-log-file",