Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need more chaos #48

Merged
merged 2 commits into from
May 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 18 additions & 32 deletions chaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def install_requirements():

if __name__ == "__main__":
logging.info("starting up and entering event loop")

os.system("pkill chaos_server")
subprocess.Popen([sys.executable, "server.py"], cwd=join(THIS_DIR, "server"))

log.info("starting http server")
start_http_server()

while True:
log.info("looking for PRs")

Expand All @@ -87,35 +87,21 @@ def install_requirements():
pr_num = pr["number"]
logging.info("processing PR #%d", pr_num)

votes = gh.voting.get_votes(api, settings.URN, pr)

# is our PR approved or rejected?
vote_total = gh.voting.get_vote_sum(api, votes)
threshold = gh.voting.get_approval_threshold(api, settings.URN)
is_approved = vote_total >= threshold

if is_approved:
log.info("PR %d approved for merging!", pr_num)
try:
gh.prs.merge_pr(api, settings.URN, pr, votes, vote_total,
threshold)
# some error, like suddenly there's a merge conflict, or some
# new commits were introduced between findint this ready pr and
# merging it
except gh_exc.CouldntMerge:
log.info("couldn't merge PR %d for some reason, skipping",
pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["can't merge"])
continue

gh.prs.label_pr(api, settings.URN, pr_num, ["accepted"])
needs_update = True

else:
log.info("PR %d rejected, closing", pr_num)
gh.comments.leave_reject_comment(api, settings.URN, pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["rejected"])
gh.prs.close_pr(api, settings.URN, pr)
log.info("PR %d approved for merging!", pr_num)
try:
gh.prs.merge_pr(api, settings.URN, pr, votes, vote_total,
threshold)
# some error, like suddenly there's a merge conflict, or some
# new commits were introduced between findint this ready pr and
# merging it
except gh_exc.CouldntMerge:
log.info("couldn't merge PR %d for some reason, skipping",
pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["can't merge"])
continue

gh.prs.label_pr(api, settings.URN, pr_num, ["accepted"])
needs_update = True


# we approved a PR, restart
Expand Down