Skip to content

Commit

Permalink
move to env
Browse files Browse the repository at this point in the history
  • Loading branch information
mordamax committed Aug 11, 2023
1 parent e2aae8b commit 4de4563
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.example.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ process.env.CMD_BOT_URL ??= "http://localhost:3000/"
process.env.MIN_LOG_LEVEL ??= "debug"

process.env.BOT_PR_COMMENT_MENTION ??= "localbot"

process.env.PROCESSBOT_SUPPORTED_REPOS: "substrate,polkadot,cumulus"
1 change: 1 addition & 0 deletions .env.unit-tests.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ process.env.ALLOWED_ORGANIZATIONS ??= "123,456"
process.env.MASTER_TOKEN ??= "placeholder"
process.env.TASK_DB_VERSION ??= "123"
process.env.CMD_BOT_URL ??= "http://localhost:3000/"
process.env.PROCESSBOT_SUPPORTED_REPOS: "substrate,polkadot,cumulus"
1 change: 1 addition & 0 deletions helm/values-parity-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ common:
CMD_BOT_URL: https://command-bot.parity-prod.parity.io/
BOT_PR_COMMENT_MENTION: bot
PIPELINE_SCRIPTS_REF: main
PROCESSBOT_SUPPORTED_REPOS: "substrate,polkadot,cumulus"
secrets:
ALLOWED_ORGANIZATIONS: ref+vault://kv/gitlab/parity/mirrors/command-bot/devops-parity-prod#ALLOWED_ORGANIZATIONS
APP_ID: ref+vault://kv/gitlab/parity/mirrors/command-bot/devops-parity-prod#APP_ID
Expand Down
1 change: 1 addition & 0 deletions helm/values-parity-stg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ common:
CMD_BOT_URL: https://command-bot.parity-stg.parity.io/
PIPELINE_SCRIPTS_REF: main
BOT_PR_COMMENT_MENTION: bot
PROCESSBOT_SUPPORTED_REPOS: "substrate,polkadot,cumulus"
secrets:
ALLOWED_ORGANIZATIONS: ref+vault://kv/gitlab/parity/mirrors/command-bot/devops-parity-stg#ALLOWED_ORGANIZATIONS
APP_ID: ref+vault://kv/gitlab/parity/mirrors/command-bot/devops-parity-stg#APP_ID
Expand Down
1 change: 0 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Context } from "src/types";

// just do nothing, completely skip
export const botPullRequestIgnoreCommands = ["merge", "rebase"];
export const processBotSupportedRepos = ["substrate", "polkadot", "cumulus"];
export const botPullRequestCommentSubcommands: {
[Subcommand in "cancel"]: Subcommand;
} = { cancel: "cancel" };
Expand Down
4 changes: 2 additions & 2 deletions src/commander/commander.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, CommanderError, InvalidArgumentError, Option, OptionValues } from "commander";

import { botPullRequestIgnoreCommands, processBotSupportedRepos } from "src/bot";
import { botPullRequestIgnoreCommands } from "src/bot";
import { CancelCommand, CleanCommand, GenericCommand, HelpCommand, ParsedCommand } from "src/bot/parse/ParsedCommand";
import { SkipEvent } from "src/bot/types";
import { CommandConfigs } from "src/command-configs/types";
Expand Down Expand Up @@ -32,7 +32,7 @@ export function getCommanderFromConfiguration(
commandConfigs: CommandConfigs,
repo: string,
): ExtendedCommander {
const { botPullRequestCommentMention } = config;
const { botPullRequestCommentMention, processBotSupportedRepos } = config;
const root = new Command(botPullRequestCommentMention) as ExtendedCommander;
let unknownCommand: string | undefined;
let parsedCommand: ParseResults["parsedCommand"] = undefined;
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const allowedOrganizations = envVar("ALLOWED_ORGANIZATIONS")
return parsedValue;
});

const processBotSupportedRepos = envVar("PROCESSBOT_SUPPORTED_REPOS")
.split(",")
.map((repo) => repo.trim())
.filter((value) => value.length !== 0);

export type Config = {
dataPath: string;
pipelineScripts: PipelineScripts;
Expand Down Expand Up @@ -58,6 +63,7 @@ export type Config = {
gitlabJobImage: string;
cmdBotUrl: string;
botPullRequestCommentMention: string;
processBotSupportedRepos: string[];
};

export const config: Config = {
Expand Down Expand Up @@ -87,4 +93,5 @@ export const config: Config = {
gitlabJobImage: envVar("GITLAB_JOB_IMAGE"),
cmdBotUrl: envVar("CMD_BOT_URL"),
botPullRequestCommentMention: process.env.BOT_PR_COMMENT_MENTION || "bot",
processBotSupportedRepos,
};
2 changes: 2 additions & 0 deletions src/test/setup/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ function getBotEnv(
MIN_LOG_LEVEL: "debug",

BOT_PR_COMMENT_MENTION: "testbot",

PROCESSBOT_SUPPORTED_REPOS: "substrate,polkadot,cumulus",
};
}

0 comments on commit 4de4563

Please sign in to comment.