Skip to content

Commit

Permalink
Reduce the number of runs needed to merge a successful pull request
Browse files Browse the repository at this point in the history
Basically, we can skip the TESTED state entirely. We can also check the
next pull request at the same time.

Fixes graydon#35.
  • Loading branch information
barosl committed Dec 15, 2014
1 parent 416f6cc commit 8a40722
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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']))
Expand All @@ -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)
Expand All @@ -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())
Expand Down Expand Up @@ -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:"
Expand All @@ -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():
Expand All @@ -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"),
Expand Down Expand Up @@ -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)



Expand Down

0 comments on commit 8a40722

Please sign in to comment.