Use the CLI version when caching the bundle in telemetry too
This commit is contained in:
parent
33206d299e
commit
0be20e5ce1
6 changed files with 36 additions and 16 deletions
2
lib/codeql.test.js
generated
2
lib/codeql.test.js
generated
|
|
@ -187,7 +187,7 @@ function mockApiDetails(apiDetails) {
|
||||||
const result = await codeql.setupCodeQL(url, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
const result = await codeql.setupCodeQL(url, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
||||||
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
|
||||||
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
|
t.deepEqual(result.toolsVersion, "2.10.0");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
for (const { isCached, tagName, toolcacheCliVersion } of [
|
for (const { isCached, tagName, toolcacheCliVersion } of [
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
18
lib/setup-codeql.js
generated
18
lib/setup-codeql.js
generated
|
|
@ -427,13 +427,17 @@ async function downloadCodeQL(codeqlURL, maybeCliVersion, apiDetails, variant, t
|
||||||
// Try to compute the CLI version for this bundle
|
// Try to compute the CLI version for this bundle
|
||||||
const cliVersion = maybeCliVersion ||
|
const cliVersion = maybeCliVersion ||
|
||||||
(variant === util.GitHubVariant.DOTCOM &&
|
(variant === util.GitHubVariant.DOTCOM &&
|
||||||
(await tryFindCliVersionDotcomOnly(`codeql-bundle-${bundleVersion}`, logger)));
|
(await tryFindCliVersionDotcomOnly(`codeql-bundle-${bundleVersion}`, logger))) ||
|
||||||
|
undefined;
|
||||||
// Include the bundle version in the toolcache version number so that if the user requests the
|
// Include the bundle version in the toolcache version number so that if the user requests the
|
||||||
// same URL again, we can get it from the cache without having to call any of the Releases API.
|
// same URL again, we can get it from the cache without having to call any of the Releases API.
|
||||||
const toolcacheVersion = cliVersion
|
const toolcacheVersion = cliVersion
|
||||||
? `${cliVersion}-${bundleVersion}`
|
? `${cliVersion}-${bundleVersion}`
|
||||||
: convertToSemVer(bundleVersion, logger);
|
: convertToSemVer(bundleVersion, logger);
|
||||||
return await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion);
|
return {
|
||||||
|
toolsVersion: cliVersion || toolcacheVersion,
|
||||||
|
codeqlFolder: await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
exports.downloadCodeQL = downloadCodeQL;
|
exports.downloadCodeQL = downloadCodeQL;
|
||||||
function getCodeQLURLVersion(url) {
|
function getCodeQLURLVersion(url) {
|
||||||
|
|
@ -461,6 +465,7 @@ exports.getCodeQLURLVersion = getCodeQLURLVersion;
|
||||||
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger) {
|
async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypassToolcache, defaultCliVersion, logger) {
|
||||||
const source = await getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, apiDetails, variant, logger);
|
const source = await getCodeQLSource(toolsInput, bypassToolcache, defaultCliVersion, apiDetails, variant, logger);
|
||||||
let codeqlFolder;
|
let codeqlFolder;
|
||||||
|
let toolsVersion = source.toolsVersion;
|
||||||
switch (source.sourceType) {
|
switch (source.sourceType) {
|
||||||
case "local":
|
case "local":
|
||||||
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
||||||
|
|
@ -469,13 +474,16 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, bypas
|
||||||
codeqlFolder = source.codeqlFolder;
|
codeqlFolder = source.codeqlFolder;
|
||||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||||
break;
|
break;
|
||||||
case "download":
|
case "download": {
|
||||||
codeqlFolder = await downloadCodeQL(source.codeqlURL, source.cliVersion, apiDetails, variant, tempDir, logger);
|
const result = await downloadCodeQL(source.codeqlURL, source.cliVersion, apiDetails, variant, tempDir, logger);
|
||||||
|
toolsVersion = result.toolsVersion;
|
||||||
|
codeqlFolder = result.codeqlFolder;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
util.assertNever(source);
|
util.assertNever(source);
|
||||||
}
|
}
|
||||||
return { codeqlFolder, toolsVersion: source.toolsVersion };
|
return { codeqlFolder, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.setupCodeQLBundle = setupCodeQLBundle;
|
exports.setupCodeQLBundle = setupCodeQLBundle;
|
||||||
//# sourceMappingURL=setup-codeql.js.map
|
//# sourceMappingURL=setup-codeql.js.map
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -266,7 +266,7 @@ test("tries to cache an explicitly requested bundle with its CLI version number"
|
||||||
);
|
);
|
||||||
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
t.assert(releaseApiMock.isDone(), "Releases API should have been called");
|
||||||
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "2.10.0-20200610"));
|
||||||
t.deepEqual(result.toolsVersion, "0.0.0-20200610");
|
t.deepEqual(result.toolsVersion, "2.10.0");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -526,7 +526,7 @@ export async function downloadCodeQL(
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<string> {
|
): Promise<{ toolsVersion: string; codeqlFolder: string }> {
|
||||||
const parsedCodeQLURL = new URL(codeqlURL);
|
const parsedCodeQLURL = new URL(codeqlURL);
|
||||||
const searchParams = new URLSearchParams(parsedCodeQLURL.search);
|
const searchParams = new URLSearchParams(parsedCodeQLURL.search);
|
||||||
const headers: OutgoingHttpHeaders = {
|
const headers: OutgoingHttpHeaders = {
|
||||||
|
|
@ -565,19 +565,27 @@ export async function downloadCodeQL(
|
||||||
|
|
||||||
const bundleVersion = getBundleVersionFromUrl(codeqlURL);
|
const bundleVersion = getBundleVersionFromUrl(codeqlURL);
|
||||||
// Try to compute the CLI version for this bundle
|
// Try to compute the CLI version for this bundle
|
||||||
const cliVersion =
|
const cliVersion: string | undefined =
|
||||||
maybeCliVersion ||
|
maybeCliVersion ||
|
||||||
(variant === util.GitHubVariant.DOTCOM &&
|
(variant === util.GitHubVariant.DOTCOM &&
|
||||||
(await tryFindCliVersionDotcomOnly(
|
(await tryFindCliVersionDotcomOnly(
|
||||||
`codeql-bundle-${bundleVersion}`,
|
`codeql-bundle-${bundleVersion}`,
|
||||||
logger
|
logger
|
||||||
)));
|
))) ||
|
||||||
|
undefined;
|
||||||
// Include the bundle version in the toolcache version number so that if the user requests the
|
// Include the bundle version in the toolcache version number so that if the user requests the
|
||||||
// same URL again, we can get it from the cache without having to call any of the Releases API.
|
// same URL again, we can get it from the cache without having to call any of the Releases API.
|
||||||
const toolcacheVersion = cliVersion
|
const toolcacheVersion = cliVersion
|
||||||
? `${cliVersion}-${bundleVersion}`
|
? `${cliVersion}-${bundleVersion}`
|
||||||
: convertToSemVer(bundleVersion, logger);
|
: convertToSemVer(bundleVersion, logger);
|
||||||
return await toolcache.cacheDir(codeqlExtracted, "CodeQL", toolcacheVersion);
|
return {
|
||||||
|
toolsVersion: cliVersion || toolcacheVersion,
|
||||||
|
codeqlFolder: await toolcache.cacheDir(
|
||||||
|
codeqlExtracted,
|
||||||
|
"CodeQL",
|
||||||
|
toolcacheVersion
|
||||||
|
),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCodeQLURLVersion(url: string): string {
|
export function getCodeQLURLVersion(url: string): string {
|
||||||
|
|
@ -623,6 +631,7 @@ export async function setupCodeQLBundle(
|
||||||
);
|
);
|
||||||
|
|
||||||
let codeqlFolder: string;
|
let codeqlFolder: string;
|
||||||
|
let toolsVersion = source.toolsVersion;
|
||||||
switch (source.sourceType) {
|
switch (source.sourceType) {
|
||||||
case "local":
|
case "local":
|
||||||
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
codeqlFolder = await toolcache.extractTar(source.codeqlTarPath);
|
||||||
|
|
@ -631,8 +640,8 @@ export async function setupCodeQLBundle(
|
||||||
codeqlFolder = source.codeqlFolder;
|
codeqlFolder = source.codeqlFolder;
|
||||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||||
break;
|
break;
|
||||||
case "download":
|
case "download": {
|
||||||
codeqlFolder = await downloadCodeQL(
|
const result = await downloadCodeQL(
|
||||||
source.codeqlURL,
|
source.codeqlURL,
|
||||||
source.cliVersion,
|
source.cliVersion,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
|
|
@ -640,9 +649,12 @@ export async function setupCodeQLBundle(
|
||||||
tempDir,
|
tempDir,
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
|
toolsVersion = result.toolsVersion;
|
||||||
|
codeqlFolder = result.codeqlFolder;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
util.assertNever(source);
|
util.assertNever(source);
|
||||||
}
|
}
|
||||||
return { codeqlFolder, toolsVersion: source.toolsVersion };
|
return { codeqlFolder, toolsVersion };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue