@@ -374,6 +374,20 @@ async function resolveDefaultCliVersion(
374374 * Determines where the CodeQL CLI we want to use comes from. This can be from a local file,
375375 * the Actions toolcache, or a download.
376376 *
377+ * We handle the `tools` input in this order:
378+ *
379+ * - A local path is extracted without using the toolcache.
380+ * - `nightly` or `nightly-latest`, or the `force_nightly` feature flag in a dynamic workflow,
381+ * selects a bundle from the latest nightly release. We then continue with that bundle's URL.
382+ * - `linked`, or its old name `latest`, selects the version shipped with the Action.
383+ * - `toolcache` selects the latest version in the toolcache, falling back to the default version
384+ * outside dynamic workflows or if there isn't one.
385+ * - Any other value is the URL of a bundle.
386+ * - Without a `tools` input, we use the default version.
387+ *
388+ * Apart from a local path, we look for the resolved version in the toolcache before downloading. A
389+ * cached version takes precedence even if the job could use a per-language bundle.
390+ *
377391 * @param toolsInput The argument provided for the `tools` input, if any.
378392 * @param defaultCliVersion The default CLI version that's linked to the CodeQL Action.
379393 * @param rawLanguages Raw set of languages.
@@ -556,7 +570,9 @@ export async function getCodeQLSource(
556570 tagName = version . tagName ;
557571 }
558572 } else if ( toolsInput !== undefined ) {
559- // If a tools URL was provided, then use that.
573+ // Any other value is a bundle URL, including one we selected from the latest nightly above.
574+ // We use the version in its tag, if any, for the toolcache, so we assume that bundles with the
575+ // same version are the same build, whichever repository they're in.
560576 tagName = tryGetTagNameFromUrl ( toolsInput , logger ) ;
561577 url = toolsInput ;
562578
@@ -763,6 +779,8 @@ export async function getCodeQLSource(
763779 }
764780 compressionMethod = method ;
765781
782+ // Keep the bundle we selected from the latest nightly, which records the combined bundle to
783+ // fall back to. Otherwise, classify the explicit URL, which gets no fallback.
766784 bundle ??= getCodeQLBundleFromUrl ( url ) ;
767785 if ( bundle . kind === "per-language" ) {
768786 logger . info (
0 commit comments