Rename forceLatest to forceShippedTools

This commit is contained in:
Henry Mercer 2023-02-06 11:57:48 +00:00
parent f140af5e28
commit d49282c3b5
3 changed files with 26 additions and 16 deletions

18
lib/setup-codeql.js generated
View file

@ -285,7 +285,8 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
toolsVersion: "local", toolsVersion: "local",
}; };
} }
const forceLatestReason = /** The reason why the tools shipped with the Action have been forced. */
const forceShippedToolsReason =
// We use the special value of 'latest' to prioritize the version in the // We use the special value of 'latest' to prioritize the version in the
// defaults over any pinned cached version. // defaults over any pinned cached version.
toolsInput === "latest" toolsInput === "latest"
@ -297,9 +298,11 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
toolsInput === undefined && bypassToolcache toolsInput === undefined && bypassToolcache
? "a specific version of the CodeQL tools was not requested and the bypass toolcache feature is enabled" ? "a specific version of the CodeQL tools was not requested and the bypass toolcache feature is enabled"
: undefined; : undefined;
const forceLatest = forceLatestReason !== undefined; /** Whether the tools shipped with the Action, i.e. those in `defaults.json`, have been forced. */
if (forceLatest) { const forceShippedTools = forceShippedToolsReason !== undefined;
logger.debug(`Forcing the latest version of the CodeQL tools since ${forceLatestReason}.`); if (forceShippedTools) {
logger.info("Overriding the version of the CodeQL tools by the version shipped with the Action since " +
`${forceShippedToolsReason}.`);
} }
/** CLI version number, for example 2.12.1. */ /** CLI version number, for example 2.12.1. */
let cliVersion; let cliVersion;
@ -311,8 +314,7 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
* This does not always include a tag name. * This does not always include a tag name.
*/ */
let url; let url;
if (forceLatest) { if (forceShippedTools) {
// When forceLatest is true, the requested version is the one shipped with the Action in `defaults.json`.
cliVersion = defaults.cliVersion; cliVersion = defaults.cliVersion;
tagName = defaults.bundleVersion; tagName = defaults.bundleVersion;
} }
@ -393,7 +395,9 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
// If we don't find the requested version on Enterprise, we may allow a // If we don't find the requested version on Enterprise, we may allow a
// different version to save download time if the version hasn't been // different version to save download time if the version hasn't been
// specified explicitly (in which case we always honor it). // specified explicitly (in which case we always honor it).
if (variant !== util.GitHubVariant.DOTCOM && !forceLatest && !toolsInput) { if (variant !== util.GitHubVariant.DOTCOM &&
!forceShippedTools &&
!toolsInput) {
const result = await findOverridingToolsInCache(humanReadableVersion, logger); const result = await findOverridingToolsInCache(humanReadableVersion, logger);
if (result !== undefined) { if (result !== undefined) {
return result; return result;

File diff suppressed because one or more lines are too long

View file

@ -368,7 +368,8 @@ export async function getCodeQLSource(
}; };
} }
const forceLatestReason = /** The reason why the tools shipped with the Action have been forced. */
const forceShippedToolsReason =
// We use the special value of 'latest' to prioritize the version in the // We use the special value of 'latest' to prioritize the version in the
// defaults over any pinned cached version. // defaults over any pinned cached version.
toolsInput === "latest" toolsInput === "latest"
@ -380,10 +381,12 @@ export async function getCodeQLSource(
toolsInput === undefined && bypassToolcache toolsInput === undefined && bypassToolcache
? "a specific version of the CodeQL tools was not requested and the bypass toolcache feature is enabled" ? "a specific version of the CodeQL tools was not requested and the bypass toolcache feature is enabled"
: undefined; : undefined;
const forceLatest = forceLatestReason !== undefined; /** Whether the tools shipped with the Action, i.e. those in `defaults.json`, have been forced. */
if (forceLatest) { const forceShippedTools = forceShippedToolsReason !== undefined;
logger.debug( if (forceShippedTools) {
`Forcing the latest version of the CodeQL tools since ${forceLatestReason}.` logger.info(
"Overriding the version of the CodeQL tools by the version shipped with the Action since " +
`${forceShippedToolsReason}.`
); );
} }
@ -398,8 +401,7 @@ export async function getCodeQLSource(
*/ */
let url: string | undefined; let url: string | undefined;
if (forceLatest) { if (forceShippedTools) {
// When forceLatest is true, the requested version is the one shipped with the Action in `defaults.json`.
cliVersion = defaults.cliVersion; cliVersion = defaults.cliVersion;
tagName = defaults.bundleVersion; tagName = defaults.bundleVersion;
} else if (toolsInput !== undefined) { } else if (toolsInput !== undefined) {
@ -512,7 +514,11 @@ export async function getCodeQLSource(
// If we don't find the requested version on Enterprise, we may allow a // If we don't find the requested version on Enterprise, we may allow a
// different version to save download time if the version hasn't been // different version to save download time if the version hasn't been
// specified explicitly (in which case we always honor it). // specified explicitly (in which case we always honor it).
if (variant !== util.GitHubVariant.DOTCOM && !forceLatest && !toolsInput) { if (
variant !== util.GitHubVariant.DOTCOM &&
!forceShippedTools &&
!toolsInput
) {
const result = await findOverridingToolsInCache( const result = await findOverridingToolsInCache(
humanReadableVersion, humanReadableVersion,
logger logger