Merge pull request #1 from fries1234/main

add trusted contributor support
main
Matt C 2 years ago committed by GitHub
commit ac9676b78c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (rfc-bot)" project-jdk-type="Python SDK" />
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/rfc-bot.iml" filepath="$PROJECT_DIR$/.idea/rfc-bot.iml" />
</modules>
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -1,15 +1,21 @@
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']
targets = ["crystal-linux/.github", "crystal-linux-packages/.github"]
status_text = ""
@ -17,23 +23,31 @@ 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')
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():
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:
total_votes_for = 0
total_votes_against = 0
for reaction in all_reactions:
if reaction.user.login in core_team_logins:
if reaction.user.login in crystal_logins:
# print(f"- {reaction.content}: by {reaction.user.login}")
if reaction.content == "+1":
total_votes_for += 1
@ -41,10 +55,14 @@ for tgt in targets:
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"

Loading…
Cancel
Save