Skip to content

Commit 7e94a6c

Browse files
committed
Print diagnostic messages when debug logging enabled
This commit prints diagnostic messages to the Actions log when debug logging is enabled by passing `debug: true` to `codeql-action/init` or enabling Actions step debug logging.
1 parent b7da732 commit 7e94a6c

9 files changed

Lines changed: 20 additions & 15 deletions

File tree

lib/analyze.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ export async function runQueries(
308308
const analysisSummary = await runInterpretResults(
309309
language,
310310
querySuitePaths,
311-
sarifFile
311+
sarifFile,
312+
config.debugMode
312313
);
313314
if (!cliCanCountBaseline)
314315
await injectLinesOfCode(sarifFile, language, locPromise);
@@ -337,7 +338,8 @@ export async function runQueries(
337338
async function runInterpretResults(
338339
language: Language,
339340
queries: string[],
340-
sarifFile: string
341+
sarifFile: string,
342+
enableDebugLogging: boolean
341343
): Promise<string> {
342344
const databasePath = util.getCodeQLDatabasePath(config, language);
343345
const codeql = await getCodeQL(config.codeQLCmd);
@@ -347,6 +349,7 @@ export async function runQueries(
347349
sarifFile,
348350
addSnippetsFlag,
349351
threadsFlag,
352+
enableDebugLogging ? "-vv" : "-v",
350353
automationDetailsId
351354
);
352355
}

src/codeql.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ test("databaseInterpretResults() does not set --sarif-add-query-help for 2.7.0",
410410
const runnerConstructorStub = stubToolRunnerConstructor();
411411
const codeqlObject = await codeql.getCodeQLForTesting();
412412
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
413-
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
413+
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
414414
t.false(
415415
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
416416
"--sarif-add-query-help should be absent, but it is present"
@@ -421,7 +421,7 @@ test("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (
421421
const runnerConstructorStub = stubToolRunnerConstructor();
422422
const codeqlObject = await codeql.getCodeQLForTesting();
423423
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
424-
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
424+
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
425425
t.true(
426426
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
427427
"--sarif-add-query-help should be present, but it is absent"

src/codeql.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export interface CodeQL {
156156
sarifFile: string,
157157
addSnippetsFlag: string,
158158
threadsFlag: string,
159+
verbosityFlag: string | undefined,
159160
automationDetailsId: string | undefined
160161
): Promise<string>;
161162
/**
@@ -942,14 +943,15 @@ async function getCodeQLForCmd(
942943
sarifFile: string,
943944
addSnippetsFlag: string,
944945
threadsFlag: string,
946+
verbosityFlag: string,
945947
automationDetailsId: string | undefined
946948
): Promise<string> {
947949
const codeqlArgs = [
948950
"database",
949951
"interpret-results",
950952
threadsFlag,
951953
"--format=sarif-latest",
952-
"-v",
954+
verbosityFlag,
953955
`--output=${sarifFile}`,
954956
addSnippetsFlag,
955957
...getExtraOptionsFromEnv(["database", "interpret-results"]),

0 commit comments

Comments
 (0)