From 55cb6b8b94eb4a22f725a5a37b22484d90eada33 Mon Sep 17 00:00:00 2001 From: Chuan-kai Lin Date: Thu, 10 Jul 2025 10:28:03 -0700 Subject: [PATCH] Extract isOverlayAnalysisFeatureEnabled() --- src/config-utils.ts | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/config-utils.ts b/src/config-utils.ts index ff06b02a3..94e71a39e 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -646,6 +646,23 @@ function parseQueriesFromInput( return trimmedInput.split(",").map((query) => ({ uses: query.trim() })); } +async function isOverlayAnalysisFeatureEnabled( + repository: RepositoryNwo, + features: FeatureEnablement, + codeql: CodeQL, +): Promise { + // TODO: Remove the repository owner check once support for overlay analysis + // stabilizes, and no more backward-incompatible changes are expected. + if (!["github", "dsp-testing"].includes(repository.owner)) { + return false; + } + if (!(await features.getValue(Feature.OverlayAnalysis, codeql))) { + return false; + } + // TODO: Add per-language feature checks here + return true; +} + /** * Calculate and validate the overlay database mode and caching to use. * @@ -696,10 +713,7 @@ export async function getOverlayDatabaseMode( "from the CODEQL_OVERLAY_DATABASE_MODE environment variable.", ); } else if ( - // TODO: Remove the repository owner check once support for overlay analysis - // stabilizes, and no more backward-incompatible changes are expected. - ["github", "dsp-testing"].includes(repository.owner) && - (await features.getValue(Feature.OverlayAnalysis, codeql)) + await isOverlayAnalysisFeatureEnabled(repository, features, codeql) ) { if (isAnalyzingPullRequest()) { overlayDatabaseMode = OverlayDatabaseMode.Overlay;