Fix computation of fallback version
This commit is contained in:
parent
0a9e9db27f
commit
75ae065ae6
3 changed files with 29 additions and 9 deletions
15
lib/setup-codeql.js
generated
15
lib/setup-codeql.js
generated
|
|
@ -211,12 +211,19 @@ async function getCodeQLBundleDownloadURL(tagName, apiDetails, variant, logger)
|
||||||
}
|
}
|
||||||
return `https://github.com/${exports.CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`;
|
return `https://github.com/${exports.CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
|
function getBundleVersionFromTagName(tagName) {
|
||||||
|
const match = tagName.match(/^codeql-bundle-(.*)$/);
|
||||||
|
if (match === null || match.length < 2) {
|
||||||
|
throw new Error(`Malformed bundle tag name: ${tagName}. Bundle version could not be inferred`);
|
||||||
|
}
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
function getBundleVersionFromUrl(url) {
|
function getBundleVersionFromUrl(url) {
|
||||||
const match = url.match(/\/codeql-bundle-(.*)\//);
|
const match = url.match(/\/(codeql-bundle-.*)\//);
|
||||||
if (match === null || match.length < 2) {
|
if (match === null || match.length < 2) {
|
||||||
throw new Error(`Malformed tools url: ${url}. Bundle version could not be inferred`);
|
throw new Error(`Malformed tools url: ${url}. Bundle version could not be inferred`);
|
||||||
}
|
}
|
||||||
return match[1];
|
return getBundleVersionFromTagName(match[1]);
|
||||||
}
|
}
|
||||||
exports.getBundleVersionFromUrl = getBundleVersionFromUrl;
|
exports.getBundleVersionFromUrl = getBundleVersionFromUrl;
|
||||||
function convertToSemVer(version, logger) {
|
function convertToSemVer(version, logger) {
|
||||||
|
|
@ -349,14 +356,14 @@ async function getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, a
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!codeqlFolder && requestedVersion.cliVersion) {
|
if (!codeqlFolder && requestedVersion.cliVersion) {
|
||||||
// Fall back to accepting a `0.0.0-<tagName>` version if we didn't find the
|
// Fall back to accepting a `0.0.0-<bundleVersion>` version if we didn't find the
|
||||||
// `x.y.z` version. This is to support old versions of the toolcache.
|
// `x.y.z` version. This is to support old versions of the toolcache.
|
||||||
//
|
//
|
||||||
// If we are on Dotcom, we will make an HTTP request to the Releases API here
|
// If we are on Dotcom, we will make an HTTP request to the Releases API here
|
||||||
// to find the tag name for the requested version.
|
// to find the tag name for the requested version.
|
||||||
tagName =
|
tagName =
|
||||||
tagName || (await getOrFindBundleTagName(requestedVersion, logger));
|
tagName || (await getOrFindBundleTagName(requestedVersion, logger));
|
||||||
const fallbackVersion = convertToSemVer(tagName, logger);
|
const fallbackVersion = convertToSemVer(getBundleVersionFromTagName(tagName), logger);
|
||||||
logger.debug(`Computed a fallback toolcache version number of ${fallbackVersion} for CodeQL tools version ` +
|
logger.debug(`Computed a fallback toolcache version number of ${fallbackVersion} for CodeQL tools version ` +
|
||||||
`${requestedVersion.cliVersion}.`);
|
`${requestedVersion.cliVersion}.`);
|
||||||
codeqlFolder = toolcache.find("CodeQL", fallbackVersion);
|
codeqlFolder = toolcache.find("CodeQL", fallbackVersion);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -241,14 +241,24 @@ async function getCodeQLBundleDownloadURL(
|
||||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`;
|
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${tagName}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBundleVersionFromTagName(tagName: string): string {
|
||||||
|
const match = tagName.match(/^codeql-bundle-(.*)$/);
|
||||||
|
if (match === null || match.length < 2) {
|
||||||
|
throw new Error(
|
||||||
|
`Malformed bundle tag name: ${tagName}. Bundle version could not be inferred`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
|
|
||||||
export function getBundleVersionFromUrl(url: string): string {
|
export function getBundleVersionFromUrl(url: string): string {
|
||||||
const match = url.match(/\/codeql-bundle-(.*)\//);
|
const match = url.match(/\/(codeql-bundle-.*)\//);
|
||||||
if (match === null || match.length < 2) {
|
if (match === null || match.length < 2) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Malformed tools url: ${url}. Bundle version could not be inferred`
|
`Malformed tools url: ${url}. Bundle version could not be inferred`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return match[1];
|
return getBundleVersionFromTagName(match[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function convertToSemVer(version: string, logger: Logger): string {
|
export function convertToSemVer(version: string, logger: Logger): string {
|
||||||
|
|
@ -448,14 +458,17 @@ export async function getCodeQLSource(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!codeqlFolder && requestedVersion.cliVersion) {
|
if (!codeqlFolder && requestedVersion.cliVersion) {
|
||||||
// Fall back to accepting a `0.0.0-<tagName>` version if we didn't find the
|
// Fall back to accepting a `0.0.0-<bundleVersion>` version if we didn't find the
|
||||||
// `x.y.z` version. This is to support old versions of the toolcache.
|
// `x.y.z` version. This is to support old versions of the toolcache.
|
||||||
//
|
//
|
||||||
// If we are on Dotcom, we will make an HTTP request to the Releases API here
|
// If we are on Dotcom, we will make an HTTP request to the Releases API here
|
||||||
// to find the tag name for the requested version.
|
// to find the tag name for the requested version.
|
||||||
tagName =
|
tagName =
|
||||||
tagName || (await getOrFindBundleTagName(requestedVersion, logger));
|
tagName || (await getOrFindBundleTagName(requestedVersion, logger));
|
||||||
const fallbackVersion = convertToSemVer(tagName, logger);
|
const fallbackVersion = convertToSemVer(
|
||||||
|
getBundleVersionFromTagName(tagName),
|
||||||
|
logger
|
||||||
|
);
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Computed a fallback toolcache version number of ${fallbackVersion} for CodeQL tools version ` +
|
`Computed a fallback toolcache version number of ${fallbackVersion} for CodeQL tools version ` +
|
||||||
`${requestedVersion.cliVersion}.`
|
`${requestedVersion.cliVersion}.`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue