mirror of
https://github.com/github/codeql-action.git
synced 2026-11-09 06:29:52 +00:00
Persist repository root from init action in CodeQL Action state
This commit is contained in:
43
lib/entry-points.js
generated
43
lib/entry-points.js
generated
@@ -150444,7 +150444,7 @@ async function initActionState({
|
||||
analysisKinds,
|
||||
logger,
|
||||
enableFileCoverageInformation
|
||||
}, userConfig) {
|
||||
}, userConfig, repositoryRoot) {
|
||||
const languages = await getLanguages(
|
||||
codeql,
|
||||
languagesInput,
|
||||
@@ -150480,6 +150480,7 @@ async function initActionState({
|
||||
);
|
||||
return {
|
||||
version: getActionVersion(),
|
||||
repositoryRoot,
|
||||
analysisKinds,
|
||||
languages,
|
||||
buildMode,
|
||||
@@ -150630,7 +150631,7 @@ async function checkRunnerResources(codeql, features, diskUsage, ramInput, logge
|
||||
}
|
||||
return new Success(void 0);
|
||||
}
|
||||
async function checkOverlayEnablement(codeql, features, languages, sourceRoot, buildMode, ramInput, codeScanningConfig, repositoryProperties, gitVersion, logger) {
|
||||
async function checkOverlayEnablement(codeql, features, languages, repositoryRoot, sourceRoot, buildMode, ramInput, codeScanningConfig, repositoryProperties, gitVersion, logger) {
|
||||
const modeEnv = process.env.CODEQL_OVERLAY_DATABASE_MODE;
|
||||
if (modeEnv === "overlay" /* Overlay */ || modeEnv === "overlay-base" /* OverlayBase */ || modeEnv === "none" /* None */) {
|
||||
logger.info(
|
||||
@@ -150645,6 +150646,7 @@ async function checkOverlayEnablement(codeql, features, languages, sourceRoot, b
|
||||
true,
|
||||
codeql,
|
||||
languages,
|
||||
repositoryRoot,
|
||||
sourceRoot,
|
||||
buildMode,
|
||||
gitVersion,
|
||||
@@ -150717,13 +150719,14 @@ async function checkOverlayEnablement(codeql, features, languages, sourceRoot, b
|
||||
false,
|
||||
codeql,
|
||||
languages,
|
||||
repositoryRoot,
|
||||
sourceRoot,
|
||||
buildMode,
|
||||
gitVersion,
|
||||
logger
|
||||
);
|
||||
}
|
||||
async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDatabaseCaching, overlayModeSetExplicitly, codeql, languages, sourceRoot, buildMode, gitVersion, logger) {
|
||||
async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDatabaseCaching, overlayModeSetExplicitly, codeql, languages, repositoryRoot, sourceRoot, buildMode, gitVersion, logger) {
|
||||
if (buildMode !== "none" /* None */ && (await Promise.all(
|
||||
languages.map(
|
||||
async (l) => l !== "go" /* go */ && // Workaround to allow overlay analysis for Go with any build
|
||||
@@ -150744,14 +150747,13 @@ async function validateOverlayDatabaseMode(overlayDatabaseMode, useOverlayDataba
|
||||
);
|
||||
return new Failure("incompatible-codeql" /* IncompatibleCodeQl */);
|
||||
}
|
||||
const gitRoot = await getGitRoot(sourceRoot);
|
||||
if (gitRoot === void 0) {
|
||||
if (repositoryRoot === 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 new Failure("no-git-root" /* NoGitRoot */);
|
||||
}
|
||||
if (hasSubmodules(gitRoot)) {
|
||||
if (hasSubmodules(repositoryRoot)) {
|
||||
if (gitVersion === void 0) {
|
||||
logger.warning(
|
||||
`Cannot build an ${overlayDatabaseMode} database because the repository has submodules and the Git version could not be determined. Falling back to creating a normal full database instead.`
|
||||
@@ -150886,8 +150888,9 @@ async function determineUserConfig(action, tempDir, inputs) {
|
||||
async function initConfig(actionState, inputs) {
|
||||
const { logger, features } = actionState;
|
||||
const { tempDir } = inputs;
|
||||
const repositoryRoot = await getGitRoot(inputs.sourceRoot);
|
||||
const userConfig = await determineUserConfig(actionState, tempDir, inputs);
|
||||
const config = await initActionState(inputs, userConfig);
|
||||
const config = await initActionState(inputs, userConfig, repositoryRoot);
|
||||
if (config.analysisKinds.length === 1 && isCodeQualityEnabled(config)) {
|
||||
if (hasQueryCustomisation(config.computedConfig)) {
|
||||
throw new ConfigurationError(
|
||||
@@ -150940,6 +150943,7 @@ async function initConfig(actionState, inputs) {
|
||||
inputs.codeql,
|
||||
inputs.features,
|
||||
config.languages,
|
||||
repositoryRoot,
|
||||
inputs.sourceRoot,
|
||||
config.buildMode,
|
||||
inputs.ramInput,
|
||||
@@ -153801,8 +153805,27 @@ var CodeQLAnalysisError = class extends Error {
|
||||
message;
|
||||
error;
|
||||
};
|
||||
function determineCheckoutPath(action) {
|
||||
return action.actions.getRequiredInput("checkout_path");
|
||||
async function determineCheckoutPath(action) {
|
||||
const checkoutPathInput = action.actions.getRequiredInput("checkout_path");
|
||||
const repositoryRoot = await getGitRoot(checkoutPathInput);
|
||||
if (repositoryRoot === void 0) {
|
||||
action.logger.warning(
|
||||
[
|
||||
`The directory at '${checkoutPathInput}' is not in the work tree of a git repository.`,
|
||||
"If the repository being analyzed is checked out elsewhere,",
|
||||
"you must explicitly set the 'checkout_path' input for the 'codeql-action/analyze' step to",
|
||||
"the checkout path."
|
||||
].join(" ")
|
||||
);
|
||||
} else if (repositoryRoot !== path16.resolve(checkoutPathInput)) {
|
||||
action.logger.warning(
|
||||
[
|
||||
`The directory at '${checkoutPathInput}' is not the root of the repository ('${repositoryRoot}').`,
|
||||
"Set the 'checkout_path' input for the 'codeql-action/analyze' step to the root path of the checkout."
|
||||
].join(" ")
|
||||
);
|
||||
}
|
||||
return checkoutPathInput;
|
||||
}
|
||||
async function setupPythonExtractor(logger) {
|
||||
const codeqlPython = process.env["CODEQL_PYTHON"];
|
||||
@@ -156615,7 +156638,7 @@ async function run(action) {
|
||||
getOptionalInput("ram") || process.env["CODEQL_RAM"],
|
||||
logger
|
||||
);
|
||||
const checkoutPath = determineCheckoutPath(action);
|
||||
const checkoutPath = await determineCheckoutPath(action);
|
||||
const diffRangePackDir = await setupDiffInformedQueryRun(
|
||||
logger,
|
||||
checkoutPath
|
||||
|
||||
Reference in New Issue
Block a user