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.
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -31,6 +31,7 @@ const debugArtifacts = __importStar(require("./debug-artifacts"));
const feature_flags_1 = require("./feature-flags");
const testing_utils_1 = require("./testing-utils");
const util_1 = require("./util");
const logging_1 = require("./logging");
(0, ava_1.default)("sanitizeArtifactName", (t) => {
t.deepEqual(debugArtifacts.sanitizeArtifactName("hello-world_"), "hello-world_");
t.deepEqual(debugArtifacts.sanitizeArtifactName("hello`world`"), "helloworld");
@@ -39,7 +40,8 @@ const util_1 = require("./util");
});
(0, ava_1.default)("uploadDebugArtifacts", async (t) => {
// Test that no error is thrown if artifacts list is empty.
const logger = (0, logging_1.getActionsLogger)();
const mockFeature = (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.ArtifactV2Upgrade]);
await t.notThrowsAsync(debugArtifacts.uploadDebugArtifacts([], "rootDir", "artifactName", util_1.GitHubVariant.DOTCOM, mockFeature));
await t.notThrowsAsync(debugArtifacts.uploadDebugArtifacts(logger, [], "rootDir", "artifactName", util_1.GitHubVariant.DOTCOM, mockFeature));
});
//# sourceMappingURL=debug-artifacts.test.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"debug-artifacts.test.js","sourceRoot":"","sources":["../src/debug-artifacts.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8C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AAS,CACT,cAAc,CAAC,oBAAoB,CAAC,cAAc,CAAC,EACnD,YAAY,CACb,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,oBAAoB,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAC;IAC5E,CAAC,CAAC,SAAS,CACT,cAAc,CAAC,oBAAoB,CAAC,yBAAyB,CAAC,EAC9D,aAAa,CACd,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvC,2DAA2D;IAC3D,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,MAAM,WAAW,GAAG,IAAA,8BAAc,EAAC,CAAC,uBAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChE,MAAM,CAAC,CAAC,cAAc,CACpB,cAAc,CAAC,oBAAoB,CACjC,MAAM,EACN,EAAE,EACF,SAAS,EACT,cAAc,EACd,oBAAa,CAAC,MAAM,EACpB,WAAW,CACZ,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
+13 -4
View File
@@ -64,10 +64,19 @@ 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 !== util_1.GitHubVariant.GHES &&
(await features.getValue(feature_flags_1.Feature.ArtifactV2Upgrade))
? new artifact.DefaultArtifactClient()
: artifactLegacy.create();
let artifactUploader;
if (gitHubVersion.type === 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();
}
await artifactUploader.uploadArtifact("proxy-log-file", [logFilePath], actionsUtil.getTemporaryDirectory(), {
// ensure we don't keep the debug artifacts around for too long since they can be large.
retentionDays: 7,
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,4DAA8C;AAC9C,yEAA2D;AAC3D,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAAgD;AAChD,4DAA8C;AAC9C,mDAAoD;AACpD,uCAA6C;AAC7C,6CAAkD;AAClD,iCAKgB;AAEhB,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/C,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,wCAAwC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CACjE,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACxC,WAAW,CAAC,qBAAqB,EAAE,EACnC,IAAI,CACL,CAAC;IAEF,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CACP,wEAAwE,CACzE,CAAC;QACF,IAAI,MAAM,EAAE,aAAa,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,OAAO,CACV,qFAAqF,CACtF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;QAClC,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAC;QAC/C,IAAA,gCAAyB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,aAAa,GAAG,IAAA,+BAAkB,EACtC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CACzC,CAAC;QACF,MAAM,QAAQ,GAAG,IAAI,wBAAQ,CAC3B,aAAa,EACb,aAAa,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC,MAAM,CACP,CAAC;QAEF,IAAI,CAAC;YACH,+GAA+G;YAC/G,uGAAuG;YACvG,MAAM,gBAAgB,GACpB,MAAM,EAAE,aAAa,CAAC,IAAI,KAAK,oBAAa,CAAC,IAAI;gBACjD,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,uBAAO,CAAC,iBAAiB,CAAC,CAAC;gBAClD,CAAC,CAAC,IAAI,QAAQ,CAAC,qBAAqB,EAAE;gBACtC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YAE9B,MAAM,gBAAgB,CAAC,cAAc,CACnC,gBAAgB,EAChB,CAAC,WAAW,CAAC,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC;gBACE,wFAAwF;gBACxF,aAAa,EAAE,CAAC;aACjB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,yEAAyE;YACzE,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
{"version":3,"file":"start-proxy-action-post.js","sourceRoot":"","sources":["../src/start-proxy-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA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QACF,MAAM,QAAQ,GAAG,IAAI,wBAAQ,CAC3B,aAAa,EACb,aAAa,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC,MAAM,CACP,CAAC;QAEF,IAAI,CAAC;YACH,+GAA+G;YAC/G,uGAAuG;YACvG,IAAI,gBAE6B,CAAC;YAClC,IAAI,aAAa,CAAC,IAAI,KAAK,oBAAa,CAAC,IAAI,EAAE,CAAC;gBAC9C,MAAM,CAAC,IAAI,CACT,0HAA0H,CAC3H,CAAC;gBACF,gBAAgB,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;YAC7C,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,uBAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC;gBACjE,MAAM,CAAC,IAAI,CACT,6OAA6O,CAC9O,CAAC;gBACF,gBAAgB,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CACT,oEAAoE,CACrE,CAAC;gBACF,gBAAgB,GAAG,IAAI,QAAQ,CAAC,qBAAqB,EAAE,CAAC;YAC1D,CAAC;YAED,MAAM,gBAAgB,CAAC,cAAc,CACnC,gBAAgB,EAChB,CAAC,WAAW,CAAC,EACb,WAAW,CAAC,qBAAqB,EAAE,EACnC;gBACE,wFAAwF;gBACxF,aAAa,EAAE,CAAC;aACjB,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,yEAAyE;YACzE,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
+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",