diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index fe9c9e12f..dc3893fba 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -161731,6 +161731,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/analyze-action.js b/lib/analyze-action.js index c3e75dc4a..5a1178328 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -107241,6 +107241,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 7164f5624..ffe03382c 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -103784,6 +103784,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 28e39d00a..9f6eee9a7 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -165109,6 +165109,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/init-action.js b/lib/init-action.js index bd2c433d1..757b0ab65 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -104404,11 +104404,13 @@ function getUnknownLanguagesError(languages) { // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); var repositoryPropertyParsers = { ["github-codeql-disable-overlay" /* DISABLE_OVERLAY */]: parseBooleanRepositoryProperty, + ["github-codeql-enable-file-coverage-on-prs" /* ENABLE_FILE_COVERAGE_ON_PRS */]: parseBooleanRepositoryProperty, ["github-codeql-extra-queries" /* EXTRA_QUERIES */]: parseStringRepositoryProperty }; async function loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo) { @@ -109051,13 +109053,15 @@ function cleanupDatabaseClusterDirectory(config, logger, options = {}, rmSync2 = } } } -async function getFileCoverageInformationEnabled(debugMode, repositoryNwo, features) { +async function getFileCoverageInformationEnabled(debugMode, repositoryNwo, 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() || // For now, restrict this feature to the GitHub org + !isAnalyzingPullRequest() || // Allow repository owners to opt in to file coverage on PRs via a + // repository property. + repositoryProperties["github-codeql-enable-file-coverage-on-prs" /* ENABLE_FILE_COVERAGE_ON_PRS */] === true || // For now, restrict this feature to the GitHub org repositoryNwo.owner !== "github" || !await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */) ); } @@ -109701,7 +109705,8 @@ async function run(startedAt) { enableFileCoverageInformation: await getFileCoverageInformationEnabled( debugMode, repositoryNwo, - features + features, + repositoryPropertiesResult.orElse({}) ), logger }); diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index c02bbb249..2aabb1731 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -103783,6 +103783,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 853b7648b..588d78501 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -104777,6 +104777,7 @@ var semver5 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index df3ddb4df..b55373dea 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -161366,6 +161366,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index aa65d267a..c2e9d1b97 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -121384,6 +121384,7 @@ var semver5 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/upload-lib.js b/lib/upload-lib.js index d8d6b6de0..1636733d3 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -106836,6 +106836,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index f65dc4fa3..687083b86 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -161516,6 +161516,7 @@ var semver2 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index be9f6ffe2..4fe45b462 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -107508,6 +107508,7 @@ var semver5 = __toESM(require_semver2()); // src/feature-flags/properties.ts var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => { RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay"; + RepositoryPropertyName2["ENABLE_FILE_COVERAGE_ON_PRS"] = "github-codeql-enable-file-coverage-on-prs"; RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries"; return RepositoryPropertyName2; })(RepositoryPropertyName || {}); diff --git a/src/feature-flags/properties.ts b/src/feature-flags/properties.ts index 3b55fcb6a..422e0eefb 100644 --- a/src/feature-flags/properties.ts +++ b/src/feature-flags/properties.ts @@ -8,12 +8,14 @@ import { GitHubVariant, GitHubVersion } from "../util"; */ export enum RepositoryPropertyName { DISABLE_OVERLAY = "github-codeql-disable-overlay", + ENABLE_FILE_COVERAGE_ON_PRS = "github-codeql-enable-file-coverage-on-prs", EXTRA_QUERIES = "github-codeql-extra-queries", } /** Parsed types of the known repository properties. */ type AllRepositoryProperties = { [RepositoryPropertyName.DISABLE_OVERLAY]: boolean; + [RepositoryPropertyName.ENABLE_FILE_COVERAGE_ON_PRS]: boolean; [RepositoryPropertyName.EXTRA_QUERIES]: string; }; @@ -29,6 +31,8 @@ const repositoryPropertyParsers: { ) => AllRepositoryProperties[K]; } = { [RepositoryPropertyName.DISABLE_OVERLAY]: parseBooleanRepositoryProperty, + [RepositoryPropertyName.ENABLE_FILE_COVERAGE_ON_PRS]: + parseBooleanRepositoryProperty, [RepositoryPropertyName.EXTRA_QUERIES]: parseStringRepositoryProperty, }; diff --git a/src/init-action.ts b/src/init-action.ts index 7bd749e82..eaeca7a6c 100644 --- a/src/init-action.ts +++ b/src/init-action.ts @@ -380,6 +380,7 @@ async function run(startedAt: Date) { debugMode, repositoryNwo, features, + repositoryPropertiesResult.orElse({}), ), logger, }); diff --git a/src/init.test.ts b/src/init.test.ts index 8106a78f9..f426bb3b3 100644 --- a/src/init.test.ts +++ b/src/init.test.ts @@ -7,6 +7,7 @@ import * as sinon from "sinon"; import * as actionsUtil from "./actions-util"; import { createStubCodeQL } from "./codeql"; import { Feature } from "./feature-flags"; +import { RepositoryPropertyName } from "./feature-flags/properties"; import { checkPacksForOverlayCompatibility, cleanupDatabaseClusterDirectory, @@ -455,6 +456,7 @@ test("file coverage information enabled when debugMode is true", async (t) => { true, // debugMode parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.SkipFileCoverageOnPrs]), + {}, ), ); }); @@ -467,6 +469,7 @@ test("file coverage information enabled when not analyzing a pull request", asyn false, // debugMode parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.SkipFileCoverageOnPrs]), + {}, ), ); }); @@ -479,6 +482,7 @@ test("file coverage information enabled when owner is not 'github'", async (t) = false, // debugMode parseRepositoryNwo("other-org/some-repo"), createFeatures([Feature.SkipFileCoverageOnPrs]), + {}, ), ); }); @@ -491,6 +495,7 @@ test("file coverage information enabled when feature flag is not enabled", async false, // debugMode parseRepositoryNwo("github/codeql-action"), createFeatures([]), + {}, ), ); }); @@ -503,6 +508,22 @@ test("file coverage information disabled when all conditions for skipping are me false, // debugMode parseRepositoryNwo("github/codeql-action"), createFeatures([Feature.SkipFileCoverageOnPrs]), + {}, + ), + ); +}); + +test("file coverage information enabled when repository property enables it on PRs", async (t) => { + sinon.stub(actionsUtil, "isAnalyzingPullRequest").returns(true); + + t.true( + await getFileCoverageInformationEnabled( + false, // debugMode + parseRepositoryNwo("github/codeql-action"), + createFeatures([Feature.SkipFileCoverageOnPrs]), + { + [RepositoryPropertyName.ENABLE_FILE_COVERAGE_ON_PRS]: true, + }, ), ); }); diff --git a/src/init.ts b/src/init.ts index a5c8e9ec0..e7cc9ddaf 100644 --- a/src/init.ts +++ b/src/init.ts @@ -18,6 +18,10 @@ import { Feature, FeatureEnablement, } from "./feature-flags"; +import { + RepositoryProperties, + RepositoryPropertyName, +} from "./feature-flags/properties"; import { KnownLanguage, Language } from "./languages"; import { Logger, withGroupAsync } from "./logging"; import { RepositoryNwo } from "./repository"; @@ -302,6 +306,7 @@ export async function getFileCoverageInformationEnabled( debugMode: boolean, repositoryNwo: RepositoryNwo, features: FeatureEnablement, + repositoryProperties: RepositoryProperties, ): Promise { return ( // Always enable file coverage information in debug mode @@ -310,6 +315,10 @@ export async function getFileCoverageInformationEnabled( // submitting file coverage information for the default branch since // it is used to populate the status page. !isAnalyzingPullRequest() || + // Allow repository owners to opt in to file coverage on PRs via a + // repository property. + repositoryProperties[RepositoryPropertyName.ENABLE_FILE_COVERAGE_ON_PRS] === + true || // For now, restrict this feature to the GitHub org repositoryNwo.owner !== "github" || !(await features.getValue(Feature.SkipFileCoverageOnPrs))