Add option tools: linked for init action.

Also ensure that option latest remains compatible, and add tests for
the two options.
This commit is contained in:
Fotis Koutoulakis (@NlightNFotis) 2024-05-08 15:52:42 +01:00 committed by Fotis Koutoulakis
parent bf2faab135
commit cbe408dfc9
9 changed files with 101 additions and 12 deletions

View file

@ -7,8 +7,10 @@ import * as actionsUtil from "./actions-util";
import { getRunnerLogger } from "./logging";
import * as setupCodeql from "./setup-codeql";
import {
LINKED_CLI_VERSION,
SAMPLE_DEFAULT_CLI_VERSION,
SAMPLE_DOTCOM_API_DETAILS,
getRecordingLogger,
mockBundleDownloadApi,
setupActionsVars,
setupTests,
@ -93,3 +95,41 @@ test("getCodeQLSource sets CLI version for a semver tagged bundle", async (t) =>
t.is(source["cliVersion"], "1.2.3");
});
});
test("getCodeQLSource correctly returns bundled CLI version when tools == linked", async (t) => {
const loggedMessages = [];
const logger = getRecordingLogger(loggedMessages);
await withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir);
const source = await setupCodeql.getCodeQLSource(
"linked",
SAMPLE_DEFAULT_CLI_VERSION,
SAMPLE_DOTCOM_API_DETAILS,
GitHubVariant.DOTCOM,
logger,
);
t.is(source.toolsVersion, LINKED_CLI_VERSION.cliVersion);
t.is(source.sourceType, "download");
});
});
test("getCodeQLSource correctly returns bundled CLI version when tools == latest", async (t) => {
const loggedMessages = [];
const logger = getRecordingLogger(loggedMessages);
await withTmpDir(async (tmpDir) => {
setupActionsVars(tmpDir, tmpDir);
const source = await setupCodeql.getCodeQLSource(
"latest",
SAMPLE_DEFAULT_CLI_VERSION,
SAMPLE_DOTCOM_API_DETAILS,
GitHubVariant.DOTCOM,
logger,
);
t.is(source.toolsVersion, LINKED_CLI_VERSION.cliVersion);
t.is(source.sourceType, "download");
});
});