From f265dd9392d918a2bd0736228989d389325e9990 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 26 Feb 2026 18:44:50 +0000 Subject: [PATCH] Separate `generateFailedSarif` out of `prepareFailedSarif` --- lib/init-action-post.js | 11 ++++++++++- src/init-action-post-helper.ts | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 5cd5ca0c2..f40d4fd98 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -169806,6 +169806,15 @@ async function prepareFailedSarif(logger, features, config) { } const category = getCategoryInputOrThrow(workflow, jobName, matrix); const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix); + const result = await generateFailedSarif( + features, + config, + category, + checkoutPath + ); + return new Success(result); +} +async function generateFailedSarif(features, config, category, checkoutPath) { const databasePath = config.dbLocation; const codeql = await getCodeQL(config.codeQLCmd); const sarifFile = "../codeql-failed-run.sarif"; @@ -169814,7 +169823,7 @@ async function prepareFailedSarif(logger, features, config) { } else { await codeql.databaseExportDiagnostics(databasePath, sarifFile, category); } - return new Success({ sarifFile, category, checkoutPath }); + return { sarifFile, category, checkoutPath }; } async function maybeUploadFailedSarif(config, repositoryNwo, features, logger) { const failedSarifResult = await prepareFailedSarif(logger, features, config); diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index cdd564853..bf0586f0e 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -112,6 +112,22 @@ async function prepareFailedSarif( } const category = getCategoryInputOrThrow(workflow, jobName, matrix); const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix); + + const result = await generateFailedSarif( + features, + config, + category, + checkoutPath, + ); + return new Success(result); +} + +async function generateFailedSarif( + features: FeatureEnablement, + config: Config, + category: string | undefined, + checkoutPath: string, +) { const databasePath = config.dbLocation; const codeql = await getCodeQL(config.codeQLCmd); @@ -128,7 +144,7 @@ async function prepareFailedSarif( await codeql.databaseExportDiagnostics(databasePath, sarifFile, category); } - return new Success({ sarifFile, category, checkoutPath }); + return { sarifFile, category, checkoutPath }; } /**