From 6e24973d7adf77c81ba32565e7a32243c5f1864f Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 17 Sep 2024 11:15:08 +0200 Subject: [PATCH] Improve logging for combined SARIF debug artifact --- lib/analyze-action-post.js | 4 +- lib/analyze-action-post.js.map | 2 +- lib/debug-artifacts.js | 36 +++++++++-------- lib/debug-artifacts.js.map | 2 +- lib/upload-sarif-action-post.js | 4 +- lib/upload-sarif-action-post.js.map | 2 +- src/analyze-action-post.ts | 7 +++- src/debug-artifacts.ts | 60 ++++++++++++++++------------- src/upload-sarif-action-post.ts | 6 ++- 9 files changed, 72 insertions(+), 51 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index c9d790f9a1..57043b26ff 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -31,13 +31,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const debugArtifacts = __importStar(require("./debug-artifacts")); const environment_1 = require("./environment"); +const logging_1 = require("./logging"); const util_1 = require("./util"); async function runWrapper() { try { + const logger = (0, logging_1.getActionsLogger)(); // Upload SARIF artifacts if we determine that this is a first-party analysis run. // For third-party runs, this artifact will be uploaded in the `upload-sarif-post` step. if (process.env[environment_1.EnvVar.INIT_ACTION_HAS_RUN] === "true") { - await debugArtifacts.uploadCombinedSarifArtifacts(); + await (0, logging_1.withGroup)("Uploading combined SARIF debug artifact", () => debugArtifacts.uploadCombinedSarifArtifacts(logger)); } } catch (error) { diff --git a/lib/analyze-action-post.js.map b/lib/analyze-action-post.js.map index 2e08953e44..e7a2c10ad6 100644 --- a/lib/analyze-action-post.js.map +++ b/lib/analyze-action-post.js.map @@ -1 +1 @@ -{"version":3,"file":"analyze-action-post.js","sourceRoot":"","sources":["../src/analyze-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,kEAAoD;AACpD,+CAAuC;AACvC,iCAAyC;AAEzC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,kFAAkF;QAClF,wFAAwF;QACxF,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAM,CAAC,mBAAmB,CAAC,KAAK,MAAM,EAAE,CAAC;YACvD,MAAM,cAAc,CAAC,4BAA4B,EAAE,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,oCAAoC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAC7D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"analyze-action-post.js","sourceRoot":"","sources":["../src/analyze-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,kEAAoD;AACpD,+CAAuC;AACvC,uCAAwD;AACxD,iCAAyC;AAEzC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;QAElC,kFAAkF;QAClF,wFAAwF;QACxF,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAM,CAAC,mBAAmB,CAAC,KAAK,MAAM,EAAE,CAAC;YACvD,MAAM,IAAA,mBAAS,EAAC,yCAAyC,EAAE,GAAG,EAAE,CAC9D,cAAc,CAAC,4BAA4B,CAAC,MAAM,CAAC,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,oCAAoC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAC7D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/lib/debug-artifacts.js b/lib/debug-artifacts.js index 481f1679e9..b3669d6267 100644 --- a/lib/debug-artifacts.js +++ b/lib/debug-artifacts.js @@ -49,11 +49,11 @@ function sanitizeArtifactName(name) { * Upload Actions SARIF artifacts for debugging when CODEQL_ACTION_DEBUG_COMBINED_SARIF * environment variable is set */ -async function uploadCombinedSarifArtifacts() { +async function uploadCombinedSarifArtifacts(logger) { const tempDir = (0, actions_util_1.getTemporaryDirectory)(); // Upload Actions SARIF artifacts for debugging when environment variable is set if (process.env["CODEQL_ACTION_DEBUG_COMBINED_SARIF"] === "true") { - core.info("Uploading available combined SARIF files as Actions debugging artifact..."); + logger.info("Uploading available combined SARIF files as Actions debugging artifact..."); const baseTempDir = path.resolve(tempDir, "combined-sarif"); const toUpload = []; if (fs.existsSync(baseTempDir)) { @@ -67,9 +67,12 @@ async function uploadCombinedSarifArtifacts() { } } } - if (toUpload.length > 0) { + try { await uploadDebugArtifacts(toUpload, baseTempDir, "combined-sarif-artifacts"); } + catch (e) { + logger.warning(`Failed to upload combined SARIF files as Actions debugging artifact. Reason: ${(0, util_1.getErrorMessage)(e)}`); + } } } /** @@ -126,8 +129,8 @@ async function tryBundleDatabase(config, language, logger) { * Logs and suppresses any errors that occur. */ async function tryUploadAllAvailableDebugArtifacts(config, logger) { + const filesToUpload = []; try { - const filesToUpload = []; for (const language of config.languages) { await (0, logging_1.withGroup)(`Uploading debug artifacts for ${language}`, async () => { logger.info("Preparing SARIF result debug artifact..."); @@ -159,8 +162,13 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) { } }); } - logger.info("Uploading debug artifacts..."); - await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName); + } + catch (e) { + logger.warning(`Failed to prepare debug artifacts. Reason: ${(0, util_1.getErrorMessage)(e)}`); + return; + } + try { + await (0, logging_1.withGroup)("Uploading debug artifacts", async () => uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName)); } catch (e) { logger.warning(`Failed to upload debug artifacts. Reason: ${(0, util_1.getErrorMessage)(e)}`); @@ -181,17 +189,11 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) { core.info("Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input."); } } - try { - await artifact.create().uploadArtifact(sanitizeArtifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir), { - continueOnError: true, - // 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. Reason: ${(0, util_1.getErrorMessage)(e)}`); - } + await artifact.create().uploadArtifact(sanitizeArtifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir), { + continueOnError: true, + // ensure we don't keep the debug artifacts around for too long since they can be large. + retentionDays: 7, + }); } /** * If a database has not been finalized, we cannot run the `codeql database bundle` diff --git a/lib/debug-artifacts.js.map b/lib/debug-artifacts.js.map index 5b820d2182..6740248177 100644 --- a/lib/debug-artifacts.js.map +++ b/lib/debug-artifacts.js.map @@ -1 +1 @@ -{"version":3,"file":"debug-artifacts.js","sourceRoot":"","sources":["../src/debug-artifacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,oDAEC;AAMD,oEAmCC;AAgFD,kFAgEC;AAED,oDAwCC;AA5PD,uCAAyB;AACzB,2CAA6B;AAE7B,4DAA8C;AAC9C,oDAAsC;AACtC,sDAA6B;AAC7B,8CAAsB;AAEtB,iDAAyE;AACzE,uCAA0C;AAC1C,qCAAqC;AAErC,+CAAuC;AAEvC,uCAA8C;AAC9C,iCAMgB;AAEhB,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,4BAA4B;IAChD,MAAM,OAAO,GAAG,IAAA,oCAAqB,GAAE,CAAC;IAExC,gFAAgF;IAChF,IAAI,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,KAAK,MAAM,EAA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kBAAkB,CAAC,CAAC;IACjC,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,uBAAuB,CACpC,MAAc,EACd,QAAkB;IAElB,MAAM,kBAAkB,GAAG,MAAM,IAAA,eAAQ,EACvC,MAAM,EACN,QAAQ,EACR,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,EACjC,GAAG,MAAM,CAAC,iBAAiB,IAAI,QAAQ,EAAE,CAC1C,CAAC;IACF,OAAO,kBAAkB,CAAC;AAC5B,CAAC"} \ No newline at end of file diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index e6495a91e4..dcc49e5cdc 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -31,13 +31,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const debugArtifacts = __importStar(require("./debug-artifacts")); const environment_1 = require("./environment"); +const logging_1 = require("./logging"); const util_1 = require("./util"); async function runWrapper() { try { + const logger = (0, logging_1.getActionsLogger)(); // Upload SARIF artifacts if we determine that this is a third-party analysis run. // For first-party runs, this artifact will be uploaded in the `analyze-post` step. if (process.env[environment_1.EnvVar.INIT_ACTION_HAS_RUN] !== "true") { - await debugArtifacts.uploadCombinedSarifArtifacts(); + await (0, logging_1.withGroup)("Uploading combined SARIF debug artifact", () => debugArtifacts.uploadCombinedSarifArtifacts(logger)); } } catch (error) { diff --git a/lib/upload-sarif-action-post.js.map b/lib/upload-sarif-action-post.js.map index 52a1926bbc..3f3dfbf501 100644 --- a/lib/upload-sarif-action-post.js.map +++ b/lib/upload-sarif-action-post.js.map @@ -1 +1 @@ -{"version":3,"file":"upload-sarif-action-post.js","sourceRoot":"","sources":["../src/upload-sarif-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,kEAAoD;AACpD,+CAAuC;AACvC,iCAAyC;AAEzC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,kFAAkF;QAClF,mFAAmF;QACnF,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAM,CAAC,mBAAmB,CAAC,KAAK,MAAM,EAAE,CAAC;YACvD,MAAM,cAAc,CAAC,4BAA4B,EAAE,CAAC;QACtD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,yCAAyC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"upload-sarif-action-post.js","sourceRoot":"","sources":["../src/upload-sarif-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,kEAAoD;AACpD,+CAAuC;AACvC,uCAAwD;AACxD,iCAAyC;AAEzC,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;QAClC,kFAAkF;QAClF,mFAAmF;QACnF,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAM,CAAC,mBAAmB,CAAC,KAAK,MAAM,EAAE,CAAC;YACvD,MAAM,IAAA,mBAAS,EAAC,yCAAyC,EAAE,GAAG,EAAE,CAC9D,cAAc,CAAC,4BAA4B,CAAC,MAAM,CAAC,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,yCAAyC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"} \ No newline at end of file diff --git a/src/analyze-action-post.ts b/src/analyze-action-post.ts index a202583246..6e456236d9 100644 --- a/src/analyze-action-post.ts +++ b/src/analyze-action-post.ts @@ -7,14 +7,19 @@ import * as core from "@actions/core"; import * as debugArtifacts from "./debug-artifacts"; import { EnvVar } from "./environment"; +import { getActionsLogger, withGroup } from "./logging"; import { getErrorMessage } from "./util"; async function runWrapper() { try { + const logger = getActionsLogger(); + // Upload SARIF artifacts if we determine that this is a first-party analysis run. // For third-party runs, this artifact will be uploaded in the `upload-sarif-post` step. if (process.env[EnvVar.INIT_ACTION_HAS_RUN] === "true") { - await debugArtifacts.uploadCombinedSarifArtifacts(); + await withGroup("Uploading combined SARIF debug artifact", () => + debugArtifacts.uploadCombinedSarifArtifacts(logger), + ); } } catch (error) { core.setFailed( diff --git a/src/debug-artifacts.ts b/src/debug-artifacts.ts index 049bc5f834..d48322cbb5 100644 --- a/src/debug-artifacts.ts +++ b/src/debug-artifacts.ts @@ -29,12 +29,12 @@ export function sanitizeArtifactName(name: string): string { * Upload Actions SARIF artifacts for debugging when CODEQL_ACTION_DEBUG_COMBINED_SARIF * environment variable is set */ -export async function uploadCombinedSarifArtifacts() { +export async function uploadCombinedSarifArtifacts(logger: Logger) { const tempDir = getTemporaryDirectory(); // Upload Actions SARIF artifacts for debugging when environment variable is set if (process.env["CODEQL_ACTION_DEBUG_COMBINED_SARIF"] === "true") { - core.info( + logger.info( "Uploading available combined SARIF files as Actions debugging artifact...", ); @@ -56,12 +56,18 @@ export async function uploadCombinedSarifArtifacts() { } } - if (toUpload.length > 0) { + try { await uploadDebugArtifacts( toUpload, baseTempDir, "combined-sarif-artifacts", ); + } catch (e) { + logger.warning( + `Failed to upload combined SARIF files as Actions debugging artifact. Reason: ${getErrorMessage( + e, + )}`, + ); } } } @@ -148,9 +154,8 @@ export async function tryUploadAllAvailableDebugArtifacts( config: Config, logger: Logger, ) { + const filesToUpload: string[] = []; try { - const filesToUpload: string[] = []; - for (const language of config.languages) { await withGroup(`Uploading debug artifacts for ${language}`, async () => { logger.info("Preparing SARIF result debug artifact..."); @@ -196,12 +201,20 @@ export async function tryUploadAllAvailableDebugArtifacts( } }); } + } catch (e) { + logger.warning( + `Failed to prepare debug artifacts. Reason: ${getErrorMessage(e)}`, + ); + return; + } - logger.info("Uploading debug artifacts..."); - await uploadDebugArtifacts( - filesToUpload, - config.dbLocation, - config.debugArtifactName, + try { + await withGroup("Uploading debug artifacts", async () => + uploadDebugArtifacts( + filesToUpload, + config.dbLocation, + config.debugArtifactName, + ), ); } catch (e) { logger.warning( @@ -233,23 +246,16 @@ export async function uploadDebugArtifacts( } } - try { - await artifact.create().uploadArtifact( - sanitizeArtifactName(`${artifactName}${suffix}`), - toUpload.map((file) => path.normalize(file)), - path.normalize(rootDir), - { - continueOnError: true, - // 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. Reason: ${getErrorMessage(e)}`, - ); - } + await artifact.create().uploadArtifact( + sanitizeArtifactName(`${artifactName}${suffix}`), + toUpload.map((file) => path.normalize(file)), + path.normalize(rootDir), + { + continueOnError: true, + // ensure we don't keep the debug artifacts around for too long since they can be large. + retentionDays: 7, + }, + ); } /** diff --git a/src/upload-sarif-action-post.ts b/src/upload-sarif-action-post.ts index f2db87fd01..1871997437 100644 --- a/src/upload-sarif-action-post.ts +++ b/src/upload-sarif-action-post.ts @@ -7,14 +7,18 @@ import * as core from "@actions/core"; import * as debugArtifacts from "./debug-artifacts"; import { EnvVar } from "./environment"; +import { getActionsLogger, withGroup } from "./logging"; import { getErrorMessage } from "./util"; async function runWrapper() { try { + const logger = getActionsLogger(); // Upload SARIF artifacts if we determine that this is a third-party analysis run. // For first-party runs, this artifact will be uploaded in the `analyze-post` step. if (process.env[EnvVar.INIT_ACTION_HAS_RUN] !== "true") { - await debugArtifacts.uploadCombinedSarifArtifacts(); + await withGroup("Uploading combined SARIF debug artifact", () => + debugArtifacts.uploadCombinedSarifArtifacts(logger), + ); } } catch (error) { core.setFailed(