Add disabled reason

This commit is contained in:
Henry Mercer
2026-02-25 14:22:13 +00:00
parent 70db156dcb
commit 182427800c
3 changed files with 109 additions and 52 deletions
+20 -20
View File
@@ -106248,8 +106248,7 @@ async function runnerSupportsOverlayAnalysis(diskUsage, ramInput, logger, useV2R
async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, buildMode, ramInput, codeScanningConfig, repositoryProperties, gitVersion, logger) {
let overlayDatabaseMode = "none" /* None */;
let useOverlayDatabaseCaching = false;
let skippedDueToCachedStatus = false;
let disabledByRepositoryProperty = false;
let disabledReason;
const modeEnv = process.env.CODEQL_OVERLAY_DATABASE_MODE;
if (modeEnv === "overlay" /* Overlay */ || modeEnv === "overlay-base" /* OverlayBase */ || modeEnv === "none" /* None */) {
overlayDatabaseMode = modeEnv;
@@ -106261,7 +106260,7 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b
`Setting overlay database mode to ${"none" /* None */} because the ${"github-codeql-disable-overlay" /* DISABLE_OVERLAY */} repository property is set to true.`
);
overlayDatabaseMode = "none" /* None */;
disabledByRepositoryProperty = true;
disabledReason = "disabled-by-repository-property" /* DisabledByRepositoryProperty */;
} else if (await isOverlayAnalysisFeatureEnabled(
features,
codeql,
@@ -106286,17 +106285,19 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b
useV2ResourceChecks
)) {
overlayDatabaseMode = "none" /* None */;
disabledReason = "insufficient-resources" /* InsufficientResources */;
} else if (checkOverlayStatus && diskUsage === void 0) {
logger.warning(
`Unable to determine disk usage, therefore setting overlay database mode to ${"none" /* None */}.`
);
overlayDatabaseMode = "none" /* None */;
disabledReason = "unable-to-determine-disk-usage" /* UnableToDetermineDiskUsage */;
} else if (checkOverlayStatus && diskUsage && await shouldSkipOverlayAnalysis(codeql, languages, diskUsage, logger)) {
logger.info(
`Setting overlay database mode to ${"none" /* None */} because overlay analysis previously failed with this combination of languages, disk space, and CodeQL version.`
);
overlayDatabaseMode = "none" /* None */;
skippedDueToCachedStatus = true;
disabledReason = "skipped-due-to-cached-status" /* SkippedDueToCachedStatus */;
} else if (isAnalyzingPullRequest()) {
overlayDatabaseMode = "overlay" /* Overlay */;
useOverlayDatabaseCaching = true;
@@ -106310,15 +106311,16 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b
`Setting overlay database mode to ${overlayDatabaseMode} with caching because we are analyzing the default branch.`
);
}
} else {
disabledReason = "feature-not-enabled" /* FeatureNotEnabled */;
}
const nonOverlayAnalysis = {
const disabledResult = (reason) => ({
overlayDatabaseMode: "none" /* None */,
useOverlayDatabaseCaching: false,
skippedDueToCachedStatus,
disabledByRepositoryProperty
};
disabledReason: reason
});
if (overlayDatabaseMode === "none" /* None */) {
return nonOverlayAnalysis;
return disabledResult(disabledReason);
}
if (buildMode !== "none" /* None */ && (await Promise.all(
languages.map(
@@ -106332,37 +106334,36 @@ async function getOverlayDatabaseMode(codeql, features, languages, sourceRoot, b
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because build-mode is set to "${buildMode}" instead of "none". Falling back to creating a normal full database instead.`
);
return nonOverlayAnalysis;
return disabledResult("incompatible-build-mode" /* IncompatibleBuildMode */);
}
if (!await codeQlVersionAtLeast(codeql, CODEQL_OVERLAY_MINIMUM_VERSION)) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because the CodeQL CLI is older than ${CODEQL_OVERLAY_MINIMUM_VERSION}. Falling back to creating a normal full database instead.`
);
return nonOverlayAnalysis;
return disabledResult("incompatible-codeql" /* IncompatibleCodeQl */);
}
if (await getGitRoot(sourceRoot) === void 0) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because the source root "${sourceRoot}" is not inside a git repository. Falling back to creating a normal full database instead.`
);
return nonOverlayAnalysis;
return disabledResult("no-git-root" /* NoGitRoot */);
}
if (gitVersion === void 0) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because the Git version could not be determined. Falling back to creating a normal full database instead.`
);
return nonOverlayAnalysis;
return disabledResult("incompatible-git" /* IncompatibleGit */);
}
if (!gitVersion.isAtLeast(GIT_MINIMUM_VERSION_FOR_OVERLAY)) {
logger.warning(
`Cannot build an ${overlayDatabaseMode} database because the installed Git version is older than ${GIT_MINIMUM_VERSION_FOR_OVERLAY}. Falling back to creating a normal full database instead.`
);
return nonOverlayAnalysis;
return disabledResult("incompatible-git" /* IncompatibleGit */);
}
return {
overlayDatabaseMode,
useOverlayDatabaseCaching,
skippedDueToCachedStatus,
disabledByRepositoryProperty
disabledReason
};
}
function dbLocationOrDefault(dbLocation, tempDir) {
@@ -106454,8 +106455,7 @@ async function initConfig(features, inputs) {
const {
overlayDatabaseMode,
useOverlayDatabaseCaching,
skippedDueToCachedStatus: overlaySkippedDueToCachedStatus,
disabledByRepositoryProperty: overlayDisabledByRepositoryProperty
disabledReason: overlayDisabledReason
} = await getOverlayDatabaseMode(
inputs.codeql,
inputs.features,
@@ -106473,7 +106473,7 @@ async function initConfig(features, inputs) {
);
config.overlayDatabaseMode = overlayDatabaseMode;
config.useOverlayDatabaseCaching = useOverlayDatabaseCaching;
if (overlaySkippedDueToCachedStatus) {
if (overlayDisabledReason === "skipped-due-to-cached-status" /* SkippedDueToCachedStatus */) {
addNoLanguageDiagnostic(
config,
makeDiagnostic(
@@ -106496,7 +106496,7 @@ Improved incremental analysis will be automatically retried when the next versio
)
);
}
if (overlayDisabledByRepositoryProperty) {
if (overlayDisabledReason === "disabled-by-repository-property" /* DisabledByRepositoryProperty */) {
addNoLanguageDiagnostic(
config,
makeDiagnostic(