mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Verify persisted repository root path in analyze action
This commit is contained in:
13
lib/entry-points.js
generated
13
lib/entry-points.js
generated
@@ -153805,7 +153805,7 @@ var CodeQLAnalysisError = class extends Error {
|
||||
message;
|
||||
error;
|
||||
};
|
||||
async function determineCheckoutPath(action) {
|
||||
async function determineCheckoutPath(action, config) {
|
||||
const checkoutPathInput = action.actions.getRequiredInput("checkout_path");
|
||||
const repositoryRoot = await getGitRoot(checkoutPathInput);
|
||||
if (repositoryRoot === void 0) {
|
||||
@@ -153824,6 +153824,15 @@ async function determineCheckoutPath(action) {
|
||||
"Set the 'checkout_path' input for the 'codeql-action/analyze' step to the root path of the checkout."
|
||||
].join(" ")
|
||||
);
|
||||
} else if (config.repositoryRoot !== void 0 && repositoryRoot !== config.repositoryRoot) {
|
||||
action.logger.warning(
|
||||
[
|
||||
`The repository path at '${repositoryRoot}' does not match that found by the 'codeql-action/init' step: '${config.repositoryRoot}'.`,
|
||||
"Ensure that the 'checkout_path' input for the 'codeql-action/analyze' step is set to the path of the same repository that",
|
||||
"the 'codeql-action/init' step determined. This is either the GitHub Actions workspace or the repository root corresponding to",
|
||||
"the 'source-root' input if that was provided."
|
||||
].join(" ")
|
||||
);
|
||||
}
|
||||
return checkoutPathInput;
|
||||
}
|
||||
@@ -156638,7 +156647,7 @@ async function run(action) {
|
||||
getOptionalInput("ram") || process.env["CODEQL_RAM"],
|
||||
logger
|
||||
);
|
||||
const checkoutPath = await determineCheckoutPath(action);
|
||||
const checkoutPath = await determineCheckoutPath(action, config);
|
||||
const diffRangePackDir = await setupDiffInformedQueryRun(
|
||||
logger,
|
||||
checkoutPath
|
||||
|
||||
@@ -310,7 +310,7 @@ async function run(action: ActionState<["Base", "Logger", "Env", "Actions"]>) {
|
||||
logger,
|
||||
);
|
||||
|
||||
const checkoutPath = await determineCheckoutPath(action);
|
||||
const checkoutPath = await determineCheckoutPath(action, config);
|
||||
|
||||
// Setup diff informed analysis if needed (based on whether init created the file)
|
||||
const diffRangePackDir = await setupDiffInformedQueryRun(
|
||||
|
||||
@@ -93,9 +93,11 @@ export interface QueriesStatusReport
|
||||
* refers to the root of a repository.
|
||||
*
|
||||
* @param action The action state.
|
||||
* @param config The CodeQL Action configuration state.
|
||||
*/
|
||||
export async function determineCheckoutPath(
|
||||
action: ActionState<["Logger", "Actions"]>,
|
||||
config: configUtils.Config,
|
||||
) {
|
||||
const checkoutPathInput = action.actions.getRequiredInput("checkout_path");
|
||||
|
||||
@@ -118,6 +120,19 @@ export async function determineCheckoutPath(
|
||||
"Set the 'checkout_path' input for the 'codeql-action/analyze' step to the root path of the checkout.",
|
||||
].join(" "),
|
||||
);
|
||||
} else if (
|
||||
config.repositoryRoot !== undefined &&
|
||||
repositoryRoot !== config.repositoryRoot
|
||||
) {
|
||||
// The repository root that was persisted by the `init` step doesn't match the one we have found here.
|
||||
action.logger.warning(
|
||||
[
|
||||
`The repository path at '${repositoryRoot}' does not match that found by the 'codeql-action/init' step: '${config.repositoryRoot}'.`,
|
||||
"Ensure that the 'checkout_path' input for the 'codeql-action/analyze' step is set to the path of the same repository that",
|
||||
"the 'codeql-action/init' step determined. This is either the GitHub Actions workspace or the repository root corresponding to",
|
||||
"the 'source-root' input if that was provided.",
|
||||
].join(" "),
|
||||
);
|
||||
}
|
||||
|
||||
return checkoutPathInput;
|
||||
|
||||
Reference in New Issue
Block a user