From de73487a6f08d40519a4dfa0ef1f9ac69ec86f3b Mon Sep 17 00:00:00 2001 From: Barosl Lee Date: Mon, 15 Dec 2014 09:52:36 +0900 Subject: [PATCH] Reduce the number of runs needed to merge a successful pull request Basically, we can skip the TESTED state entirely. We can also check the next pull request at the same time. Fixes #35. --- bors.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/bors.py b/bors.py index f791775..e16c597 100755 --- a/bors.py +++ b/bors.py @@ -563,6 +563,8 @@ def merge_or_batch(self, pulls): self.merge_pull_head_to_test_ref() def advance_master_ref_to_test(self, pulls): + ret = False + if self.batched(): num2sha = {x.num: x.sha for x in pulls} @@ -578,7 +580,7 @@ def advance_master_ref_to_test(self, pulls): if advanced: self.statuses = [x for x in self.statuses if x not in ['success', 'pending']] # Mark this PR as unsuccessful self.merge_or_batch(pulls) - return + return ret s = ("fast-forwarding %s to %s = %.8s" % (self.master_ref, self.test_ref, self.metadata['merge_sha'])) @@ -587,6 +589,8 @@ def advance_master_ref_to_test(self, pulls): self.dst().git().refs().heads(self.master_ref).patch(sha=self.metadata['merge_sha'], force=False) self.add_comment(self.sha, s) + + ret = True except github.ApiError: s = s + " failed" self.log.info(s) @@ -600,9 +604,9 @@ def advance_master_ref_to_test(self, pulls): self.log.info("closing failed; auto-closed after merge?") pass + return ret - - def try_advance(self, pulls): + def try_advance(self, pulls, cfg): s = self.current_state() self.log.info("considering %s", self.desc()) @@ -638,6 +642,8 @@ def try_advance(self, pulls): self.add_comment(self.sha, c) self.set_success("all tests passed") + s = STATE_TESTED + elif t == False: self.log.info("%s - tests failed, marking failure", self.short()) c = "some tests failed:" @@ -652,11 +658,11 @@ def try_advance(self, pulls): else: self.log.info("%s - no info yet, waiting on tests", self.short()) - elif s == STATE_TESTED: + if s == STATE_TESTED: self.parse_metadata() self.log.info("%s - tests successful, attempting landing", self.short()) - self.advance_master_ref_to_test(pulls) - + if self.advance_master_ref_to_test(pulls): + run(cfg) def main(): @@ -682,6 +688,9 @@ def main(): logging.info("loading bors.cfg") cfg = json.load(open("bors.cfg")) + run(cfg) + +def run(cfg): gh = None if "gh_pass" in cfg: gh = github.GitHub(username=cfg["gh_user"].encode("utf8"), @@ -763,7 +772,7 @@ def main(): else: p = pulls[-1] logging.info("working with most-ripe pull %s", p.short()) - p.try_advance(list(reversed(pulls))) + p.try_advance(list(reversed(pulls)), cfg)