mirror of
https://github.com/github/codeql-action.git
synced 2026-04-28 01:48:48 +00:00
Record overlay disablement reason
This commit is contained in:
+3
-3
@@ -15,10 +15,10 @@ import { CliError } from "./cli-errors";
|
||||
import * as codeql from "./codeql";
|
||||
import {
|
||||
AugmentationProperties,
|
||||
Config,
|
||||
defaultAugmentationProperties,
|
||||
generateCodeScanningConfig,
|
||||
} from "./config-utils";
|
||||
defaultAugmentationProperties,
|
||||
} from "./config/db-config";
|
||||
import type { Config } from "./config-utils";
|
||||
import * as defaults from "./defaults.json";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { KnownLanguage } from "./languages";
|
||||
|
||||
+15
-14
@@ -11,8 +11,8 @@ import { AnalysisKind, supportedAnalysisKinds } from "./analyses";
|
||||
import * as api from "./api-client";
|
||||
import { CachingKind } from "./caching-utils";
|
||||
import { createStubCodeQL } from "./codeql";
|
||||
import { UserConfig } from "./config/db-config";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { OverlayDisabledReason } from "./config-utils";
|
||||
import * as errorMessages from "./error-messages";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { RepositoryProperties } from "./feature-flags/properties";
|
||||
@@ -21,6 +21,7 @@ import { GitVersionInfo } from "./git-utils";
|
||||
import { KnownLanguage, Language } from "./languages";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { CODEQL_OVERLAY_MINIMUM_VERSION, OverlayDatabaseMode } from "./overlay";
|
||||
import { OverlayDisabledReason } from "./overlay/diagnostics";
|
||||
import * as overlayStatus from "./overlay/status";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import {
|
||||
@@ -248,7 +249,7 @@ test("initActionState doesn't throw if there are queries configured in the repos
|
||||
};
|
||||
|
||||
// Expected configuration for a CQ-only analysis.
|
||||
const computedConfig: configUtils.UserConfig = {
|
||||
const computedConfig: UserConfig = {
|
||||
"disable-default-queries": true,
|
||||
queries: [{ uses: "code-quality" }],
|
||||
"query-filters": [],
|
||||
@@ -493,7 +494,7 @@ test("load non-empty input", async (t) => {
|
||||
|
||||
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||
|
||||
const userConfig: configUtils.UserConfig = {
|
||||
const userConfig: UserConfig = {
|
||||
name: "my config",
|
||||
"disable-default-queries": true,
|
||||
queries: [{ uses: "./foo" }],
|
||||
@@ -981,7 +982,7 @@ interface OverlayDatabaseModeTestSetup {
|
||||
codeqlVersion: string;
|
||||
gitRoot: string | undefined;
|
||||
gitVersion: GitVersionInfo | undefined;
|
||||
codeScanningConfig: configUtils.UserConfig;
|
||||
codeScanningConfig: UserConfig;
|
||||
diskUsage: DiskUsage | undefined;
|
||||
memoryFlagValue: number;
|
||||
shouldSkipOverlayAnalysisDueToCachedStatus: boolean;
|
||||
@@ -1189,7 +1190,7 @@ test(
|
||||
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
||||
codeScanningConfig: {
|
||||
packs: ["some-custom-pack@1.0.0"],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isDefaultBranch: true,
|
||||
},
|
||||
{
|
||||
@@ -1434,7 +1435,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
"disable-default-queries": true,
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isDefaultBranch: true,
|
||||
},
|
||||
{
|
||||
@@ -1455,7 +1456,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
packs: ["some-custom-pack@1.0.0"],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isDefaultBranch: true,
|
||||
},
|
||||
{
|
||||
@@ -1476,7 +1477,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
queries: [{ uses: "some-query.ql" }],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isDefaultBranch: true,
|
||||
},
|
||||
{
|
||||
@@ -1497,7 +1498,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
"query-filters": [{ include: { "security-severity": "high" } }],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isDefaultBranch: true,
|
||||
},
|
||||
{
|
||||
@@ -1574,7 +1575,7 @@ test(
|
||||
features: [Feature.OverlayAnalysis, Feature.OverlayAnalysisJavascript],
|
||||
codeScanningConfig: {
|
||||
packs: ["some-custom-pack@1.0.0"],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isPullRequest: true,
|
||||
},
|
||||
{
|
||||
@@ -1712,7 +1713,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
"disable-default-queries": true,
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isPullRequest: true,
|
||||
},
|
||||
{
|
||||
@@ -1733,7 +1734,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
packs: ["some-custom-pack@1.0.0"],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isPullRequest: true,
|
||||
},
|
||||
{
|
||||
@@ -1754,7 +1755,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
queries: [{ uses: "some-query.ql" }],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isPullRequest: true,
|
||||
},
|
||||
{
|
||||
@@ -1775,7 +1776,7 @@ test(
|
||||
],
|
||||
codeScanningConfig: {
|
||||
"query-filters": [{ include: { "security-severity": "high" } }],
|
||||
} as configUtils.UserConfig,
|
||||
} as UserConfig,
|
||||
isPullRequest: true,
|
||||
},
|
||||
{
|
||||
|
||||
+8
-82
@@ -27,11 +27,9 @@ import {
|
||||
} from "./config/db-config";
|
||||
import {
|
||||
addNoLanguageDiagnostic,
|
||||
makeDiagnostic,
|
||||
makeTelemetryDiagnostic,
|
||||
} from "./diagnostics";
|
||||
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { EnvVar } from "./environment";
|
||||
import * as errorMessages from "./error-messages";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
@@ -50,6 +48,10 @@ import {
|
||||
import { KnownLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { CODEQL_OVERLAY_MINIMUM_VERSION, OverlayDatabaseMode } from "./overlay";
|
||||
import {
|
||||
addOverlayDisablementDiagnostics,
|
||||
OverlayDisabledReason,
|
||||
} from "./overlay/diagnostics";
|
||||
import { shouldSkipOverlayAnalysis } from "./overlay/status";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
@@ -69,32 +71,6 @@ import {
|
||||
DiskUsage,
|
||||
} from "./util";
|
||||
|
||||
/**
|
||||
* The reason why overlay analysis was disabled, if applicable.
|
||||
*/
|
||||
export enum OverlayDisabledReason {
|
||||
/** Overlay analysis was disabled by a repository property. */
|
||||
DisabledByRepositoryProperty = "disabled-by-repository-property",
|
||||
/** Overlay analysis feature was not enabled. */
|
||||
FeatureNotEnabled = "feature-not-enabled",
|
||||
/** The build mode is incompatible with overlay analysis. */
|
||||
IncompatibleBuildMode = "incompatible-build-mode",
|
||||
/** The CodeQL CLI version is too old to support overlay analysis. */
|
||||
IncompatibleCodeQl = "incompatible-codeql",
|
||||
/** The Git version could not be determined or is too old. */
|
||||
IncompatibleGit = "incompatible-git",
|
||||
/** The runner does not have enough disk space or memory. */
|
||||
InsufficientResources = "insufficient-resources",
|
||||
/** The source root is not inside a git repository. */
|
||||
NoGitRoot = "no-git-root",
|
||||
/** Overlay analysis was skipped because it previously failed with similar hardware resources. */
|
||||
SkippedDueToCachedStatus = "skipped-due-to-cached-status",
|
||||
/** Disk usage could not be determined during the overlay status check. */
|
||||
UnableToDetermineDiskUsage = "unable-to-determine-disk-usage",
|
||||
}
|
||||
|
||||
export * from "./config/db-config";
|
||||
|
||||
/**
|
||||
* The minimum available disk space (in MB) required to perform overlay analysis.
|
||||
* If the available disk space on the runner is below the threshold when deciding
|
||||
@@ -1119,61 +1095,11 @@ export async function initConfig(
|
||||
config.overlayDatabaseMode = overlayDatabaseMode;
|
||||
config.useOverlayDatabaseCaching = useOverlayDatabaseCaching;
|
||||
|
||||
if (
|
||||
overlayDisabledReason === OverlayDisabledReason.SkippedDueToCachedStatus
|
||||
) {
|
||||
addNoLanguageDiagnostic(
|
||||
if (overlayDisabledReason !== undefined) {
|
||||
await addOverlayDisablementDiagnostics(
|
||||
config,
|
||||
makeDiagnostic(
|
||||
"codeql-action/overlay-skipped-due-to-cached-status",
|
||||
"Skipped improved incremental analysis because it failed previously with similar hardware resources",
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
},
|
||||
markdownMessage:
|
||||
`Improved incremental analysis was skipped because it previously failed for this repository ` +
|
||||
`with CodeQL version ${(await inputs.codeql.getVersion()).version} on a runner with similar hardware resources. ` +
|
||||
"Improved incremental analysis may require a significant amount of disk space for some repositories. " +
|
||||
"If you want to enable improved incremental analysis, increase the disk space available " +
|
||||
"to the runner. If that doesn't help, contact GitHub Support for further assistance.\n\n" +
|
||||
"Improved incremental analysis will be automatically retried when the next version of CodeQL is released. " +
|
||||
`You can also manually trigger a retry by [removing](${DocUrl.DELETE_ACTIONS_CACHE_ENTRIES}) \`codeql-overlay-status-*\` entries from the Actions cache.`,
|
||||
severity: "note",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: true,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
overlayDisabledReason === OverlayDisabledReason.DisabledByRepositoryProperty
|
||||
) {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
makeDiagnostic(
|
||||
"codeql-action/overlay-disabled-by-repository-property",
|
||||
"Improved incremental analysis disabled by repository property",
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
},
|
||||
markdownMessage:
|
||||
"Improved incremental analysis has been disabled because the " +
|
||||
`\`${RepositoryPropertyName.DISABLE_OVERLAY}\` repository property is set to \`true\`. ` +
|
||||
"To re-enable improved incremental analysis, set this property to `false` or remove it.",
|
||||
severity: "note",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: true,
|
||||
},
|
||||
},
|
||||
),
|
||||
inputs.codeql,
|
||||
overlayDisabledReason,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { type CodeQL } from "../codeql";
|
||||
import { type Config } from "../config-utils";
|
||||
import {
|
||||
addNoLanguageDiagnostic,
|
||||
makeDiagnostic,
|
||||
makeTelemetryDiagnostic,
|
||||
} from "../diagnostics";
|
||||
import { DocUrl } from "../doc-url";
|
||||
import { RepositoryPropertyName } from "../feature-flags/properties";
|
||||
|
||||
/** Reason why overlay analysis was disabled. */
|
||||
export enum OverlayDisabledReason {
|
||||
/** Overlay analysis was disabled by a repository property. */
|
||||
DisabledByRepositoryProperty = "disabled-by-repository-property",
|
||||
/** Overlay analysis feature was not enabled. */
|
||||
FeatureNotEnabled = "feature-not-enabled",
|
||||
/** The build mode is incompatible with overlay analysis. */
|
||||
IncompatibleBuildMode = "incompatible-build-mode",
|
||||
/** The CodeQL CLI version is too old to support overlay analysis. */
|
||||
IncompatibleCodeQl = "incompatible-codeql",
|
||||
/** The Git version could not be determined or is too old. */
|
||||
IncompatibleGit = "incompatible-git",
|
||||
/** The runner does not have enough disk space or memory. */
|
||||
InsufficientResources = "insufficient-resources",
|
||||
/** The source root is not inside a git repository. */
|
||||
NoGitRoot = "no-git-root",
|
||||
/** Overlay analysis was skipped because it previously failed with similar hardware resources. */
|
||||
SkippedDueToCachedStatus = "skipped-due-to-cached-status",
|
||||
/** Disk usage could not be determined during the overlay status check. */
|
||||
UnableToDetermineDiskUsage = "unable-to-determine-disk-usage",
|
||||
}
|
||||
|
||||
/**
|
||||
* Add diagnostics related to why overlay was disabled. This includes:
|
||||
*
|
||||
* - A telemetry diagnostic that logs the disablement reason.
|
||||
* - User-facing diagnostics for specific disablement reasons that are
|
||||
* actionable by the user.
|
||||
*/
|
||||
export async function addOverlayDisablementDiagnostics(
|
||||
config: Config,
|
||||
codeql: CodeQL,
|
||||
overlayDisabledReason: OverlayDisabledReason,
|
||||
): Promise<void> {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
makeTelemetryDiagnostic(
|
||||
"codeql-action/overlay-disabled",
|
||||
"Overlay analysis disabled",
|
||||
{
|
||||
reason: overlayDisabledReason,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (
|
||||
overlayDisabledReason === OverlayDisabledReason.SkippedDueToCachedStatus
|
||||
) {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
makeDiagnostic(
|
||||
"codeql-action/overlay-disabled-due-to-cached-status",
|
||||
"Skipped improved incremental analysis because it failed previously with similar hardware resources",
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
},
|
||||
markdownMessage:
|
||||
`Improved incremental analysis was skipped because it previously failed for this repository ` +
|
||||
`with CodeQL version ${(await codeql.getVersion()).version} on a runner with similar hardware resources. ` +
|
||||
"Improved incremental analysis may require a significant amount of disk space for some repositories. " +
|
||||
"If you want to enable improved incremental analysis, increase the disk space available " +
|
||||
"to the runner. If that doesn't help, contact GitHub Support for further assistance.\n\n" +
|
||||
"Improved incremental analysis will be automatically retried when the next version of CodeQL is released. " +
|
||||
`You can also manually trigger a retry by [removing](${DocUrl.DELETE_ACTIONS_CACHE_ENTRIES}) \`codeql-overlay-status-*\` entries from the Actions cache.`,
|
||||
severity: "note",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: false,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
overlayDisabledReason === OverlayDisabledReason.DisabledByRepositoryProperty
|
||||
) {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
makeDiagnostic(
|
||||
"codeql-action/overlay-disabled-by-repository-property",
|
||||
"Improved incremental analysis disabled by repository property",
|
||||
{
|
||||
attributes: {
|
||||
languages: config.languages,
|
||||
},
|
||||
markdownMessage:
|
||||
"Improved incremental analysis has been disabled because the " +
|
||||
`\`${RepositoryPropertyName.DISABLE_OVERLAY}\` repository property is set to \`true\`. ` +
|
||||
"To re-enable improved incremental analysis, set this property to `false` or remove it.",
|
||||
severity: "note",
|
||||
visibility: {
|
||||
cliSummaryTable: true,
|
||||
statusPage: true,
|
||||
telemetry: false,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -11,7 +11,8 @@ import * as semver from "semver";
|
||||
|
||||
import * as apiCompatibility from "./api-compatibility.json";
|
||||
import type { CodeQL, VersionInfo } from "./codeql";
|
||||
import type { Config, Pack } from "./config-utils";
|
||||
import type { Pack } from "./config/db-config";
|
||||
import type { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
|
||||
Reference in New Issue
Block a user