Add failing regression test
This commit is contained in:
parent
24ca6b0400
commit
0a9e9db27f
3 changed files with 81 additions and 106 deletions
70
lib/codeql.test.js
generated
70
lib/codeql.test.js
generated
|
|
@ -216,66 +216,50 @@ for (const { cliVersion, expectedToolcacheVersion, } of EXPLICITLY_REQUESTED_BUN
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (const { isCached, tagName, toolcacheCliVersion } of [
|
for (const { githubReleases, toolcacheVersion } of [
|
||||||
|
// Test that we use the tools from the toolcache when `SAMPLE_DEFAULT_CLI_VERSION` is requested
|
||||||
|
// and `SAMPLE_DEFAULT_CLI_VERSION-` is in the toolcache.
|
||||||
{
|
{
|
||||||
isCached: true,
|
toolcacheVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
|
||||||
tagName: "codeql-bundle-20230101",
|
|
||||||
toolcacheCliVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCached: true,
|
githubReleases: {
|
||||||
// By leaving toolcacheCliVersion undefined, the bundle will be installed
|
"codeql-bundle-20230101": `cli-version-${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}.txt`,
|
||||||
// into the toolcache as `${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`.
|
},
|
||||||
// This lets us test that `x.y.z-yyyymmdd` toolcache versions are used if an
|
toolcacheVersion: "0.0.0-20230101",
|
||||||
// `x.y.z` version isn't in the toolcache.
|
|
||||||
tagName: `codeql-bundle-${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCached: false,
|
toolcacheVersion: `${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
|
||||||
tagName: "codeql-bundle-20230101",
|
|
||||||
},
|
},
|
||||||
]) {
|
]) {
|
||||||
(0, ava_1.default)(`uses default version on Dotcom when default version bundle ${tagName} is ${isCached ? "" : "not "}cached`, async (t) => {
|
(0, ava_1.default)(`uses tools from toolcache when ${SAMPLE_DEFAULT_CLI_VERSION.cliVersion} is requested and ` +
|
||||||
|
`${toolcacheVersion} is installed`, async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
if (isCached) {
|
sinon
|
||||||
await installIntoToolcache({
|
.stub(toolcache, "find")
|
||||||
cliVersion: toolcacheCliVersion,
|
.withArgs("CodeQL", toolcacheVersion)
|
||||||
tagName,
|
.returns("path/to/cached/codeql");
|
||||||
isPinned: true,
|
sinon.stub(toolcache, "findAllVersions").returns([toolcacheVersion]);
|
||||||
tmpDir,
|
if (githubReleases) {
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
mockDownloadApi({
|
|
||||||
tagName,
|
|
||||||
});
|
|
||||||
sinon.stub(api, "getApiClient").value(() => ({
|
sinon.stub(api, "getApiClient").value(() => ({
|
||||||
repos: {
|
repos: {
|
||||||
listReleases: sinon.stub().resolves(undefined),
|
listReleases: sinon.stub().resolves(undefined),
|
||||||
},
|
},
|
||||||
paginate: sinon.stub().resolves([
|
paginate: sinon.stub().resolves(Object.entries(githubReleases).map(([releaseTagName, cliVersionMarkerFile]) => ({
|
||||||
{
|
assets: [
|
||||||
assets: [
|
{
|
||||||
{
|
name: cliVersionMarkerFile,
|
||||||
name: "cli-version-2.0.0.txt",
|
},
|
||||||
},
|
],
|
||||||
],
|
tag_name: releaseTagName,
|
||||||
tag_name: tagName,
|
}))),
|
||||||
},
|
|
||||||
]),
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
const result = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
const result = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, false, SAMPLE_DEFAULT_CLI_VERSION, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
||||||
if (isCached) {
|
t.is(result.toolsSource, init_1.ToolsSource.Toolcache);
|
||||||
t.is(result.toolsSource, init_1.ToolsSource.Toolcache);
|
t.is(result.toolsDownloadDurationMs, undefined);
|
||||||
t.is(result.toolsDownloadDurationMs, undefined);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
t.is(result.toolsSource, init_1.ToolsSource.Download);
|
|
||||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -298,80 +298,71 @@ for (const {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const { isCached, tagName, toolcacheCliVersion } of [
|
for (const { githubReleases, toolcacheVersion } of [
|
||||||
|
// Test that we use the tools from the toolcache when `SAMPLE_DEFAULT_CLI_VERSION` is requested
|
||||||
|
// and `SAMPLE_DEFAULT_CLI_VERSION-` is in the toolcache.
|
||||||
{
|
{
|
||||||
isCached: true,
|
toolcacheVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
|
||||||
tagName: "codeql-bundle-20230101",
|
|
||||||
toolcacheCliVersion: SAMPLE_DEFAULT_CLI_VERSION.cliVersion,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCached: true,
|
githubReleases: {
|
||||||
// By leaving toolcacheCliVersion undefined, the bundle will be installed
|
"codeql-bundle-20230101": `cli-version-${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}.txt`,
|
||||||
// into the toolcache as `${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`.
|
},
|
||||||
// This lets us test that `x.y.z-yyyymmdd` toolcache versions are used if an
|
toolcacheVersion: "0.0.0-20230101",
|
||||||
// `x.y.z` version isn't in the toolcache.
|
|
||||||
tagName: `codeql-bundle-${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
isCached: false,
|
toolcacheVersion: `${SAMPLE_DEFAULT_CLI_VERSION.cliVersion}-20230101`,
|
||||||
tagName: "codeql-bundle-20230101",
|
|
||||||
},
|
},
|
||||||
]) {
|
]) {
|
||||||
test(`uses default version on Dotcom when default version bundle ${tagName} is ${
|
test(
|
||||||
isCached ? "" : "not "
|
`uses tools from toolcache when ${SAMPLE_DEFAULT_CLI_VERSION.cliVersion} is requested and ` +
|
||||||
}cached`, async (t) => {
|
`${toolcacheVersion} is installed`,
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
async (t) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
if (isCached) {
|
sinon
|
||||||
await installIntoToolcache({
|
.stub(toolcache, "find")
|
||||||
cliVersion: toolcacheCliVersion,
|
.withArgs("CodeQL", toolcacheVersion)
|
||||||
tagName,
|
.returns("path/to/cached/codeql");
|
||||||
isPinned: true,
|
sinon.stub(toolcache, "findAllVersions").returns([toolcacheVersion]);
|
||||||
tmpDir,
|
|
||||||
});
|
if (githubReleases) {
|
||||||
} else {
|
sinon.stub(api, "getApiClient").value(() => ({
|
||||||
mockDownloadApi({
|
repos: {
|
||||||
tagName,
|
listReleases: sinon.stub().resolves(undefined),
|
||||||
});
|
|
||||||
sinon.stub(api, "getApiClient").value(() => ({
|
|
||||||
repos: {
|
|
||||||
listReleases: sinon.stub().resolves(undefined),
|
|
||||||
},
|
|
||||||
paginate: sinon.stub().resolves([
|
|
||||||
{
|
|
||||||
assets: [
|
|
||||||
{
|
|
||||||
name: "cli-version-2.0.0.txt",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
tag_name: tagName,
|
|
||||||
},
|
},
|
||||||
]),
|
paginate: sinon.stub().resolves(
|
||||||
}));
|
Object.entries(githubReleases).map(
|
||||||
}
|
([releaseTagName, cliVersionMarkerFile]) => ({
|
||||||
|
assets: [
|
||||||
|
{
|
||||||
|
name: cliVersionMarkerFile,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
tag_name: releaseTagName,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
const result = await codeql.setupCodeQL(
|
const result = await codeql.setupCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
sampleApiDetails,
|
sampleApiDetails,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
util.GitHubVariant.DOTCOM,
|
util.GitHubVariant.DOTCOM,
|
||||||
false,
|
false,
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
t.is(result.toolsVersion, SAMPLE_DEFAULT_CLI_VERSION.cliVersion);
|
||||||
|
|
||||||
if (isCached) {
|
|
||||||
t.is(result.toolsSource, ToolsSource.Toolcache);
|
t.is(result.toolsSource, ToolsSource.Toolcache);
|
||||||
t.is(result.toolsDownloadDurationMs, undefined);
|
t.is(result.toolsDownloadDurationMs, undefined);
|
||||||
} else {
|
});
|
||||||
t.is(result.toolsSource, ToolsSource.Download);
|
}
|
||||||
t.is(typeof result.toolsDownloadDurationMs, "number");
|
);
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
for (const variant of [util.GitHubVariant.GHAE, util.GitHubVariant.GHES]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue