diff --git a/lib/entry-points.js b/lib/entry-points.js index 7994d26d9..ca6dd881b 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -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 diff --git a/src/analyze-action.ts b/src/analyze-action.ts index 7c117f75a..8cc13c1ba 100644 --- a/src/analyze-action.ts +++ b/src/analyze-action.ts @@ -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( diff --git a/src/analyze.ts b/src/analyze.ts index 306ccd434..f1a1841f3 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -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;