Remove CLI version lookup based on release assets
This is now superseded by semantically versioned bundles
This commit is contained in:
parent
48c11ed2ba
commit
0407820509
6 changed files with 10 additions and 158 deletions
|
|
@ -18,7 +18,7 @@ import * as defaults from "./defaults.json";
|
|||
import { CodeQLDefaultVersionInfo } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
import * as util from "./util";
|
||||
import { isGoodVersion, wrapError } from "./util";
|
||||
import { isGoodVersion } from "./util";
|
||||
|
||||
export enum ToolsSource {
|
||||
Unknown = "UNKNOWN",
|
||||
|
|
@ -59,54 +59,6 @@ export function getCodeQLActionRepository(logger: Logger): string {
|
|||
return util.getRequiredEnvParam("GITHUB_ACTION_REPOSITORY");
|
||||
}
|
||||
|
||||
function tryGetCodeQLCliVersionForRelease(
|
||||
release,
|
||||
logger: Logger,
|
||||
): string | undefined {
|
||||
const cliVersionsFromMarkerFiles = (release.assets as Array<{ name: string }>)
|
||||
.map((asset) => asset.name.match(/cli-version-(.*)\.txt/)?.[1])
|
||||
.filter((v) => v)
|
||||
.map((v) => v as string);
|
||||
if (cliVersionsFromMarkerFiles.length > 1) {
|
||||
logger.warning(
|
||||
`Ignoring release ${release.tag_name} with multiple CLI version marker files.`,
|
||||
);
|
||||
return undefined;
|
||||
} else if (cliVersionsFromMarkerFiles.length === 0) {
|
||||
logger.debug(
|
||||
`Failed to find the CodeQL CLI version for release ${release.tag_name}.`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
return cliVersionsFromMarkerFiles[0];
|
||||
}
|
||||
|
||||
export async function tryFindCliVersionDotcomOnly(
|
||||
tagName: string,
|
||||
logger: Logger,
|
||||
): Promise<string | undefined> {
|
||||
try {
|
||||
logger.debug(
|
||||
`Fetching the GitHub Release for the CodeQL bundle tagged ${tagName}.`,
|
||||
);
|
||||
const apiClient = api.getApiClient();
|
||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
||||
const release = await apiClient.rest.repos.getReleaseByTag({
|
||||
owner: codeQLActionRepository.split("/")[0],
|
||||
repo: codeQLActionRepository.split("/")[1],
|
||||
tag: tagName,
|
||||
});
|
||||
return tryGetCodeQLCliVersionForRelease(release.data, logger);
|
||||
} catch (e) {
|
||||
logger.debug(
|
||||
`Failed to find the CLI version for the CodeQL bundle tagged ${tagName}. ${
|
||||
wrapError(e).message
|
||||
}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function getCodeQLBundleDownloadURL(
|
||||
tagName: string,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
|
|
@ -516,7 +468,6 @@ export const downloadCodeQL = async function (
|
|||
maybeBundleVersion: string | undefined,
|
||||
maybeCliVersion: string | undefined,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
variant: util.GitHubVariant,
|
||||
tempDir: string,
|
||||
logger: Logger,
|
||||
): Promise<{
|
||||
|
|
@ -594,18 +545,6 @@ export const downloadCodeQL = async function (
|
|||
};
|
||||
}
|
||||
|
||||
// Try to compute the CLI version for this bundle
|
||||
if (
|
||||
maybeCliVersion === undefined &&
|
||||
variant === util.GitHubVariant.DOTCOM &&
|
||||
codeqlURL.includes(`/${CODEQL_DEFAULT_ACTION_REPOSITORY}/`)
|
||||
) {
|
||||
maybeCliVersion = await tryFindCliVersionDotcomOnly(
|
||||
`codeql-bundle-${bundleVersion}`,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
logger.debug("Caching CodeQL bundle.");
|
||||
const toolcacheVersion = getCanonicalToolcacheVersion(
|
||||
maybeCliVersion,
|
||||
|
|
@ -725,7 +664,6 @@ export async function setupCodeQLBundle(
|
|||
source.bundleVersion,
|
||||
source.cliVersion,
|
||||
apiDetails,
|
||||
variant,
|
||||
tempDir,
|
||||
logger,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue