diff --git a/CHANGELOG.md b/CHANGELOG.md index 17f83fed25..537eec7fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,4 +3,5 @@ ## [UNRELEASED] - Add this changelog file. [#507](https://github.com/github/codeql-action/pull/507) -- Improve grouping of analysis logs. Add a new log group containing a summary of metrics and diagnostics, if they were produced by CodeQL builtin queries. [#515](https://github.com/github/codeql-action/pull/515) \ No newline at end of file +- Improve grouping of analysis logs. Add a new log group containing a summary of metrics and diagnostics, if they were produced by CodeQL builtin queries. [#515](https://github.com/github/codeql-action/pull/515) +- Add metrics and diagnostics summaries from custom query suites to the analysis summary log group. [#532](https://github.com/github/codeql-action/pull/532) diff --git a/lib/analyze.js b/lib/analyze.js index 8c1b5b9009..bc527ff96d 100644 --- a/lib/analyze.js +++ b/lib/analyze.js @@ -92,21 +92,23 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, throw new Error(`Unable to analyse ${language} as no queries were selected for this language`); } try { - let analysisSummary = ""; + let analysisSummaryBuiltIn = ""; + const customAnalysisSummaries = []; if (queries["builtin"].length > 0) { - const startTimeBuliltIn = new Date().getTime(); + const startTimeBuiltIn = new Date().getTime(); const { sarifFile, stdout } = await runQueryGroup(language, "builtin", queries["builtin"], sarifFolder, undefined); - analysisSummary = stdout; + analysisSummaryBuiltIn = stdout; await injectLinesOfCode(sarifFile, language, locPromise); statusReport[`analyze_builtin_queries_${language}_duration_ms`] = - new Date().getTime() - startTimeBuliltIn; + new Date().getTime() - startTimeBuiltIn; } const startTimeCustom = new Date().getTime(); const temporarySarifDir = config.tempDir; const temporarySarifFiles = []; for (let i = 0; i < queries["custom"].length; ++i) { if (queries["custom"][i].queries.length > 0) { - const { sarifFile } = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath); + const { sarifFile, stdout } = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath); + customAnalysisSummaries.push(stdout); temporarySarifFiles.push(sarifFile); } } @@ -118,10 +120,23 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, new Date().getTime() - startTimeCustom; } logger.endGroup(); - // Print the LoC baseline and the summary results from database analyze. + // Print the LoC baseline and the summary results from database analyze for the standard + // query suite and (if appropriate) each custom query suite. logger.startGroup(`Analysis summary for ${language}`); printLinesOfCodeSummary(logger, language, await locPromise); - logger.info(analysisSummary); + logger.info(analysisSummaryBuiltIn); + for (const [i, customSummary] of customAnalysisSummaries.entries()) { + if (customSummary.trim() === "") { + continue; + } + const description = customAnalysisSummaries.length === 1 + ? "custom queries" + : `custom query suite ${i + 1}/${customAnalysisSummaries.length}`; + logger.info(`Analysis summary for ${description}:`); + logger.info(""); + logger.info(customSummary); + logger.info(""); + } logger.endGroup(); } catch (e) { diff --git a/lib/analyze.js.map b/lib/analyze.js.map index 48ddf30ba0..36a53d0d99 100644 --- a/lib/analyze.js.map +++ b/lib/analyze.js.map @@ -1 +1 @@ -{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAE3D,gEAAkD;AAClD,qCAAqC;AAErC,2CAAoD;AACpD,2CAA0D;AAE1D,gEAAkD;AAClD,6CAAiD;AACjD,6CAA+B;AAE/B,MAAa,mBAAoB,SAAQ,KAAK;IAG5C,YAAY,mBAAwC,EAAE,OAAe;QACnE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;CACF;AATD,kDASC;AAmCD,KAAK,UAAU,oBAAoB,CAAC,MAAc;IAChD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAClD,IAAI,Y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AAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE;gBAC5B,MAAM,MAAM,GAAG,GAAG,QAAQ,wBAAwB,CAAC;gBACnD,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC;gBACtC,GAAG,CAAC,UAAU,CAAC,aAAa,GAAG,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC;gBAClE,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI;gBAC5C,6CAA6C;gBAC7C,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,OAAA,CAAC,CAAC,IAAI,0CAAE,EAAE,MAAK,MAAM,CAAA,EAAA,CACpD,CAAC;gBACF,yDAAyD;gBACzD,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;iBACtC;aACF;SACF;QACD,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;KACpD;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,MAAc,EACd,QAAkB,EAClB,UAA6C;IAE7C,IAAI,QAAQ,IAAI,UAAU,EAAE;QAC1B,MAAM,CAAC,IAAI,CACT,WAAW,UAAU,CAAC,QAAQ,CAAC,sBAAsB,QAAQ,iBAAiB,CAC/E,CAAC;KACH;AACH,CAAC"} \ No newline at end of file diff --git a/src/analyze.ts b/src/analyze.ts index 558ab64748..82c65ee4d8 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -176,9 +176,10 @@ export async function runQueries( } try { - let analysisSummary = ""; + let analysisSummaryBuiltIn = ""; + const customAnalysisSummaries: string[] = []; if (queries["builtin"].length > 0) { - const startTimeBuliltIn = new Date().getTime(); + const startTimeBuiltIn = new Date().getTime(); const { sarifFile, stdout } = await runQueryGroup( language, "builtin", @@ -186,24 +187,25 @@ export async function runQueries( sarifFolder, undefined ); - analysisSummary = stdout; + analysisSummaryBuiltIn = stdout; await injectLinesOfCode(sarifFile, language, locPromise); statusReport[`analyze_builtin_queries_${language}_duration_ms`] = - new Date().getTime() - startTimeBuliltIn; + new Date().getTime() - startTimeBuiltIn; } const startTimeCustom = new Date().getTime(); const temporarySarifDir = config.tempDir; const temporarySarifFiles: string[] = []; for (let i = 0; i < queries["custom"].length; ++i) { if (queries["custom"][i].queries.length > 0) { - const { sarifFile } = await runQueryGroup( + const { sarifFile, stdout } = await runQueryGroup( language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath ); + customAnalysisSummaries.push(stdout); temporarySarifFiles.push(sarifFile); } } @@ -217,10 +219,27 @@ export async function runQueries( } logger.endGroup(); - // Print the LoC baseline and the summary results from database analyze. + // Print the LoC baseline and the summary results from database analyze for the standard + // query suite and (if appropriate) each custom query suite. logger.startGroup(`Analysis summary for ${language}`); + printLinesOfCodeSummary(logger, language, await locPromise); - logger.info(analysisSummary); + logger.info(analysisSummaryBuiltIn); + + for (const [i, customSummary] of customAnalysisSummaries.entries()) { + if (customSummary.trim() === "") { + continue; + } + const description = + customAnalysisSummaries.length === 1 + ? "custom queries" + : `custom query suite ${i + 1}/${customAnalysisSummaries.length}`; + logger.info(`Analysis summary for ${description}:`); + logger.info(""); + logger.info(customSummary); + logger.info(""); + } + logger.endGroup(); } catch (e) { logger.info(e);