Skip to content

Commit b996b9d

Browse files
author
bors-servo
authored
Auto merge of #133 - aidanhs:aphs-logging, r=manishearth
More logging in debug mode This is probably excessively verbose (the `{!r}` prints out a lot of irrelevant info), but it's an improvement on the extreme lack at the moment. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/homu/133) <!-- Reviewable:end -->
2 parents f34e399 + 9679cd3 commit b996b9d

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

homu/main.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import functools
77
from . import utils
8+
from .utils import lazy_debug
89
import logging
910
from threading import Thread, Lock
1011
import time
@@ -370,7 +371,7 @@ def verify_auth(username, repo_cfg, state, auth, realtime, my_username):
370371
else:
371372
reply += 'Not in reviewers'
372373
elif auth == AuthState.TRY:
373-
reply += 'and not in try users'
374+
reply += 'not in try users'
374375
state.add_comment(reply)
375376
return False
376377

@@ -745,11 +746,16 @@ def branch_equal_to_merge(git_cmd, state, branch):
745746
return utils.silent_call(git_cmd('diff', '--quiet', 'FETCH_HEAD', branch)) == 0 # noqa
746747

747748

748-
def create_merge(state, repo_cfg, branch, git_cfg, ensure_merge_equal=False):
749+
def create_merge(state, repo_cfg, branch, logger, git_cfg,
750+
ensure_merge_equal=False):
749751
base_sha = state.get_repo().ref('heads/' + state.base_ref).object.sha
750752

751753
state.refresh()
752754

755+
lazy_debug(logger,
756+
lambda: "create_merge: attempting merge {} into {} on {!r}"
757+
.format(state.head_sha, branch, state.get_repo()))
758+
753759
merge_msg = 'Auto merge of #{} - {}, r={}\n\n{}\n\n{}'.format(
754760
state.num,
755761
state.head_ref,
@@ -920,13 +926,15 @@ def get_github_merge_sha(state, repo_cfg, git_cfg):
920926
return subprocess.check_output(git_cmd('rev-parse', 'FETCH_HEAD')).decode('ascii').strip() # noqa
921927

922928

923-
def do_exemption_merge(state, repo_cfg, git_cfg, url, check_merge, reason):
929+
def do_exemption_merge(state, logger, repo_cfg, git_cfg, url, check_merge,
930+
reason):
924931

925932
try:
926933
merge_sha = create_merge(
927934
state,
928935
repo_cfg,
929936
state.base_ref,
937+
logger,
930938
git_cfg,
931939
check_merge)
932940
except subprocess.CalledProcessError:
@@ -951,7 +959,7 @@ def do_exemption_merge(state, repo_cfg, git_cfg, url, check_merge, reason):
951959
return True
952960

953961

954-
def try_travis_exemption(state, repo_cfg, git_cfg):
962+
def try_travis_exemption(state, logger, repo_cfg, git_cfg):
955963

956964
travis_info = None
957965
for info in utils.github_iter_statuses(state.get_repo(), state.head_sha):
@@ -986,14 +994,14 @@ def try_travis_exemption(state, repo_cfg, git_cfg):
986994
if (travis_commit.parents[0]['sha'] == base_sha and
987995
travis_commit.parents[1]['sha'] == state.head_sha):
988996
# make sure we check against the github merge sha before pushing
989-
return do_exemption_merge(state, repo_cfg, git_cfg,
997+
return do_exemption_merge(state, logger, repo_cfg, git_cfg,
990998
travis_info.target_url, True,
991999
"merge already tested by Travis CI")
9921000

9931001
return False
9941002

9951003

996-
def try_status_exemption(state, repo_cfg, git_cfg):
1004+
def try_status_exemption(state, logger, repo_cfg, git_cfg):
9971005

9981006
# If all the builders are status-based, then we can do some checks to
9991007
# exempt testing under the following cases:
@@ -1032,7 +1040,7 @@ def try_status_exemption(state, repo_cfg, git_cfg):
10321040
# is the PR fully rebased?
10331041
base_sha = state.get_repo().ref('heads/' + state.base_ref).object.sha
10341042
if pull_is_rebased(state, repo_cfg, git_cfg, base_sha):
1035-
return do_exemption_merge(state, repo_cfg, git_cfg, '', False,
1043+
return do_exemption_merge(state, logger, repo_cfg, git_cfg, '', False,
10361044
"pull fully rebased and already tested")
10371045

10381046
# check if we can use the github merge sha as proof
@@ -1050,7 +1058,7 @@ def try_status_exemption(state, repo_cfg, git_cfg):
10501058
merge_commit.parents[0]['sha'] == base_sha and
10511059
merge_commit.parents[1]['sha'] == state.head_sha):
10521060
# make sure we check against the github merge sha before pushing
1053-
return do_exemption_merge(state, repo_cfg, git_cfg, '', True,
1061+
return do_exemption_merge(state, logger, repo_cfg, git_cfg, '', True,
10541062
"merge already tested")
10551063

10561064
return False
@@ -1060,6 +1068,8 @@ def start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
10601068
if buildbot_slots[0]:
10611069
return True
10621070

1071+
lazy_debug(logger, lambda: "start_build on {!r}".format(state.get_repo()))
1072+
10631073
assert state.head_sha == state.get_repo().pull_request(state.num).head.sha
10641074

10651075
repo_cfg = repo_cfgs[state.repo_label]
@@ -1100,15 +1110,18 @@ def start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
11001110
if len(builders) is 0:
11011111
raise RuntimeError('Invalid configuration')
11021112

1113+
lazy_debug(logger, lambda: "start_build: builders={!r}".format(builders))
1114+
11031115
if (only_status_builders and state.approved_by and
11041116
repo_cfg.get('status_based_exemption', False)):
11051117
if can_try_travis_exemption:
1106-
if try_travis_exemption(state, repo_cfg, git_cfg):
1118+
if try_travis_exemption(state, logger, repo_cfg, git_cfg):
11071119
return True
1108-
if try_status_exemption(state, repo_cfg, git_cfg):
1120+
if try_status_exemption(state, logger, repo_cfg, git_cfg):
11091121
return True
11101122

1111-
merge_sha = create_merge(state, repo_cfg, branch, git_cfg)
1123+
merge_sha = create_merge(state, repo_cfg, branch, logger, git_cfg)
1124+
lazy_debug(logger, lambda: "start_build: merge_sha={}".format(merge_sha))
11121125
if not merge_sha:
11131126
return False
11141127

@@ -1238,6 +1251,8 @@ def process_queue(states, repos, repo_cfgs, logger, buildbot_slots, db,
12381251
repo_states = sorted(states[repo_label].values())
12391252

12401253
for state in repo_states:
1254+
lazy_debug(logger, lambda: "process_queue: state={!r}, building {}"
1255+
.format(state, repo_label))
12411256
if state.priority < repo.treeclosed:
12421257
continue
12431258
if state.status == 'pending' and not state.try_:

0 commit comments

Comments
 (0)