Skip to content

Commit

Permalink
Merge pull request #99 from olehermanse/master
Browse files Browse the repository at this point in the history
Fixed Tom's config for libntech in new org
  • Loading branch information
olehermanse authored Feb 15, 2024
2 parents 4db0e85 + 4d2028e commit b4daac8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 21 deletions.
47 changes: 37 additions & 10 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"bots": [
{
"orgs": ["cfengine"],
"username": "cf-bottom",
"secrets": "cfengine-secrets.json",
"trusted": [
"trusted_gh_users_to_start_jenkins_builds": [
"nickanderson",
"mineralsfree",
"vpodzime",
Expand All @@ -16,11 +17,11 @@
"larsewi"
],
"reviewers": ["larsewi", "craigcomstock"],
"jenkins": "https://ci.cfengine.com/",
"jenkins_url": "https://ci.cfengine.com/",
"jenkins_job": "pr-pipeline",
"bot_features": [
"check_commit_emails",
"ping_reviewers",
"ping_reviewer_for_new_pr_after_1_day",
"trigger_jenkins_from_gh_comments",
"approve_prs",
"report_open_prs",
Expand All @@ -37,7 +38,6 @@
"ole": "94534ae37a66ade3bae446c81cc15433efcda3a8516ffe6b2c2e0f6dd70127dd",
"ole1": "23d337c7f69fee4a04dca86de41cf737a0c585029864eab34aa1a5390aa7b845"
},
"orgs": ["cfengine"],
"jenkins_repos": [
"libntech",
"core",
Expand All @@ -49,7 +49,7 @@
"documentation",
"system-testing"
],
"repos": {
"repo_maintainers": {
"cfengine/core": ["larsewi", "craigcomstock"],
"cfengine/enterprise": ["larsewi", "craigcomstock"],
"cfengine/nova": ["larsewi", "craigcomstock"],
Expand All @@ -63,31 +63,58 @@
}
},
{
"orgs": ["mendersoftware"],
"username": "mender-test-bot",
"secrets": "mender-secrets.json",
"orgs": ["mendersoftware"],
"bot_features": [
"report_open_prs"
]
},
{
"username": "cf-bottom",
"orgs": ["NorthernTechHQ"],
"secrets": "nt-secrets.json",
"username": "cf-bottom",
"secrets": "cfengine-secrets.json",
"reviewers": ["olehermanse", "oldgiova", "alfrunes"],
"bot_features": [
"report_open_prs",
"check_commit_emails",
"ping_reviewers_dependabot"
"trigger_jenkins_from_gh_comments",
"ping_reviewer_dependabot"
],
"trusted_gh_users_to_start_jenkins_builds": [
"nickanderson",
"mineralsfree",
"vpodzime",
"craigcomstock",
"olehermanse",
"aleksandrychev",
"chiachenglu",
"oleorhagen",
"lluiscampos",
"larsewi"
],
"jenkins_repos": [
"libntech",
"core",
"enterprise",
"nova",
"masterfiles",
"mission-portal",
"buildscripts",
"documentation",
"system-testing"
],
"jenkins_url": "https://ci.cfengine.com/",
"jenkins_job": "pr-pipeline",
"banned_emails": {
"craig": "5a09cedd03ac8f6625afbf82320d9182ab56e507311f43d02aace8f5fe6d93f5",
"igor": "56d20f3d01cf0c08db466fb629187ff41a30bb170623251b7e14e32c3c1a67a4",
"vratislav": "54a458f06da35064562b258e52f5b233dbbd561a51816097b7bce1a306775d05",
"ole": "94534ae37a66ade3bae446c81cc15433efcda3a8516ffe6b2c2e0f6dd70127dd",
"ole1": "23d337c7f69fee4a04dca86de41cf737a0c585029864eab34aa1a5390aa7b845"
},
"repos": {
"repo_maintainers": {
"NorthernTechHQ/libntech": ["larsewi", "craigcomstock"],
"NorthernTechHQ/alvaldi-docs": ["olehermanse"],
"NorthernTechHQ/nt-connect": ["olehermanse", "alfrunes"]
},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ def test_slow_docs_build():
config = {
"response_choices": ["Predictably"],
"username": bot_username,
"jenkins": jenkins_base_url,
"jenkins_url": jenkins_base_url,
"jenkins_job": jenkins_default_job,
"trusted": [trusted_author],
"trusted_gh_users_to_start_jenkins_builds": [trusted_author],
"secrets_data": {
"GITHUB_TOKEN": test_github_token,
"JENKINS_USER": test_jenkins_user,
Expand Down
20 changes: 11 additions & 9 deletions tom/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@ def __init__(self, config, secrets, directory, interactive, reports):

self.username = config["username"]
self.orgs = config.get("orgs", [])
self.repo_maintainers = config.get("repos", {})
self.repo_maintainers = config.get("repo_maintainers", {})
self.repo_dependabot_maintainers = config.get("repo_dependabot_maintainers", {})
self.default_maintainers = config.get("reviewers", [])
self.trusted = config.get("trusted", [])
self.trusted_gh_users_to_start_jenkins_builds = config.get(
"trusted_gh_users_to_start_jenkins_builds", []
)

self.jenkins_repos = config.get("jenkins_repos", [])
banned_emails = config.get("banned_emails", {})
self.banned_emails = [v for v in banned_emails.values()]

self.jenkins = None
if "jenkins" in config:
if "jenkins_url" in config:
self.jenkins = Jenkins(
config["jenkins"], config["jenkins_job"], secrets, self.username
config["jenkins_url"], config["jenkins_job"], secrets, self.username
)

self.github = GitHub(secrets["GITHUB_TOKEN"], self.username, self.jenkins_repos)
Expand Down Expand Up @@ -273,7 +275,7 @@ def handle_mention(self, pr, comment):
deny = "@{} : I'm sorry, I cannot do that. @olehermanse please help.".format(
comment.author
)
if comment.author not in self.trusted:
if comment.author not in self.trusted_gh_users_to_start_jenkins_builds:
print("Denying mention from {}".format(comment.author))
self.comment(pr, deny)
return
Expand Down Expand Up @@ -322,13 +324,13 @@ def handle_pr(self, pr):
log.info("Looking at: {} ({})".format(pr["title"], pr["html_url"]))

pr = PR(pr, self.github)
if "ping_reviewers" in self.bot_features:
if "ping_reviewer_for_new_pr_after_1_day" in self.bot_features:
self.find_reviewers(pr)
if "ping_reviewers_dependabot" in self.bot_features:
if "ping_reviewer_dependabot" in self.bot_features:
self.assign_dependabot_maintainer(pr)
if (
"ping_reviewers" in self.bot_features
or "ping_reviewers_dependabot" in self.bot_features
"ping_reviewer_for_new_pr_after_1_day" in self.bot_features
or "ping_reviewer_dependabot" in self.bot_features
):
self.ping_reviewer(pr)
if (
Expand Down

0 comments on commit b4daac8

Please sign in to comment.