Skip to content

Commit

Permalink
Enable one-click debugging via the "Enable debug logging" rerun option
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Jul 1, 2022
1 parent ca8a203 commit 53850d8
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async function run() {
}
}

if (core.isDebug() && config !== undefined) {
if (config !== undefined && config.debugMode) {
core.info("Debug mode is on. Printing CodeQL debug logs...");
for (const language of config.languages) {
const databaseDirectory = util.getCodeQLDatabasePath(config, language);
Expand Down
10 changes: 4 additions & 6 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,9 @@ export async function runQueries(
{}
);
const cliCanCountBaseline = await cliCanCountLoC();
const debugMode =
process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] ||
process.env["ACTIONS_RUNNER_DEBUG"] ||
process.env["ACTIONS_STEP_DEBUG"];
if (!cliCanCountBaseline || debugMode) {
const countLocDebugMode =
process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || config.debugMode;
if (!cliCanCountBaseline || countLocDebugMode) {
// count the number of lines in the background
locPromise = countLoc(
path.resolve(),
Expand Down Expand Up @@ -318,7 +316,7 @@ export async function runQueries(
new Date().getTime() - startTimeInterpretResults;
logger.endGroup();
logger.info(analysisSummary);
if (!cliCanCountBaseline || debugMode)
if (!cliCanCountBaseline || countLocDebugMode)
printLinesOfCodeSummary(logger, language, await locPromise);
if (cliCanCountBaseline) logger.info(await runPrintLinesOfCode(language));
} catch (e) {
Expand Down
6 changes: 5 additions & 1 deletion src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ async function run() {
getOptionalInput("packs"),
getOptionalInput("config-file"),
getOptionalInput("db-location"),
getOptionalInput("debug") === "true",
// Debug mode is enabled if:
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
// - The `init` Action is passed `debug: true`.
getOptionalInput("debug") === "true" || !!process.env["RUNNER_DEBUG"],
getOptionalInput("debug-artifact-name") || DEFAULT_DEBUG_ARTIFACT_NAME,
getOptionalInput("debug-database-name") || DEFAULT_DEBUG_DATABASE_NAME,
repositoryNwo,
Expand Down

0 comments on commit 53850d8

Please sign in to comment.