Record overlay disablement reason

This commit is contained in:
Henry Mercer
2026-02-25 14:36:03 +00:00
parent 182427800c
commit 445a2a9bb2
6 changed files with 203 additions and 141 deletions

View File

@@ -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,
);
}