mirror of
https://github.com/github/codeql-action.git
synced 2026-04-01 17:22:19 +00:00
Add ability to override via repository property
This commit is contained in:
@@ -5,6 +5,11 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
|
||||
## [UNRELEASED]
|
||||
|
||||
- Fixed [a bug](https://github.com/github/codeql-action/issues/3555) which caused the CodeQL Action to fail loading repository properties if a "Multi select" repository property was configured for the repository. [#3557](https://github.com/github/codeql-action/pull/3557)
|
||||
- Added an experimental change which skips collecting file coverage information on pull requests to improve analysis performance. File coverage information will still be computed when analyzing the default branch and protected branches.
|
||||
|
||||
Repositories owned by an organization can opt out of this change by creating a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then setting this property to `true` in the repository's settings. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization).
|
||||
|
||||
We expect to roll this change out to everyone in March. [#TODO](https://github.com/github/codeql-action/pull/TODO)
|
||||
|
||||
## 4.32.6 - 05 Mar 2026
|
||||
|
||||
|
||||
1
lib/analyze-action-post.js
generated
1
lib/analyze-action-post.js
generated
@@ -161733,6 +161733,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/analyze-action.js
generated
1
lib/analyze-action.js
generated
@@ -107232,6 +107232,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/autobuild-action.js
generated
1
lib/autobuild-action.js
generated
@@ -103786,6 +103786,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/init-action-post.js
generated
1
lib/init-action-post.js
generated
@@ -165100,6 +165100,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
13
lib/init-action.js
generated
13
lib/init-action.js
generated
@@ -104406,6 +104406,7 @@ function getUnknownLanguagesError(languages) {
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
function isString(value) {
|
||||
@@ -104422,7 +104423,8 @@ var booleanProperty = {
|
||||
};
|
||||
var repositoryPropertyParsers = {
|
||||
["github-codeql-disable-overlay" /* DISABLE_OVERLAY */]: booleanProperty,
|
||||
["github-codeql-extra-queries" /* EXTRA_QUERIES */]: stringProperty
|
||||
["github-codeql-extra-queries" /* EXTRA_QUERIES */]: stringProperty,
|
||||
["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */]: booleanProperty
|
||||
};
|
||||
async function loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo) {
|
||||
if (gitHubVersion.type === "GitHub Enterprise Server" /* GHES */) {
|
||||
@@ -109091,13 +109093,15 @@ function cleanupDatabaseClusterDirectory(config, logger, options = {}, rmSync2 =
|
||||
}
|
||||
}
|
||||
}
|
||||
async function getFileCoverageInformationEnabled(debugMode, codeql, features) {
|
||||
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() || !await features.getValue("skip_file_coverage_on_prs" /* SkipFileCoverageOnPrs */, codeql)
|
||||
!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)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -109740,7 +109744,8 @@ async function run(startedAt) {
|
||||
enableFileCoverageInformation: await getFileCoverageInformationEnabled(
|
||||
debugMode,
|
||||
codeql,
|
||||
features
|
||||
features,
|
||||
repositoryPropertiesResult.orElse({})
|
||||
),
|
||||
logger
|
||||
});
|
||||
|
||||
1
lib/resolve-environment-action.js
generated
1
lib/resolve-environment-action.js
generated
@@ -103785,6 +103785,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/setup-codeql-action.js
generated
1
lib/setup-codeql-action.js
generated
@@ -104781,6 +104781,7 @@ var semver5 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/start-proxy-action-post.js
generated
1
lib/start-proxy-action-post.js
generated
@@ -161368,6 +161368,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/start-proxy-action.js
generated
1
lib/start-proxy-action.js
generated
@@ -121388,6 +121388,7 @@ var semver5 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/upload-lib.js
generated
1
lib/upload-lib.js
generated
@@ -106826,6 +106826,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/upload-sarif-action-post.js
generated
1
lib/upload-sarif-action-post.js
generated
@@ -161518,6 +161518,7 @@ var semver2 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
1
lib/upload-sarif-action.js
generated
1
lib/upload-sarif-action.js
generated
@@ -107572,6 +107572,7 @@ var semver5 = __toESM(require_semver2());
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
|
||||
@@ -9,12 +9,14 @@ import { GitHubVariant, GitHubVersion } from "../util";
|
||||
export enum RepositoryPropertyName {
|
||||
DISABLE_OVERLAY = "github-codeql-disable-overlay",
|
||||
EXTRA_QUERIES = "github-codeql-extra-queries",
|
||||
FILE_COVERAGE_ON_PRS = "github-codeql-file-coverage-on-prs",
|
||||
}
|
||||
|
||||
/** Parsed types of the known repository properties. */
|
||||
export type AllRepositoryProperties = {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: boolean;
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: boolean;
|
||||
};
|
||||
|
||||
/** Parsed repository properties. */
|
||||
@@ -24,6 +26,7 @@ export type RepositoryProperties = Partial<AllRepositoryProperties>;
|
||||
export type RepositoryPropertyApiType = {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: string;
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: string;
|
||||
};
|
||||
|
||||
/** The type of functions which take the `value` from the API and try to convert it to the type we want. */
|
||||
@@ -70,6 +73,7 @@ const repositoryPropertyParsers: {
|
||||
} = {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: booleanProperty,
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: stringProperty,
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: booleanProperty,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -380,6 +380,7 @@ async function run(startedAt: Date) {
|
||||
debugMode,
|
||||
codeql,
|
||||
features,
|
||||
repositoryPropertiesResult.orElse({}),
|
||||
),
|
||||
logger,
|
||||
});
|
||||
|
||||
@@ -457,6 +457,7 @@ test("file coverage information enabled when debugMode is true", async (t) => {
|
||||
true, // debugMode
|
||||
createStubCodeQL({}),
|
||||
createFeatures([Feature.SkipFileCoverageOnPrs]),
|
||||
{},
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -471,6 +472,7 @@ test.serial(
|
||||
false, // debugMode
|
||||
createStubCodeQL({}),
|
||||
createFeatures([Feature.SkipFileCoverageOnPrs]),
|
||||
{},
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -486,6 +488,25 @@ test.serial(
|
||||
false, // debugMode
|
||||
createStubCodeQL({}),
|
||||
createFeatures([]),
|
||||
{},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"file coverage information enabled when repository property is set",
|
||||
async (t) => {
|
||||
sinon.stub(actionsUtil, "isAnalyzingPullRequest").returns(true);
|
||||
|
||||
t.true(
|
||||
await getFileCoverageInformationEnabled(
|
||||
false, // debugMode
|
||||
createStubCodeQL({}),
|
||||
createFeatures([Feature.SkipFileCoverageOnPrs]),
|
||||
{
|
||||
"github-codeql-file-coverage-on-prs": true,
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -501,6 +522,7 @@ test.serial(
|
||||
false, // debugMode
|
||||
createStubCodeQL({}),
|
||||
createFeatures([Feature.SkipFileCoverageOnPrs]),
|
||||
{},
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -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 { ToolsSource } from "./setup-codeql";
|
||||
@@ -301,6 +305,7 @@ export async function getFileCoverageInformationEnabled(
|
||||
debugMode: boolean,
|
||||
codeql: CodeQL,
|
||||
features: FeatureEnablement,
|
||||
repositoryProperties: RepositoryProperties,
|
||||
): Promise<boolean> {
|
||||
return (
|
||||
// Always enable file coverage information in debug mode
|
||||
@@ -309,6 +314,10 @@ export async function getFileCoverageInformationEnabled(
|
||||
// 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[RepositoryPropertyName.FILE_COVERAGE_ON_PRS] ===
|
||||
true ||
|
||||
!(await features.getValue(Feature.SkipFileCoverageOnPrs, codeql))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user