Skip to content

Commit

Permalink
Unconditionally report unwritten diagnostics at the end of the init
Browse files Browse the repository at this point in the history
… Action
  • Loading branch information
Michael B. Gale committed Apr 12, 2024
1 parent 3901d12 commit 1ac88f3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
14 changes: 13 additions & 1 deletion lib/diagnostics.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/diagnostics.js.map

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

3 changes: 3 additions & 0 deletions 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

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ function writeDiagnostic(
}
}

/** Report if there are unwritten diagnostics and write them to the log. */
export function logUnwrittenDiagnostics() {
const logger = getActionsLogger();
const num = unwrittenDiagnostics.length;
if (num > 0) {
logger.warning(
`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`,
);

for (const unwritten of unwrittenDiagnostics) {
logger.debug(JSON.stringify(unwritten.diagnostic));
}
}
}

/** Writes all unwritten diagnostics to disk. */
export function flushDiagnostics(config: Config) {
const logger = getActionsLogger();
Expand Down
9 changes: 8 additions & 1 deletion src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import {
import { getGitHubVersion } from "./api-client";
import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { addDiagnostic, flushDiagnostics, makeDiagnostic } from "./diagnostics";
import {
addDiagnostic,
flushDiagnostics,
logUnwrittenDiagnostics,
makeDiagnostic,
} from "./diagnostics";
import { EnvVar } from "./environment";
import { Feature, Features } from "./feature-flags";
import { checkInstallPython311, initCodeQL, initConfig, runInit } from "./init";
Expand Down Expand Up @@ -541,6 +546,8 @@ async function run() {
error,
);
return;
} finally {
logUnwrittenDiagnostics();
}
await sendCompletedStatusReport(
startedAt,
Expand Down

0 comments on commit 1ac88f3

Please sign in to comment.