Call export diagnostics if there is no database

This commit is contained in:
Angela P Wen
2023-03-08 13:02:34 -08:00
parent 1d4190aa39
commit e6c90eacad
3 changed files with 27 additions and 15 deletions
+15 -9
View File
@@ -73,18 +73,24 @@ async function maybeUploadFailedSarif(
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
const databasePath = config.dbLocation;
// We call 'database export-diagnostics' to find any per-database diagnostics.
const sarifFile = "../codeql-failed-run.sarif";
await codeql.databaseExportDiagnostics(
databasePath,
true, // Database is always a cluster for CodeQL versions that support diagnostics.
sarifFile,
category
);
// If there was no SARIF file produced, then we fall back on 'export diagnostics'.
if (!fs.existsSync(sarifFile)) {
// If there is no database, we run 'export diagnostics'
if (databasePath === undefined) {
await codeql.diagnosticsExport(sarifFile, category);
} else {
// We call 'database export-diagnostics' to find any per-database diagnostics.
await codeql.databaseExportDiagnostics(
databasePath,
true, // Database is always a cluster for CodeQL versions that support diagnostics.
sarifFile,
category
);
// If there was no SARIF file produced, then we fall back on 'export diagnostics'.
if (!fs.existsSync(sarifFile)) {
await codeql.diagnosticsExport(sarifFile, category);
}
}
core.info(`Uploading failed SARIF file ${sarifFile}`);