mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Merge remote-tracking branch 'origin/main' into mbg/esbuild/split
This commit is contained in:
100
lib/entry-points.js
generated
100
lib/entry-points.js
generated
@@ -150818,9 +150818,6 @@ function makeTelemetryDiagnostic(id, name, attributes) {
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
var fs6 = __toESM(require("fs"));
|
||||
async function shouldPerformDiffInformedAnalysis(codeql, features, logger) {
|
||||
return await getDiffInformedAnalysisBranches(codeql, features, logger) !== void 0;
|
||||
}
|
||||
async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
if (!await features.getValue("diff_informed_queries" /* DiffInformedQueries */, codeql)) {
|
||||
return void 0;
|
||||
@@ -150837,6 +150834,30 @@ async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
async function prepareDiffInformedAnalysis(codeql, features, logger) {
|
||||
let branches;
|
||||
try {
|
||||
branches = await getDiffInformedAnalysisBranches(codeql, features, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to determine branch information for diff-informed analysis: ${getErrorMessage(e)}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (!branches) {
|
||||
return false;
|
||||
}
|
||||
return await withGroupAsync("Computing PR diff ranges", async () => {
|
||||
try {
|
||||
return await computeAndPersistDiffRanges(branches, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
function writeDiffRangesJsonFile(logger, ranges) {
|
||||
const jsonContents = JSON.stringify(ranges, null, 2);
|
||||
const jsonFilePath = getDiffRangesJsonFilePath();
|
||||
@@ -150887,6 +150908,18 @@ async function getPullRequestEditedDiffRanges(branches, logger) {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
async function computeAndPersistDiffRanges(branches, logger) {
|
||||
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
||||
if (ranges === void 0) {
|
||||
return false;
|
||||
}
|
||||
writeDiffRangesJsonFile(logger, ranges);
|
||||
const distinctFiles = new Set(ranges.map((r) => r.path)).size;
|
||||
logger.info(
|
||||
`Persisted ${ranges.length} diff range(s) across ${distinctFiles} file(s).`
|
||||
);
|
||||
return true;
|
||||
}
|
||||
async function getFileDiffsWithBasehead(branches, logger) {
|
||||
const repositoryNwo = getRepositoryNwoFromEnv(
|
||||
"CODE_SCANNING_REPOSITORY",
|
||||
@@ -151891,6 +151924,25 @@ function userConfigFromActionPath(tempDir) {
|
||||
function hasQueryCustomisation(userConfig) {
|
||||
return isDefined2(userConfig["disable-default-queries"]) || isDefined2(userConfig.queries) || isDefined2(userConfig["query-filters"]);
|
||||
}
|
||||
async function applyIncrementalAnalysisSettings(config, hasDiffRanges, codeql, logger) {
|
||||
if (config.overlayDatabaseMode === "overlay" /* Overlay */ && !hasDiffRanges) {
|
||||
logger.info(
|
||||
`Reverting overlay database mode to ${"none" /* None */} because the PR diff ranges could not be computed.`
|
||||
);
|
||||
config.overlayDatabaseMode = "none" /* None */;
|
||||
config.useOverlayDatabaseCaching = false;
|
||||
await addOverlayDisablementDiagnostics(
|
||||
config,
|
||||
codeql,
|
||||
"diff-informed-analysis-not-enabled" /* DiffInformedAnalysisNotEnabled */
|
||||
);
|
||||
}
|
||||
if (hasDiffRanges) {
|
||||
config.extraQueryExclusions.push({
|
||||
exclude: { tags: "exclude-from-incremental" }
|
||||
});
|
||||
}
|
||||
}
|
||||
async function initConfig(features, inputs) {
|
||||
const { logger, tempDir } = inputs;
|
||||
if (inputs.configInput) {
|
||||
@@ -152000,15 +152052,17 @@ async function initConfig(features, inputs) {
|
||||
overlayDisabledReason
|
||||
);
|
||||
}
|
||||
if (config.overlayDatabaseMode === "overlay" /* Overlay */ || await shouldPerformDiffInformedAnalysis(
|
||||
const hasDiffRanges = await prepareDiffInformedAnalysis(
|
||||
inputs.codeql,
|
||||
inputs.features,
|
||||
logger
|
||||
)) {
|
||||
config.extraQueryExclusions.push({
|
||||
exclude: { tags: "exclude-from-incremental" }
|
||||
});
|
||||
}
|
||||
);
|
||||
await applyIncrementalAnalysisSettings(
|
||||
config,
|
||||
hasDiffRanges,
|
||||
inputs.codeql,
|
||||
logger
|
||||
);
|
||||
if (await isTrapCachingEnabled(features, config.overlayDatabaseMode)) {
|
||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||
inputs.codeql,
|
||||
@@ -159063,7 +159117,6 @@ async function run3(startedAt) {
|
||||
logFileCoverageOnPrsDeprecationWarning(logger);
|
||||
}
|
||||
await checkInstallPython311(config.languages, codeql);
|
||||
await computeAndPersistDiffRanges(codeql, features, logger);
|
||||
} catch (unwrappedError) {
|
||||
const error3 = wrapError(unwrappedError);
|
||||
core21.setFailed(error3.message);
|
||||
@@ -159336,33 +159389,6 @@ async function loadRepositoryProperties(repositoryNwo, logger) {
|
||||
return new Failure(error3);
|
||||
}
|
||||
}
|
||||
async function computeAndPersistDiffRanges(codeql, features, logger) {
|
||||
await withGroupAsync("Computing PR diff ranges", async () => {
|
||||
try {
|
||||
const branches = await getDiffInformedAnalysisBranches(
|
||||
codeql,
|
||||
features,
|
||||
logger
|
||||
);
|
||||
if (!branches) {
|
||||
return;
|
||||
}
|
||||
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
||||
if (ranges === void 0) {
|
||||
return;
|
||||
}
|
||||
writeDiffRangesJsonFile(logger, ranges);
|
||||
const distinctFiles = new Set(ranges.map((r) => r.path)).size;
|
||||
logger.info(
|
||||
`Persisted ${ranges.length} diff range(s) across ${distinctFiles} file(s).`
|
||||
);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute and persist PR diff ranges: ${getErrorMessage(e)}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
async function recordZstdAvailability(config, zstdAvailability) {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user