mirror of
https://github.com/github/codeql-action.git
synced 2026-05-01 19:30:49 +00:00
Merge branch 'main' into henrymercer/skip-file-coverage-rollout
This commit is contained in:
+2
-1
@@ -4,12 +4,13 @@ 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 on non-PR analyses.
|
||||
|
||||
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. [#3562](https://github.com/github/codeql-action/pull/3562)
|
||||
- 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)
|
||||
- The CodeQL Action now loads [custom repository properties](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization) on GitHub Enterprise Server, enabling the customization of features such as `github-codeql-disable-overlay` that was previously only available on GitHub.com. [#3559](https://github.com/github/codeql-action/pull/3559)
|
||||
|
||||
## 4.32.6 - 05 Mar 2026
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ export default [
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
"args": "all",
|
||||
"argsIgnorePattern": "^_",
|
||||
}
|
||||
],
|
||||
|
||||
Generated
-5
@@ -162241,11 +162241,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
+2
-13
@@ -107990,11 +107990,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
@@ -112463,10 +112458,7 @@ function areAllRunsUnique(sarifLogs) {
|
||||
// src/upload-lib.ts
|
||||
var GENERIC_403_MSG = "The repo on which this action is running has not opted-in to CodeQL code scanning.";
|
||||
var GENERIC_404_MSG = "The CodeQL code scanning feature is forbidden on this repository.";
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === "GitHub Enterprise Server" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects) {
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
}
|
||||
async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
@@ -112499,10 +112491,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
logger.debug(
|
||||
"Not all SARIF files were produced by CodeQL. Merging files in the action."
|
||||
);
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects,
|
||||
gitHubVersion
|
||||
)) {
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
|
||||
logger.warning(
|
||||
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`
|
||||
);
|
||||
|
||||
Generated
-5
@@ -104290,11 +104290,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
+2
-13
@@ -165727,11 +165727,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
@@ -169553,10 +169548,7 @@ function areAllRunsUnique(sarifLogs) {
|
||||
// src/upload-lib.ts
|
||||
var GENERIC_403_MSG = "The repo on which this action is running has not opted-in to CodeQL code scanning.";
|
||||
var GENERIC_404_MSG = "The CodeQL code scanning feature is forbidden on this repository.";
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === "GitHub Enterprise Server" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects) {
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
}
|
||||
async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
@@ -169589,10 +169581,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
logger.debug(
|
||||
"Not all SARIF files were produced by CodeQL. Merging files in the action."
|
||||
);
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects,
|
||||
gitHubVersion
|
||||
)) {
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
|
||||
logger.warning(
|
||||
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`
|
||||
);
|
||||
|
||||
Generated
+3
-21
@@ -104426,10 +104426,7 @@ var repositoryPropertyParsers = {
|
||||
["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 */) {
|
||||
return {};
|
||||
}
|
||||
async function loadPropertiesFromApi(logger, repositoryNwo) {
|
||||
try {
|
||||
const response = await getRepositoryProperties(repositoryNwo);
|
||||
const remoteProperties = response.data;
|
||||
@@ -105551,11 +105548,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
@@ -109651,8 +109643,6 @@ async function run(startedAt) {
|
||||
);
|
||||
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||
repositoryNwo,
|
||||
gitHubVersion,
|
||||
features,
|
||||
logger
|
||||
);
|
||||
const jobRunUuid = v4_default();
|
||||
@@ -110065,7 +110055,7 @@ exec ${goBinaryPath} "$@"`
|
||||
logger
|
||||
);
|
||||
}
|
||||
async function loadRepositoryProperties(repositoryNwo, gitHubVersion, features, logger) {
|
||||
async function loadRepositoryProperties(repositoryNwo, logger) {
|
||||
const repositoryOwnerType = github2.context.payload.repository?.owner.type;
|
||||
logger.debug(
|
||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`
|
||||
@@ -110076,16 +110066,8 @@ async function loadRepositoryProperties(repositoryNwo, gitHubVersion, features,
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
if (!await features.getValue("use_repository_properties_v2" /* UseRepositoryProperties */)) {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the UseRepositoryProperties feature flag is disabled."
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
try {
|
||||
return new Success(
|
||||
await loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo)
|
||||
);
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error3) {
|
||||
logger.warning(
|
||||
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
||||
|
||||
Generated
-5
@@ -104281,11 +104281,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
-5
@@ -104177,11 +104177,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
-5
@@ -161647,11 +161647,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
-5
@@ -120969,11 +120969,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
+2
-13
@@ -107437,11 +107437,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
@@ -110350,10 +110345,7 @@ function areAllRunsUnique(sarifLogs) {
|
||||
// src/upload-lib.ts
|
||||
var GENERIC_403_MSG = "The repo on which this action is running has not opted-in to CodeQL code scanning.";
|
||||
var GENERIC_404_MSG = "The CodeQL code scanning feature is forbidden on this repository.";
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === "GitHub Enterprise Server" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects) {
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
}
|
||||
async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
@@ -110386,10 +110378,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
logger.debug(
|
||||
"Not all SARIF files were produced by CodeQL. Merging files in the action."
|
||||
);
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects,
|
||||
gitHubVersion
|
||||
)) {
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
|
||||
logger.warning(
|
||||
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`
|
||||
);
|
||||
|
||||
Generated
-5
@@ -161809,11 +161809,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
Generated
+2
-13
@@ -107150,11 +107150,6 @@ var featureConfig = {
|
||||
minimumVersion: void 0,
|
||||
toolsFeature: "bundleSupportsOverlay" /* BundleSupportsOverlay */
|
||||
},
|
||||
["use_repository_properties_v2" /* UseRepositoryProperties */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["validate_db_config" /* ValidateDbConfig */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
@@ -110942,10 +110937,7 @@ async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVe
|
||||
// src/upload-lib.ts
|
||||
var GENERIC_403_MSG = "The repo on which this action is running has not opted-in to CodeQL code scanning.";
|
||||
var GENERIC_404_MSG = "The CodeQL code scanning feature is forbidden on this repository.";
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === "GitHub Enterprise Server" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects) {
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
}
|
||||
async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
@@ -110978,10 +110970,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
logger.debug(
|
||||
"Not all SARIF files were produced by CodeQL. Merging files in the action."
|
||||
);
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects,
|
||||
gitHubVersion
|
||||
)) {
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
|
||||
logger.warning(
|
||||
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`
|
||||
);
|
||||
|
||||
@@ -87,7 +87,6 @@ export enum Feature {
|
||||
StartProxyRemoveUnusedRegistries = "start_proxy_remove_unused_registries",
|
||||
StartProxyUseFeaturesRelease = "start_proxy_use_features_release",
|
||||
UploadOverlayDbToApi = "upload_overlay_db_to_api",
|
||||
UseRepositoryProperties = "use_repository_properties_v2",
|
||||
ValidateDbConfig = "validate_db_config",
|
||||
}
|
||||
|
||||
@@ -349,11 +348,6 @@ export const featureConfig = {
|
||||
minimumVersion: undefined,
|
||||
toolsFeature: ToolsFeature.BundleSupportsOverlay,
|
||||
},
|
||||
[Feature.UseRepositoryProperties]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_USE_REPOSITORY_PROPERTIES",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.ValidateDbConfig]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_VALIDATE_DB_CONFIG",
|
||||
|
||||
@@ -5,7 +5,6 @@ import * as api from "../api-client";
|
||||
import { getRunnerLogger } from "../logging";
|
||||
import { parseRepositoryNwo } from "../repository";
|
||||
import { setupTests } from "../testing-utils";
|
||||
import * as util from "../util";
|
||||
|
||||
import * as properties from "./properties";
|
||||
|
||||
@@ -23,13 +22,7 @@ test.serial(
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
await t.throwsAsync(
|
||||
properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
),
|
||||
properties.loadPropertiesFromApi(logger, mockRepositoryNwo),
|
||||
{
|
||||
message: /Expected repository properties API to return an array/,
|
||||
},
|
||||
@@ -49,13 +42,7 @@ test.serial(
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
await t.throwsAsync(
|
||||
properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
),
|
||||
properties.loadPropertiesFromApi(logger, mockRepositoryNwo),
|
||||
{
|
||||
message:
|
||||
/Expected repository property object to have a 'property_name'/,
|
||||
@@ -79,43 +66,11 @@ test.serial(
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
await t.notThrowsAsync(
|
||||
properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
),
|
||||
properties.loadPropertiesFromApi(logger, mockRepositoryNwo),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"loadPropertiesFromApi returns empty object if on GHES",
|
||||
async (t) => {
|
||||
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||
headers: {},
|
||||
status: 200,
|
||||
url: "",
|
||||
data: [
|
||||
{ property_name: "github-codeql-extra-queries", value: "+queries" },
|
||||
{ property_name: "unknown-property", value: "something" },
|
||||
] satisfies properties.GitHubPropertiesResponse,
|
||||
});
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.GHES,
|
||||
version: "",
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
t.deepEqual(response, {});
|
||||
},
|
||||
);
|
||||
|
||||
test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
||||
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||
headers: {},
|
||||
@@ -129,9 +84,6 @@ test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
@@ -155,9 +107,6 @@ test.serial("loadPropertiesFromApi parses true boolean property", async (t) => {
|
||||
const warningSpy = sinon.spy(logger, "warning");
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
@@ -186,9 +135,6 @@ test.serial(
|
||||
const warningSpy = sinon.spy(logger, "warning");
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
@@ -211,13 +157,7 @@ test.serial(
|
||||
const logger = getRunnerLogger(true);
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
await t.throwsAsync(
|
||||
properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
),
|
||||
properties.loadPropertiesFromApi(logger, mockRepositoryNwo),
|
||||
{
|
||||
message:
|
||||
/Unexpected value for repository property 'github-codeql-extra-queries' \(number\), got: 123/,
|
||||
@@ -244,9 +184,6 @@ test.serial(
|
||||
const warningSpy = sinon.spy(logger, "warning");
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
{
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getRepositoryProperties } from "../api-client";
|
||||
import { Logger } from "../logging";
|
||||
import { RepositoryNwo } from "../repository";
|
||||
import { GitHubVariant, GitHubVersion } from "../util";
|
||||
|
||||
/**
|
||||
* Enumerates repository property names that have some meaning to us.
|
||||
@@ -97,16 +96,9 @@ export type GitHubPropertiesResponse = GitHubRepositoryProperty[];
|
||||
* @returns Returns a partial mapping from `RepositoryPropertyName` to values.
|
||||
*/
|
||||
export async function loadPropertiesFromApi(
|
||||
gitHubVersion: GitHubVersion,
|
||||
logger: Logger,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
): Promise<RepositoryProperties> {
|
||||
// TODO: To be safe for now; later we should replace this with a version check once we know
|
||||
// which version of GHES we expect this to be supported by.
|
||||
if (gitHubVersion.type === GitHubVariant.GHES) {
|
||||
return {};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await getRepositoryProperties(repositoryNwo);
|
||||
const remoteProperties = response.data as GitHubPropertiesResponse;
|
||||
|
||||
+1
-15
@@ -93,7 +93,6 @@ import {
|
||||
checkActionVersion,
|
||||
getErrorMessage,
|
||||
BuildMode,
|
||||
GitHubVersion,
|
||||
Result,
|
||||
getOptionalEnvVar,
|
||||
Success,
|
||||
@@ -250,8 +249,6 @@ async function run(startedAt: Date) {
|
||||
// Fetch the values of known repository properties that affect us.
|
||||
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||
repositoryNwo,
|
||||
gitHubVersion,
|
||||
features,
|
||||
logger,
|
||||
);
|
||||
|
||||
@@ -835,8 +832,6 @@ async function run(startedAt: Date) {
|
||||
*/
|
||||
async function loadRepositoryProperties(
|
||||
repositoryNwo: RepositoryNwo,
|
||||
gitHubVersion: GitHubVersion,
|
||||
features: FeatureEnablement,
|
||||
logger: Logger,
|
||||
): Promise<Result<RepositoryProperties, unknown>> {
|
||||
// See if we can skip loading repository properties early. In particular,
|
||||
@@ -854,17 +849,8 @@ async function loadRepositoryProperties(
|
||||
return new Success({});
|
||||
}
|
||||
|
||||
if (!(await features.getValue(Feature.UseRepositoryProperties))) {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the UseRepositoryProperties feature flag is disabled.",
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
|
||||
try {
|
||||
return new Success(
|
||||
await loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo),
|
||||
);
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error) {
|
||||
logger.warning(
|
||||
`Failed to load repository properties: ${getErrorMessage(error)}`,
|
||||
|
||||
@@ -356,7 +356,6 @@ export async function createStatusReportBase(
|
||||
statusReport.matrix_vars = matrix;
|
||||
}
|
||||
if ("RUNNER_ARCH" in process.env) {
|
||||
// RUNNER_ARCH is available only in GHES 3.4 and later
|
||||
// Values other than X86, X64, ARM, or ARM64 are discarded server side
|
||||
statusReport.runner_arch = process.env["RUNNER_ARCH"];
|
||||
}
|
||||
|
||||
+19
-87
@@ -631,57 +631,10 @@ test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning when on dotcom",
|
||||
async (t) => {
|
||||
t.true(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.DOTCOM,
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.13",
|
||||
async (t) => {
|
||||
t.false(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.GHES,
|
||||
version: "3.13.2",
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.14",
|
||||
async (t) => {
|
||||
t.true(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.GHES,
|
||||
version: "3.14.0",
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning when on GHES 3.16 pre",
|
||||
async (t) => {
|
||||
t.true(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.GHES,
|
||||
version: "3.16.0.pre1",
|
||||
},
|
||||
),
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([
|
||||
createMockSarif("abc", "def"),
|
||||
createMockSarif("abc", "def"),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -690,12 +643,9 @@ test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning with only 1 run",
|
||||
async (t) => {
|
||||
t.false(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.DOTCOM,
|
||||
},
|
||||
),
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([
|
||||
createMockSarif("abc", "def"),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -704,12 +654,10 @@ test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning with distinct categories",
|
||||
async (t) => {
|
||||
t.false(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("def", "def")],
|
||||
{
|
||||
type: GitHubVariant.DOTCOM,
|
||||
},
|
||||
),
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([
|
||||
createMockSarif("abc", "def"),
|
||||
createMockSarif("def", "def"),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -718,12 +666,10 @@ test.serial(
|
||||
"shouldShowCombineSarifFilesDeprecationWarning with distinct tools",
|
||||
async (t) => {
|
||||
t.false(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "abc"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.DOTCOM,
|
||||
},
|
||||
),
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([
|
||||
createMockSarif("abc", "abc"),
|
||||
createMockSarif("abc", "def"),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -734,12 +680,10 @@ test.serial(
|
||||
process.env["CODEQL_MERGE_SARIF_DEPRECATION_WARNING"] = "true";
|
||||
|
||||
t.false(
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.DOTCOM,
|
||||
},
|
||||
),
|
||||
await uploadLib.shouldShowCombineSarifFilesDeprecationWarning([
|
||||
createMockSarif("abc", "def"),
|
||||
createMockSarif("abc", "def"),
|
||||
]),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -759,18 +703,6 @@ test.serial("throwIfCombineSarifFilesDisabled when on dotcom", async (t) => {
|
||||
);
|
||||
});
|
||||
|
||||
test.serial("throwIfCombineSarifFilesDisabled when on GHES 3.13", async (t) => {
|
||||
await t.notThrowsAsync(
|
||||
uploadLib.throwIfCombineSarifFilesDisabled(
|
||||
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
|
||||
{
|
||||
type: GitHubVariant.GHES,
|
||||
version: "3.13.2",
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test.serial("throwIfCombineSarifFilesDisabled when on GHES 3.14", async (t) => {
|
||||
await t.notThrowsAsync(
|
||||
uploadLib.throwIfCombineSarifFilesDisabled(
|
||||
|
||||
+1
-15
@@ -47,16 +47,7 @@ const GENERIC_404_MSG =
|
||||
// Checks whether the deprecation warning for combining SARIF files should be shown.
|
||||
export async function shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects: Array<Partial<sarif.Log>>,
|
||||
githubVersion: GitHubVersion,
|
||||
) {
|
||||
// Do not show this warning on GHES versions before 3.14.0
|
||||
if (
|
||||
githubVersion.type === GitHubVariant.GHES &&
|
||||
satisfiesGHESVersion(githubVersion.version, "<3.14", true)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only give a deprecation warning when not all runs are unique and
|
||||
// we haven't already shown the warning.
|
||||
return (
|
||||
@@ -131,12 +122,7 @@ async function combineSarifFilesUsingCLI(
|
||||
"Not all SARIF files were produced by CodeQL. Merging files in the action.",
|
||||
);
|
||||
|
||||
if (
|
||||
await shouldShowCombineSarifFilesDeprecationWarning(
|
||||
sarifObjects,
|
||||
gitHubVersion,
|
||||
)
|
||||
) {
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
|
||||
logger.warning(
|
||||
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user