From 78d398ebc6be2d0a1fb3c058f572b35b95ffe13d Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 17 Sep 2024 10:58:00 +0200 Subject: [PATCH 1/3] Improve docs and method naming --- lib/debug-artifacts.js | 31 ++++++++++++++++------------ lib/debug-artifacts.js.map | 2 +- src/debug-artifacts.ts | 41 ++++++++++++++++++++++---------------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/lib/debug-artifacts.js b/lib/debug-artifacts.js index 4f182750e2..cb892b8081 100644 --- a/lib/debug-artifacts.js +++ b/lib/debug-artifacts.js @@ -72,11 +72,11 @@ async function uploadCombinedSarifArtifacts() { } } /** - * Try to get the SARIF result path for the given language. + * Try to prepare a SARIF result debug artifact for the given language. * - * If an error occurs, log it and return an empty list. + * @return The path to that debug artifact, or undefined if an error occurs. */ -function tryGetSarifResultPath(config, language, logger) { +function tryPrepareSarifDebugArtifact(config, language, logger) { try { const analyzeActionOutputDir = process.env[environment_1.EnvVar.SARIF_RESULTS_OUTPUT_DIR]; if (analyzeActionOutputDir !== undefined && @@ -87,37 +87,36 @@ function tryGetSarifResultPath(config, language, logger) { if (fs.existsSync(sarifFile)) { const sarifInDbLocation = path.resolve(config.dbLocation, `${language}.sarif`); fs.copyFileSync(sarifFile, sarifInDbLocation); - return [sarifInDbLocation]; + return sarifInDbLocation; } } } catch (e) { logger.warning(`Failed to find SARIF results path for ${language}. Reason: ${(0, util_1.getErrorMessage)(e)}`); } - return []; + return undefined; } /** - * Try to bundle the database for the given language. Return a list containing - * the path to the database bundle. + * Try to bundle the database for the given language. * - * If an error occurs, log it and return an empty list. + * @return The path to the database bundle, or undefined if an error occurs. */ async function tryBundleDatabase(config, language, logger) { try { if ((0, analyze_1.dbIsFinalized)(config, language, logger)) { try { - return [await createDatabaseBundleCli(config, language)]; + return await createDatabaseBundleCli(config, language); } catch (e) { logger.warning(`Failed to bundle database for ${language} using the CLI. ` + `Falling back to a partial bundle. Reason: ${(0, util_1.getErrorMessage)(e)}`); } } - return [await createPartialDatabaseBundle(config, language)]; + return await createPartialDatabaseBundle(config, language); } catch (e) { logger.warning(`Failed to bundle database for ${language}. Reason: ${(0, util_1.getErrorMessage)(e)}`); - return []; + return undefined; } } /** @@ -129,7 +128,10 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) { try { const filesToUpload = []; for (const language of config.languages) { - filesToUpload.push(...tryGetSarifResultPath(config, language, logger)); + const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger); + if (sarifResultDebugArtifact) { + filesToUpload.push(sarifResultDebugArtifact); + } // Add any log files const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language); const logsDirectory = path.resolve(databaseDirectory, "log"); @@ -142,7 +144,10 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) { filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory)); } // Add database bundle - filesToUpload.push(...(await tryBundleDatabase(config, language, logger))); + const databaseBundle = await tryBundleDatabase(config, language, logger); + if (databaseBundle) { + filesToUpload.push(databaseBundle); + } } await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName); } diff --git a/lib/debug-artifacts.js.map b/lib/debug-artifacts.js.map index 5785bd50f4..ddceddaaaf 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;AAiFD,kFA0CC;AAED,oDAwCC;AAvOD,uCAAyB;AACzB,2CAA6B;AAE7B,4DAA8C;AAC9C,oDAAsC;AACtC,sDAA6B;AAC7B,8CAAsB;AAEtB,iDAAyE;AACzE,uCAA0C;AAC1C,qCAAqC;AAErC,+CAAuC;AAGvC,iCAMgB;AAEhB,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,o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,CAAC;IACzB,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACjC,GAAG,CAAC,QAAQ,CAAC,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/src/debug-artifacts.ts b/src/debug-artifacts.ts index 51088b77be..cecefcee5a 100644 --- a/src/debug-artifacts.ts +++ b/src/debug-artifacts.ts @@ -67,15 +67,15 @@ export async function uploadCombinedSarifArtifacts() { } /** - * Try to get the SARIF result path for the given language. + * Try to prepare a SARIF result debug artifact for the given language. * - * If an error occurs, log it and return an empty list. + * @return The path to that debug artifact, or undefined if an error occurs. */ -function tryGetSarifResultPath( +function tryPrepareSarifDebugArtifact( config: Config, language: Language, logger: Logger, -): string[] { +): string | undefined { try { const analyzeActionOutputDir = process.env[EnvVar.SARIF_RESULTS_OUTPUT_DIR]; if ( @@ -94,7 +94,7 @@ function tryGetSarifResultPath( `${language}.sarif`, ); fs.copyFileSync(sarifFile, sarifInDbLocation); - return [sarifInDbLocation]; + return sarifInDbLocation; } } } catch (e) { @@ -104,24 +104,23 @@ function tryGetSarifResultPath( )}`, ); } - return []; + return undefined; } /** - * Try to bundle the database for the given language. Return a list containing - * the path to the database bundle. + * Try to bundle the database for the given language. * - * If an error occurs, log it and return an empty list. + * @return The path to the database bundle, or undefined if an error occurs. */ async function tryBundleDatabase( config: Config, language: Language, logger: Logger, -): Promise { +): Promise { try { if (dbIsFinalized(config, language, logger)) { try { - return [await createDatabaseBundleCli(config, language)]; + return await createDatabaseBundleCli(config, language); } catch (e) { logger.warning( `Failed to bundle database for ${language} using the CLI. ` + @@ -129,14 +128,14 @@ async function tryBundleDatabase( ); } } - return [await createPartialDatabaseBundle(config, language)]; + return await createPartialDatabaseBundle(config, language); } catch (e) { logger.warning( `Failed to bundle database for ${language}. Reason: ${getErrorMessage( e, )}`, ); - return []; + return undefined; } } @@ -153,7 +152,14 @@ export async function tryUploadAllAvailableDebugArtifacts( const filesToUpload: string[] = []; for (const language of config.languages) { - filesToUpload.push(...tryGetSarifResultPath(config, language, logger)); + const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact( + config, + language, + logger, + ); + if (sarifResultDebugArtifact) { + filesToUpload.push(sarifResultDebugArtifact); + } // Add any log files const databaseDirectory = getCodeQLDatabasePath(config, language); @@ -172,9 +178,10 @@ export async function tryUploadAllAvailableDebugArtifacts( } // Add database bundle - filesToUpload.push( - ...(await tryBundleDatabase(config, language, logger)), - ); + const databaseBundle = await tryBundleDatabase(config, language, logger); + if (databaseBundle) { + filesToUpload.push(databaseBundle); + } } await uploadDebugArtifacts( From d0a3cf2152cf8cb5726f920a7a258a326526702f Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 17 Sep 2024 11:08:27 +0200 Subject: [PATCH 2/3] Improve logging for debug artifacts --- lib/debug-artifacts.js | 51 ++++++++++++++++----------- lib/debug-artifacts.js.map | 2 +- lib/logging.js | 10 ++++++ lib/logging.js.map | 2 +- src/debug-artifacts.ts | 70 +++++++++++++++++++++++--------------- src/logging.ts | 9 +++++ 6 files changed, 94 insertions(+), 50 deletions(-) diff --git a/lib/debug-artifacts.js b/lib/debug-artifacts.js index cb892b8081..481f1679e9 100644 --- a/lib/debug-artifacts.js +++ b/lib/debug-artifacts.js @@ -40,6 +40,7 @@ const actions_util_1 = require("./actions-util"); const analyze_1 = require("./analyze"); const codeql_1 = require("./codeql"); const environment_1 = require("./environment"); +const logging_1 = require("./logging"); const util_1 = require("./util"); function sanitizeArtifactName(name) { return name.replace(/[^a-zA-Z0-9_\\-]+/g, ""); @@ -128,27 +129,37 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger) { try { const filesToUpload = []; for (const language of config.languages) { - const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger); - if (sarifResultDebugArtifact) { - filesToUpload.push(sarifResultDebugArtifact); - } - // Add any log files - const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language); - const logsDirectory = path.resolve(databaseDirectory, "log"); - if ((0, util_1.doesDirectoryExist)(logsDirectory)) { - filesToUpload.push(...(0, util_1.listFolder)(logsDirectory)); - } - // Multilanguage tracing: there are additional logs in the root of the cluster - const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log"); - if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) { - filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory)); - } - // Add database bundle - const databaseBundle = await tryBundleDatabase(config, language, logger); - if (databaseBundle) { - filesToUpload.push(databaseBundle); - } + await (0, logging_1.withGroup)(`Uploading debug artifacts for ${language}`, async () => { + logger.info("Preparing SARIF result debug artifact..."); + const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact(config, language, logger); + if (sarifResultDebugArtifact) { + filesToUpload.push(sarifResultDebugArtifact); + logger.info("SARIF result debug artifact ready for upload."); + } + logger.info("Preparing database logs debug artifact..."); + const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language); + const logsDirectory = path.resolve(databaseDirectory, "log"); + if ((0, util_1.doesDirectoryExist)(logsDirectory)) { + filesToUpload.push(...(0, util_1.listFolder)(logsDirectory)); + logger.info("Database logs debug artifact ready for upload."); + } + // Multilanguage tracing: there are additional logs in the root of the cluster + logger.info("Preparing database cluster logs debug artifact..."); + const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log"); + if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) { + filesToUpload.push(...(0, util_1.listFolder)(multiLanguageTracingLogsDirectory)); + logger.info("Database cluster logs debug artifact ready for upload."); + } + // Add database bundle + logger.info("Preparing database bundle debug artifact..."); + const databaseBundle = await tryBundleDatabase(config, language, logger); + if (databaseBundle) { + filesToUpload.push(databaseBundle); + logger.info("Database bundle debug artifact ready for upload."); + } + }); } + logger.info("Uploading debug artifacts..."); await uploadDebugArtifacts(filesToUpload, config.dbLocation, config.debugArtifactName); } catch (e) { diff --git a/lib/debug-artifacts.js.map b/lib/debug-artifacts.js.map index ddceddaaaf..5b820d2182 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,kFAkDC;AAED,oDAwCC;AA9OD,uCAAyB;AACzB,2CAA6B;AAE7B,4DAA8C;AAC9C,oDAAsC;AACtC,sDAA6B;AAC7B,8CAAsB;AAEtB,iDAAyE;AACzE,uCAA0C;AAC1C,qCAAqC;AAErC,+CAAuC;AAGvC,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,EAAE,CAAC;QACjE,IAAI,CAAC,IAAI,CACP,2EAA2E,CAC5E,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAE5D,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,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O,CACrC,MAAM,CAAC,UAAU,EACjB,GAAG,MAAM,CAAC,iBAAiB,IAAI,QAAQ,cAAc,CACtD,CAAC;IACF,IAAI,CAAC,IAAI,CACP,GAAG,MAAM,CAAC,iBAAiB,IAAI,QAAQ,2DAA2D,kBAAkB,KAAK,CAC1H,CAAC;IACF,qEAAqE;IACrE,IAAI,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAA,aAAG,EAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,iBAAM,EAAE,CAAC;IACzB,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACjC,GAAG,CAAC,QAAQ,CAAC,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 +{"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,I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KAAK,CAC1H,CAAC;IACF,qEAAqE;IACrE,IAAI,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAA,aAAG,EAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,iBAAM,EAAE,CAAC;IACzB,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACjC,GAAG,CAAC,QAAQ,CAAC,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/logging.js b/lib/logging.js index 250c356739..ce99866176 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.getActionsLogger = getActionsLogger; exports.getRunnerLogger = getRunnerLogger; +exports.withGroup = withGroup; const core = __importStar(require("@actions/core")); function getActionsLogger() { return core; @@ -44,4 +45,13 @@ function getRunnerLogger(debugMode) { endGroup: () => undefined, }; } +function withGroup(groupName, f) { + core.startGroup(groupName); + try { + return f(); + } + finally { + core.endGroup(); + } +} //# sourceMappingURL=logging.js.map \ No newline at end of file diff --git a/lib/logging.js.map b/lib/logging.js.map index 30bc1567a3..ef8515a9da 100644 --- a/lib/logging.js.map +++ b/lib/logging.js.map @@ -1 +1 @@ -{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAhCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAEC;AAED,0CAcC;AAED,8BAOC;AAzCD,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,sCAAsC;QACtC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,sCAAsC;QACtC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,sCAAsC;QACtC,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,sCAAsC;QACtC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAED,SAAgB,SAAS,CAAI,SAAiB,EAAE,CAAU;IACxD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC3B,IAAI,CAAC;QACH,OAAO,CAAC,EAAE,CAAC;IACb,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/src/debug-artifacts.ts b/src/debug-artifacts.ts index cecefcee5a..049bc5f834 100644 --- a/src/debug-artifacts.ts +++ b/src/debug-artifacts.ts @@ -12,7 +12,7 @@ import { getCodeQL } from "./codeql"; import { Config } from "./config-utils"; import { EnvVar } from "./environment"; import { Language } from "./languages"; -import { Logger } from "./logging"; +import { Logger, withGroup } from "./logging"; import { bundleDb, doesDirectoryExist, @@ -152,38 +152,52 @@ export async function tryUploadAllAvailableDebugArtifacts( const filesToUpload: string[] = []; for (const language of config.languages) { - const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact( - config, - language, - logger, - ); - if (sarifResultDebugArtifact) { - filesToUpload.push(sarifResultDebugArtifact); - } + await withGroup(`Uploading debug artifacts for ${language}`, async () => { + logger.info("Preparing SARIF result debug artifact..."); + const sarifResultDebugArtifact = tryPrepareSarifDebugArtifact( + config, + language, + logger, + ); + if (sarifResultDebugArtifact) { + filesToUpload.push(sarifResultDebugArtifact); + logger.info("SARIF result debug artifact ready for upload."); + } - // Add any log files - const databaseDirectory = getCodeQLDatabasePath(config, language); - const logsDirectory = path.resolve(databaseDirectory, "log"); - if (doesDirectoryExist(logsDirectory)) { - filesToUpload.push(...listFolder(logsDirectory)); - } + logger.info("Preparing database logs debug artifact..."); + const databaseDirectory = getCodeQLDatabasePath(config, language); + const logsDirectory = path.resolve(databaseDirectory, "log"); + if (doesDirectoryExist(logsDirectory)) { + filesToUpload.push(...listFolder(logsDirectory)); + logger.info("Database logs debug artifact ready for upload."); + } - // Multilanguage tracing: there are additional logs in the root of the cluster - const multiLanguageTracingLogsDirectory = path.resolve( - config.dbLocation, - "log", - ); - if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) { - filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory)); - } + // Multilanguage tracing: there are additional logs in the root of the cluster + logger.info("Preparing database cluster logs debug artifact..."); + const multiLanguageTracingLogsDirectory = path.resolve( + config.dbLocation, + "log", + ); + if (doesDirectoryExist(multiLanguageTracingLogsDirectory)) { + filesToUpload.push(...listFolder(multiLanguageTracingLogsDirectory)); + logger.info("Database cluster logs debug artifact ready for upload."); + } - // Add database bundle - const databaseBundle = await tryBundleDatabase(config, language, logger); - if (databaseBundle) { - filesToUpload.push(databaseBundle); - } + // Add database bundle + logger.info("Preparing database bundle debug artifact..."); + const databaseBundle = await tryBundleDatabase( + config, + language, + logger, + ); + if (databaseBundle) { + filesToUpload.push(databaseBundle); + logger.info("Database bundle debug artifact ready for upload."); + } + }); } + logger.info("Uploading debug artifacts..."); await uploadDebugArtifacts( filesToUpload, config.dbLocation, diff --git a/src/logging.ts b/src/logging.ts index a9d7fc2ba9..c6d769bc58 100644 --- a/src/logging.ts +++ b/src/logging.ts @@ -31,3 +31,12 @@ export function getRunnerLogger(debugMode: boolean): Logger { endGroup: () => undefined, }; } + +export function withGroup(groupName: string, f: () => T): T { + core.startGroup(groupName); + try { + return f(); + } finally { + core.endGroup(); + } +} From 6e24973d7adf77c81ba32565e7a32243c5f1864f Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Tue, 17 Sep 2024 11:15:08 +0200 Subject: [PATCH 3/3] 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,EAAE,CAAC;QACjE,IAAI,CAAC,IAAI,CACP,2EAA2E,CAC5E,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QAE5D,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAE/C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACn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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(