Unconditionally report unwritten diagnostics at the end of the init Action

This commit is contained in:
Michael B. Gale 2024-04-12 14:00:33 +01:00
parent 3901d1208a
commit 1ac88f37c7
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
6 changed files with 41 additions and 4 deletions

View file

@ -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();

View file

@ -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";
@ -541,6 +546,8 @@ async function run() {
error,
);
return;
} finally {
logUnwrittenDiagnostics();
}
await sendCompletedStatusReport(
startedAt,