From d1de567da3f3337716f86f8c9d5cd88fd287e96d Mon Sep 17 00:00:00 2001 From: Fries Date: Wed, 19 Oct 2022 18:11:08 -0700 Subject: [PATCH 1/3] add pycharm stuff --- .idea/.gitignore | 3 +++ .idea/inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/rfc-bot.iml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 37 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rfc-bot.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4a7bea9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e9f32b6 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rfc-bot.iml b/.idea/rfc-bot.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/rfc-bot.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 24dfd8915a0f5a43a2d9dd6f43a76cabfdea8848 Mon Sep 17 00:00:00 2001 From: Fries Date: Wed, 19 Oct 2022 19:25:31 -0700 Subject: [PATCH 2/3] bot: add trusted contrib support and improved code i formatted some of the code to make it a bit better and i added trusted contributor support to the bot so it checks trusted contributors as well as the core team. --- bot.py | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/bot.py b/bot.py index 97d43d9..655240a 100644 --- a/bot.py +++ b/bot.py @@ -1,13 +1,19 @@ from github import Github -import datetime -import sys +from datetime import datetime g = Github(open(".access_token").read().strip()) + def post_update(text): repo = g.get_repo("crystalrfc-bot/status") thread = repo.get_issue(1) - thread.create_comment(text + "\nBeep Boop! (I'm a bot, and this action was performed automagically.)\nScan timestamp: `" + datetime.datetime.now().isoformat() + "`") + thread.create_comment( + text + + "\nBeep Boop! (I'm a bot, and this action was performed automagically.)\nScan timestamp: `" + + datetime.now().isoformat() + + "`" + ) + targets = ['crystal-linux/.github', 'crystal-linux-packages/.github'] @@ -18,11 +24,17 @@ for tgt in targets: status_text += f"# Examining {repo.full_name}\n" core_team = g.get_organization('crystal-linux').get_team_by_slug('core-team') + trusted_contrib = g.get_organization('crystal-linux').get_team_by_slug('trusted-contribututors') core_team_members = core_team.get_members() - core_team_logins = [] + trusted_contrib_members = trusted_contrib.get_members() + + crystal_logins = [] for member in core_team_members: - core_team_logins.append(member.login) + crystal_logins.append(member.login) + + for member in trusted_contrib_members: + crystal_logins.append(member.login) rfcs_passed = 0 for issue in repo.get_issues(): @@ -33,18 +45,22 @@ for tgt in targets: total_votes_for = 0 total_votes_against = 0 for reaction in all_reactions: - if reaction.user.login in core_team_logins: - #print(f"- {reaction.content}: by {reaction.user.login}") + if reaction.user.login in crystal_logins: + # print(f"- {reaction.content}: by {reaction.user.login}") if reaction.content == "+1": total_votes_for += 1 elif reaction.content == "-1": total_votes_against += 1 print(f"Total votes for resolution: {str(total_votes_for)}") print(f"Total votes against resolution: {str(total_votes_against)}") - if (total_votes_for/len(core_team_logins)) > 0.5: + if (total_votes_for / len(crystal_logins)) > 0.5: print("This RFC should be passed. Adding comment.") if not issue.locked: - issue.create_comment("This resolution has enough votes from Core Team mebers to be considered passed. Please close the issue once appropriate actions have been taken. - Beep Boop (I'm a bot, and this action was performed automagically)") + issue.create_comment( + "This resolution has enough votes to be considered passed. " + "Please close the issue once appropriate actions have been taken. " + "- Beep Boop (I'm a bot, and this action was performed automagically)" + ) issue.lock("resolved") rfcs_passed += 1 status_text += f"* Suggested that {issue.title} be acted upon, as it has passed.\n" From 90191a25766b45516e118edf0f46f308e8ae6dd5 Mon Sep 17 00:00:00 2001 From: Fries Date: Wed, 19 Oct 2022 18:22:23 -0700 Subject: [PATCH 3/3] run black linter --- bot.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/bot.py b/bot.py index 655240a..f6b3fcb 100644 --- a/bot.py +++ b/bot.py @@ -8,14 +8,14 @@ def post_update(text): repo = g.get_repo("crystalrfc-bot/status") thread = repo.get_issue(1) thread.create_comment( - text + - "\nBeep Boop! (I'm a bot, and this action was performed automagically.)\nScan timestamp: `" + - datetime.now().isoformat() + - "`" + text + + "\nBeep Boop! (I'm a bot, and this action was performed automagically.)\nScan timestamp: `" + + datetime.now().isoformat() + + "`" ) -targets = ['crystal-linux/.github', 'crystal-linux-packages/.github'] +targets = ["crystal-linux/.github", "crystal-linux-packages/.github"] status_text = "" @@ -23,8 +23,10 @@ for tgt in targets: repo = g.get_repo(tgt) status_text += f"# Examining {repo.full_name}\n" - core_team = g.get_organization('crystal-linux').get_team_by_slug('core-team') - trusted_contrib = g.get_organization('crystal-linux').get_team_by_slug('trusted-contribututors') + core_team = g.get_organization("crystal-linux").get_team_by_slug("core-team") + trusted_contrib = g.get_organization("crystal-linux").get_team_by_slug( + "trusted-contribututors" + ) core_team_members = core_team.get_members() trusted_contrib_members = trusted_contrib.get_members() @@ -38,7 +40,7 @@ for tgt in targets: rfcs_passed = 0 for issue in repo.get_issues(): - if 'RFC' in issue.title: + if "RFC" in issue.title: print(f"Working on: {issue.title}") all_reactions = issue.get_reactions() if all_reactions.totalCount != 0: