Skip to content

Commit cff15d7

Browse files
committed
Add logging for CodeQL CLI Version and add tests to the logger for it.
1 parent cbe408d commit cff15d7

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

lib/setup-codeql.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql.test.js

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-codeql.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getRunnerLogger } from "./logging";
88
import * as setupCodeql from "./setup-codeql";
99
import {
1010
LINKED_CLI_VERSION,
11+
LoggedMessage,
1112
SAMPLE_DEFAULT_CLI_VERSION,
1213
SAMPLE_DOTCOM_API_DETAILS,
1314
getRecordingLogger,
@@ -97,7 +98,7 @@ test("getCodeQLSource sets CLI version for a semver tagged bundle", async (t) =>
9798
});
9899

99100
test("getCodeQLSource correctly returns bundled CLI version when tools == linked", async (t) => {
100-
const loggedMessages = [];
101+
const loggedMessages: LoggedMessage[] = [];
101102
const logger = getRecordingLogger(loggedMessages);
102103

103104
await withTmpDir(async (tmpDir) => {
@@ -110,8 +111,22 @@ test("getCodeQLSource correctly returns bundled CLI version when tools == linked
110111
logger,
111112
);
112113

114+
// Assert first that we got the right version of the CodeQL CLI,
115+
// and that we're sourcing it using the correct method for that.
113116
t.is(source.toolsVersion, LINKED_CLI_VERSION.cliVersion);
114117
t.is(source.sourceType, "download");
118+
119+
// Ensure that we're adequately notifying the user of the version we're using.
120+
const expected_message: LoggedMessage = {
121+
type: "info",
122+
message: `Using CodeQL CLI version: ${LINKED_CLI_VERSION.cliVersion} from download.`,
123+
};
124+
125+
loggedMessages.forEach((msg) => {
126+
console.log(msg.message);
127+
});
128+
129+
t.assert(loggedMessages.includes(expected_message));
115130
});
116131
});
117132

src/setup-codeql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ export async function setupCodeQLBundle(
692692
logger,
693693
);
694694

695+
logger.info("Using CodeQL CLI version " + source.toolsVersion + " from " + source.sourceType + ".");
696+
695697
let codeqlFolder: string;
696698
let toolsVersion = source.toolsVersion;
697699
let toolsDownloadDurationMs: number | undefined;

0 commit comments

Comments
 (0)