Fix a bug in cli config parsing

When the config specifies queries in external repositories and no other
queries and cli config parsing is enabled, the analyze job is not able
to find any queries to run and it fails. This PR fixes the problem.

Also add some logging statements when writing a copy of the user config
file.
This commit is contained in:
Andrew Eisenberg 2023-01-17 20:59:36 -08:00
parent 40cfcb0a3f
commit 9b1206e898
6 changed files with 42 additions and 24 deletions

View file

@ -222,16 +222,6 @@ export async function runQueries(
);
const packsWithVersion = config.packs[language] || [];
const hasBuiltinQueries = queries?.builtin.length > 0;
const hasCustomQueries = queries?.custom.length > 0;
const hasPackWithCustomQueries = packsWithVersion.length > 0;
if (!hasBuiltinQueries && !hasCustomQueries && !hasPackWithCustomQueries) {
throw new Error(
`Unable to analyze ${language} as no queries were selected for this language`
);
}
try {
if (await util.useCodeScanningConfigInCli(codeql, featureEnablement)) {
// If we are using the code scanning config in the CLI,
@ -262,6 +252,21 @@ export async function runQueries(
logger.info(analysisSummary);
} else {
// config was generated by the action, so must be interpreted by the action.
const hasBuiltinQueries = queries?.builtin.length > 0;
const hasCustomQueries = queries?.custom.length > 0;
const hasPackWithCustomQueries = packsWithVersion.length > 0;
if (
!hasBuiltinQueries &&
!hasCustomQueries &&
!hasPackWithCustomQueries
) {
throw new Error(
`Unable to analyze ${language} as no queries were selected for this language`
);
}
logger.startGroup(`Running queries for ${language}`);
const querySuitePaths: string[] = [];
if (queries["builtin"].length > 0) {