Reduce duplication of getFileCoverageInformationEnabled

This commit is contained in:
Henry Mercer
2026-03-10 11:42:53 +00:00
parent 3d2bdbbd3b
commit 55ae11793a
4 changed files with 95 additions and 81 deletions

37
lib/init-action.js generated
View File

@@ -109094,15 +109094,19 @@ function cleanupDatabaseClusterDirectory(config, logger, options = {}, rmSync2 =
}
}
async function getFileCoverageInformationEnabled(debugMode, codeql, features, repositoryProperties) {
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() || // Allow repositories to opt in to file coverage information on PRs
// using a repository property.
repositoryProperties["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */] === true || !await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */, codeql)
);
if (debugMode) {
return { enabled: true, enabledByRepositoryProperty: false };
}
if (!isAnalyzingPullRequest()) {
return { enabled: true, enabledByRepositoryProperty: false };
}
if (!await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */, codeql)) {
return { enabled: true, enabledByRepositoryProperty: false };
}
if (repositoryProperties["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */] === true) {
return { enabled: true, enabledByRepositoryProperty: true };
}
return { enabled: false, enabledByRepositoryProperty: false };
}
// src/status-report.ts
@@ -109714,6 +109718,12 @@ async function run(startedAt) {
analysisKinds = await getAnalysisKinds(logger);
const debugMode = getOptionalInput("debug") === "true" || core13.isDebug();
const repositoryProperties = repositoryPropertiesResult.orElse({});
const fileCoverageResult = await getFileCoverageInformationEnabled(
debugMode,
codeql,
features,
repositoryProperties
);
config = await initConfig2(features, {
analysisKinds,
languagesInput: getOptionalInput("languages"),
@@ -109742,12 +109752,7 @@ async function run(startedAt) {
apiDetails,
features,
repositoryProperties,
enableFileCoverageInformation: await getFileCoverageInformationEnabled(
debugMode,
codeql,
features,
repositoryProperties
),
enableFileCoverageInformation: fileCoverageResult.enabled,
logger
});
if (repositoryPropertiesResult.isFailure()) {
@@ -109762,7 +109767,7 @@ async function run(startedAt) {
)
);
}
if (config.enableFileCoverageInformation && isAnalyzingPullRequest() && await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */, codeql) && repositoryProperties["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */] === true) {
if (fileCoverageResult.enabledByRepositoryProperty) {
addNoLanguageDiagnostic(
config,
makeTelemetryDiagnostic(