Handle different permutations of analysis kinds in analyze action · github/codeql-action@5d95d46 (original) (raw)
`@@ -659,7 +659,11 @@ export async function runQueries(
`
659
659
``
660
660
`for (const language of config.languages) {
`
661
661
`try {
`
662
``
`` -
const sarifFile = path.join(sarifFolder, ${language}.sarif);
``
``
662
`+
// If Code Scanning is enabled, then the main SARIF file is always the Code Scanning one.
`
``
663
`+
// Otherwise, only Code Quality is enabled, and the main SARIF file is the Code Quality one.
`
``
664
`+
const sarifFile = configUtils.isCodeScanningEnabled(config)
`
``
665
`` +
? path.join(sarifFolder, ${language}.sarif)
``
``
666
`` +
: path.join(sarifFolder, ${language}.quality.sarif);
``
663
667
``
664
668
`// This should be empty to run only the query suite that was generated when
`
665
669
`// the database was initialised.
`
`@@ -695,18 +699,43 @@ export async function runQueries(
`
695
699
`` statusReport[analyze_builtin_queries_${language}_duration_ms] =
``
696
700
`new Date().getTime() - startTimeRunQueries;
`
697
701
``
698
``
`` -
logger.startGroup(Interpreting results for ${language});
``
699
702
`const startTimeInterpretResults = new Date();
`
700
``
`-
const analysisSummary = await runInterpretResults(
`
701
``
`-
language,
`
702
``
`-
undefined,
`
703
``
`-
sarifFile,
`
704
``
`-
config.debugMode,
`
705
``
`-
automationDetailsId,
`
706
``
`-
);
`
707
703
``
``
704
`+
// If only one analysis kind is enabled, then the database is initialised for the
`
``
705
`` +
// respective set of queries. Therefore, running interpret-results produces the
``
``
706
`+
// SARIF file we want for the one enabled analysis kind.
`
``
707
`+
let analysisSummary: string | undefined;
`
``
708
`+
if (
`
``
709
`+
configUtils.isCodeScanningEnabled(config) ||
`
``
710
`+
configUtils.isCodeQualityEnabled(config)
`
``
711
`+
) {
`
``
712
`` +
logger.startGroup(Interpreting results for ${language});
``
``
713
+
``
714
`+
// If this is a Code Quality analysis, correct the category to one
`
``
715
`+
// accepted by the Code Quality backend.
`
``
716
`+
let category = automationDetailsId;
`
``
717
`+
if (configUtils.isCodeQualityEnabled(config)) {
`
``
718
`+
category = fixCodeQualityCategory(logger, automationDetailsId);
`
``
719
`+
}
`
``
720
+
``
721
`+
analysisSummary = await runInterpretResults(
`
``
722
`+
language,
`
``
723
`+
undefined,
`
``
724
`+
sarifFile,
`
``
725
`+
config.debugMode,
`
``
726
`+
category,
`
``
727
`+
);
`
``
728
`+
}
`
``
729
+
``
730
`+
// This case is only needed if Code Quality is enabled in addition to Code Scanning.
`
``
731
`+
// In this case, we will have run queries for both analysis kinds. The previous call to
`
``
732
`` +
// interpret-results will have produced a SARIF file for Code Scanning and we now
``
``
733
`+
// need to produce an additional SARIF file for Code Quality.
`
708
734
`let qualityAnalysisSummary: string | undefined;
`
709
``
`-
if (configUtils.isCodeQualityEnabled(config)) {
`
``
735
`+
if (
`
``
736
`+
configUtils.isCodeQualityEnabled(config) &&
`
``
737
`+
configUtils.isCodeScanningEnabled(config)
`
``
738
`+
) {
`
710
739
`` logger.info(Interpreting quality results for ${language});
``
711
740
`const qualityCategory = fixCodeQualityCategory(
`
712
741
`logger,
`
`@@ -730,8 +759,10 @@ export async function runQueries(
`
730
759
`` statusReport[interpret_results_${language}_duration_ms] =
``
731
760
`endTimeInterpretResults.getTime() - startTimeInterpretResults.getTime();
`
732
761
`logger.endGroup();
`
733
``
`-
logger.info(analysisSummary);
`
734
762
``
``
763
`+
if (analysisSummary) {
`
``
764
`+
logger.info(analysisSummary);
`
``
765
`+
}
`
735
766
`if (qualityAnalysisSummary) {
`
736
767
`logger.info(qualityAnalysisSummary);
`
737
768
`}
`