From 17cd47509988204615feabcca9b6dc0b4ae03d44 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Mon, 26 Jan 2026 17:55:17 +0000 Subject: [PATCH] Move to separate function --- lib/init-action.js | 21 ++++++++++++++------- src/init-action.ts | 37 +++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/lib/init-action.js b/lib/init-action.js index f11ff5930..bf16508ec 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -92660,13 +92660,10 @@ async function run(startedAt) { apiDetails, features, repositoryProperties, - enableFileCoverageInformation: ( - // Always enable file coverage information in debug mode - debugMode || // We're most interested in speeding up PRs, and we want to keep - // submitting file coverage information for the default branch since - // it is used to populate the status page. - !isAnalyzingPullRequest() || // For now, restrict this feature to the GitHub org - repositoryNwo.owner !== "github" || !await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */) + enableFileCoverageInformation: await getFileCoverageInformationEnabled( + debugMode, + repositoryNwo, + features ), logger }); @@ -92960,6 +92957,16 @@ function getTrapCachingEnabled() { if (!isHostedRunner()) return false; return true; } +async function getFileCoverageInformationEnabled(debugMode, repositoryNwo, features) { + return ( + // Always enable file coverage information in debug mode + debugMode || // We're most interested in speeding up PRs, and we want to keep + // submitting file coverage information for the default branch since + // it is used to populate the status page. + !isAnalyzingPullRequest() || // For now, restrict this feature to the GitHub org + repositoryNwo.owner !== "github" || !await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */) + ); +} async function recordZstdAvailability(config, zstdAvailability) { addDiagnostic( config, diff --git a/src/init-action.ts b/src/init-action.ts index 345dbff30..485346738 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -37,7 +37,7 @@ import { makeTelemetryDiagnostic, } from "./diagnostics"; import { EnvVar } from "./environment"; -import { Feature, Features } from "./feature-flags"; +import { Feature, FeatureEnablement, Features } from "./feature-flags"; import { loadPropertiesFromApi } from "./feature-flags/properties"; import { checkInstallPython311, @@ -54,7 +54,7 @@ import { OverlayBaseDatabaseDownloadStats, OverlayDatabaseMode, } from "./overlay-database-utils"; -import { getRepositoryNwo } from "./repository"; +import { getRepositoryNwo, RepositoryNwo } from "./repository"; import { ToolsSource } from "./setup-codeql"; import { ActionName, @@ -366,16 +366,11 @@ async function run(startedAt: Date) { apiDetails, features, repositoryProperties, - enableFileCoverageInformation: - // Always enable file coverage information in debug mode - debugMode || - // We're most interested in speeding up PRs, and we want to keep - // submitting file coverage information for the default branch since - // it is used to populate the status page. - !isAnalyzingPullRequest() || - // For now, restrict this feature to the GitHub org - repositoryNwo.owner !== "github" || - !(await features.getValue(Feature.SkipFileCoverageOnPrs)), + enableFileCoverageInformation: await getFileCoverageInformationEnabled( + debugMode, + repositoryNwo, + features, + ), logger, }); @@ -799,6 +794,24 @@ function getTrapCachingEnabled(): boolean { return true; } +async function getFileCoverageInformationEnabled( + debugMode: boolean, + repositoryNwo: RepositoryNwo, + features: FeatureEnablement, +): Promise { + return ( + // Always enable file coverage information in debug mode + debugMode || + // We're most interested in speeding up PRs, and we want to keep + // submitting file coverage information for the default branch since + // it is used to populate the status page. + !isAnalyzingPullRequest() || + // For now, restrict this feature to the GitHub org + repositoryNwo.owner !== "github" || + !(await features.getValue(Feature.SkipFileCoverageOnPrs)) + ); +} + async function recordZstdAvailability( config: configUtils.Config, zstdAvailability: ZstdAvailability,