Add support for feature flagging via the GitHub API

This commit is contained in:
Henry Mercer 2021-12-14 19:50:52 +00:00
parent e1f05902cd
commit 04671efa1d
12 changed files with 590 additions and 66 deletions

View file

@ -2,6 +2,7 @@ import { TestInterface } from "ava";
import * as sinon from "sinon";
import * as CodeQL from "./codeql";
import { Logger } from "./logging";
type TestContext = {
stdoutWrite: any;
@ -89,3 +90,32 @@ export function setupActionsVars(tempDir: string, toolsDir: string) {
process.env["RUNNER_TEMP"] = tempDir;
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
}
export interface LoggedMessage {
type: "debug" | "info" | "warning" | "error";
message: string | Error;
}
export function getRecordingLogger(messages: LoggedMessage[]): Logger {
return {
debug: (message: string) => {
messages.push({ type: "debug", message });
console.debug(message);
},
info: (message: string) => {
messages.push({ type: "info", message });
console.info(message);
},
warning: (message: string | Error) => {
messages.push({ type: "warning", message });
console.warn(message);
},
error: (message: string | Error) => {
messages.push({ type: "error", message });
console.error(message);
},
isDebug: () => true,
startGroup: () => undefined,
endGroup: () => undefined,
};
}