Upload per-database diagnostic SARIFs on green and red runs (#1556)

Co-authored-by: Henry Mercer <henry.mercer@me.com>
This commit is contained in:
Angela P Wen 2023-03-20 14:09:04 -07:00 committed by GitHub
parent b4fba292aa
commit 3cbd063679
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 450 additions and 54 deletions

View file

@ -60,8 +60,17 @@ async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) {
}
const category = (0, workflow_1.getCategoryInputOrThrow)(workflow, jobName, matrix);
const checkoutPath = (0, workflow_1.getCheckoutPathInputOrThrow)(workflow, jobName, matrix);
const databasePath = config.dbLocation;
const sarifFile = "../codeql-failed-run.sarif";
await codeql.diagnosticsExport(sarifFile, category, config, features);
// If there is no database or the feature flag is off, we run 'export diagnostics'
if (databasePath === undefined ||
!(await features.getValue(feature_flags_1.Feature.ExportDiagnosticsEnabled, codeql))) {
await codeql.diagnosticsExport(sarifFile, category, config, features);
}
else {
// We call 'database export-diagnostics' to find any per-database diagnostics.
await codeql.databaseExportDiagnostics(databasePath, sarifFile, category);
}
core.info(`Uploading failed SARIF file ${sarifFile}`);
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });