From db6938a4d09a8af2acb1b29fe4cfa5592984e870 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 16 Oct 2025 15:00:12 +0100 Subject: [PATCH] Change check to be restrictive by default --- lib/init-action-post.js | 8 ++++---- src/init-action-post-helper.test.ts | 4 ++-- src/init-action-post-helper.ts | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/init-action-post.js b/lib/init-action-post.js index c1fb450be..ebb33f2cb 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -129786,8 +129786,8 @@ function appendExtraQueryExclusions(extraQueryExclusions, cliConfig) { } return augmentedConfig; } -function isCodeQualityEnabled(config) { - return config.analysisKinds.includes("code-quality" /* CodeQuality */); +function isCodeScanningEnabled(config) { + return config.analysisKinds.includes("code-scanning" /* CodeScanning */); } // src/setup-codeql.ts @@ -133753,9 +133753,9 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger "CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */, process.env["CODEQL_ACTION_JOB_STATUS" /* JOB_STATUS */] ?? "JOB_STATUS_CONFIGURATION_ERROR" /* ConfigErrorStatus */ ); - if (config.analysisKinds.length === 1 && isCodeQualityEnabled(config)) { + if (!isCodeScanningEnabled(config)) { return { - upload_failed_run_skipped_because: "Code Quality is the only enabled analysis kind." + upload_failed_run_skipped_because: "Code Scanning is not enabled." }; } try { diff --git a/src/init-action-post-helper.test.ts b/src/init-action-post-helper.test.ts index e6f4243ea..b0afb9b8b 100644 --- a/src/init-action-post-helper.test.ts +++ b/src/init-action-post-helper.test.ts @@ -297,14 +297,14 @@ test("uploading failed SARIF run fails when workflow does not reference github/c t.truthy(result.upload_failed_run_stack_trace); }); -test("not uploading failed SARIF when `code-quality` is the only analysis kind", async (t) => { +test("not uploading failed SARIF when `code-scanning` is not an enabled analysis kind", async (t) => { const result = await testFailedSarifUpload(t, createTestWorkflow([]), { analysisKinds: [AnalysisKind.CodeQuality], expectUpload: false, }); t.is( result.upload_failed_run_skipped_because, - "Code Quality is the only enabled analysis kind.", + "Code Scanning is not enabled.", ); }); diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index 331a8c10b..68bfda9a2 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -7,7 +7,7 @@ import * as actionsUtil from "./actions-util"; import { CodeScanning } from "./analyses"; import { getApiClient } from "./api-client"; import { CodeQL, getCodeQL } from "./codeql"; -import { Config, isCodeQualityEnabled } from "./config-utils"; +import { Config, isCodeScanningEnabled } from "./config-utils"; import * as dependencyCaching from "./dependency-caching"; import { EnvVar } from "./environment"; import { Feature, FeatureEnablement } from "./feature-flags"; @@ -142,10 +142,9 @@ export async function tryUploadSarifIfRunFailed( // If the only enabled analysis kind is `code-quality`, then we shouldn't // upload the failed SARIF to Code Scanning. - if (config.analysisKinds.length === 1 && isCodeQualityEnabled(config)) { + if (!isCodeScanningEnabled(config)) { return { - upload_failed_run_skipped_because: - "Code Quality is the only enabled analysis kind.", + upload_failed_run_skipped_because: "Code Scanning is not enabled.", }; }