Skip to content

Commit b380175

Browse files
authored
Merge pull request #1133 from github/henrymercer/log-diagnostics-when-debug-enabled
Print diagnostic messages when debugging mode is enabled
2 parents b7da732 + 3a5fa35 commit b380175

10 files changed

Lines changed: 21 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- You can now quickly debug a job that uses the CodeQL Action by re-running the job from the GitHub UI and selecting the "Enable debug logging" option. [#1132](https://github.com/github/codeql-action/pull/1132)
6+
- You can now see diagnostic messages produced by the analysis in the logs of the `analyze` Action by enabling debug mode. To enable debug mode, pass `debug: true` to the `init` Action, or [enable step debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging). This feature is available for CodeQL CLI version 2.10.0 and later. [#1133](https://github.com/github/codeql-action/pull/1133)
67

78
## 2.1.15 - 28 Jun 2022
89

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)