5
5
import re
6
6
import functools
7
7
from . import utils
8
+ from .utils import lazy_debug
8
9
import logging
9
10
from threading import Thread , Lock
10
11
import time
@@ -370,7 +371,7 @@ def verify_auth(username, repo_cfg, state, auth, realtime, my_username):
370
371
else :
371
372
reply += 'Not in reviewers'
372
373
elif auth == AuthState .TRY :
373
- reply += 'and not in try users'
374
+ reply += 'not in try users'
374
375
state .add_comment (reply )
375
376
return False
376
377
@@ -745,11 +746,16 @@ def branch_equal_to_merge(git_cmd, state, branch):
745
746
return utils .silent_call (git_cmd ('diff' , '--quiet' , 'FETCH_HEAD' , branch )) == 0 # noqa
746
747
747
748
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 ):
749
751
base_sha = state .get_repo ().ref ('heads/' + state .base_ref ).object .sha
750
752
751
753
state .refresh ()
752
754
755
+ lazy_debug (logger ,
756
+ lambda : "create_merge: attempting merge {} into {} on {!r}"
757
+ .format (state .head_sha , branch , state .get_repo ()))
758
+
753
759
merge_msg = 'Auto merge of #{} - {}, r={}\n \n {}\n \n {}' .format (
754
760
state .num ,
755
761
state .head_ref ,
@@ -920,13 +926,15 @@ def get_github_merge_sha(state, repo_cfg, git_cfg):
920
926
return subprocess .check_output (git_cmd ('rev-parse' , 'FETCH_HEAD' )).decode ('ascii' ).strip () # noqa
921
927
922
928
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 ):
924
931
925
932
try :
926
933
merge_sha = create_merge (
927
934
state ,
928
935
repo_cfg ,
929
936
state .base_ref ,
937
+ logger ,
930
938
git_cfg ,
931
939
check_merge )
932
940
except subprocess .CalledProcessError :
@@ -951,7 +959,7 @@ def do_exemption_merge(state, repo_cfg, git_cfg, url, check_merge, reason):
951
959
return True
952
960
953
961
954
- def try_travis_exemption (state , repo_cfg , git_cfg ):
962
+ def try_travis_exemption (state , logger , repo_cfg , git_cfg ):
955
963
956
964
travis_info = None
957
965
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):
986
994
if (travis_commit .parents [0 ]['sha' ] == base_sha and
987
995
travis_commit .parents [1 ]['sha' ] == state .head_sha ):
988
996
# 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 ,
990
998
travis_info .target_url , True ,
991
999
"merge already tested by Travis CI" )
992
1000
993
1001
return False
994
1002
995
1003
996
- def try_status_exemption (state , repo_cfg , git_cfg ):
1004
+ def try_status_exemption (state , logger , repo_cfg , git_cfg ):
997
1005
998
1006
# If all the builders are status-based, then we can do some checks to
999
1007
# exempt testing under the following cases:
@@ -1032,7 +1040,7 @@ def try_status_exemption(state, repo_cfg, git_cfg):
1032
1040
# is the PR fully rebased?
1033
1041
base_sha = state .get_repo ().ref ('heads/' + state .base_ref ).object .sha
1034
1042
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 ,
1036
1044
"pull fully rebased and already tested" )
1037
1045
1038
1046
# check if we can use the github merge sha as proof
@@ -1050,7 +1058,7 @@ def try_status_exemption(state, repo_cfg, git_cfg):
1050
1058
merge_commit .parents [0 ]['sha' ] == base_sha and
1051
1059
merge_commit .parents [1 ]['sha' ] == state .head_sha ):
1052
1060
# 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 ,
1054
1062
"merge already tested" )
1055
1063
1056
1064
return False
@@ -1060,6 +1068,8 @@ def start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
1060
1068
if buildbot_slots [0 ]:
1061
1069
return True
1062
1070
1071
+ lazy_debug (logger , lambda : "start_build on {!r}" .format (state .get_repo ()))
1072
+
1063
1073
assert state .head_sha == state .get_repo ().pull_request (state .num ).head .sha
1064
1074
1065
1075
repo_cfg = repo_cfgs [state .repo_label ]
@@ -1100,15 +1110,18 @@ def start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
1100
1110
if len (builders ) is 0 :
1101
1111
raise RuntimeError ('Invalid configuration' )
1102
1112
1113
+ lazy_debug (logger , lambda : "start_build: builders={!r}" .format (builders ))
1114
+
1103
1115
if (only_status_builders and state .approved_by and
1104
1116
repo_cfg .get ('status_based_exemption' , False )):
1105
1117
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 ):
1107
1119
return True
1108
- if try_status_exemption (state , repo_cfg , git_cfg ):
1120
+ if try_status_exemption (state , logger , repo_cfg , git_cfg ):
1109
1121
return True
1110
1122
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 ))
1112
1125
if not merge_sha :
1113
1126
return False
1114
1127
@@ -1238,6 +1251,8 @@ def process_queue(states, repos, repo_cfgs, logger, buildbot_slots, db,
1238
1251
repo_states = sorted (states [repo_label ].values ())
1239
1252
1240
1253
for state in repo_states :
1254
+ lazy_debug (logger , lambda : "process_queue: state={!r}, building {}"
1255
+ .format (state , repo_label ))
1241
1256
if state .priority < repo .treeclosed :
1242
1257
continue
1243
1258
if state .status == 'pending' and not state .try_ :
0 commit comments