Skip to content

Commit 1ac88f3

Browse files
committed
Unconditionally report unwritten diagnostics at the end of the init Action
1 parent 3901d12 commit 1ac88f3

File tree

6 files changed

+41
-4
lines changed

6 files changed

+41
-4
lines changed

lib/diagnostics.js

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/diagnostics.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/diagnostics.ts

+15
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ function writeDiagnostic(
149149
}
150150
}
151151

152+
/** Report if there are unwritten diagnostics and write them to the log. */
153+
export function logUnwrittenDiagnostics() {
154+
const logger = getActionsLogger();
155+
const num = unwrittenDiagnostics.length;
156+
if (num > 0) {
157+
logger.warning(
158+
`${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`,
159+
);
160+
161+
for (const unwritten of unwrittenDiagnostics) {
162+
logger.debug(JSON.stringify(unwritten.diagnostic));
163+
}
164+
}
165+
}
166+
152167
/** Writes all unwritten diagnostics to disk. */
153168
export function flushDiagnostics(config: Config) {
154169
const logger = getActionsLogger();

src/init-action.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ import {
1616
import { getGitHubVersion } from "./api-client";
1717
import { CodeQL } from "./codeql";
1818
import * as configUtils from "./config-utils";
19-
import { addDiagnostic, flushDiagnostics, makeDiagnostic } from "./diagnostics";
19+
import {
20+
addDiagnostic,
21+
flushDiagnostics,
22+
logUnwrittenDiagnostics,
23+
makeDiagnostic,
24+
} from "./diagnostics";
2025
import { EnvVar } from "./environment";
2126
import { Feature, Features } from "./feature-flags";
2227
import { checkInstallPython311, initCodeQL, initConfig, runInit } from "./init";
@@ -541,6 +546,8 @@ async function run() {
541546
error,
542547
);
543548
return;
549+
} finally {
550+
logUnwrittenDiagnostics();
544551
}
545552
await sendCompletedStatusReport(
546553
startedAt,

0 commit comments

Comments
 (0)