Merge "Log missing required status checks"

This commit is contained in:
Zuul 2020-09-21 16:17:12 +00:00 committed by Gerrit Code Review
commit 1ed1344785
1 changed files with 10 additions and 6 deletions

View File

@ -1663,7 +1663,11 @@ class GithubConnection(BaseConnection):
log.debug('Change %s can not merge because it is a draft', change)
return False
if not self._hasRequiredStatusChecks(allow_needs, canmerge_data):
missing_status_checks = self._getMissingStatusChecks(
allow_needs, canmerge_data)
if missing_status_checks:
log.debug('Change %s can not merge because required status checks '
'are missing: %s', change, missing_status_checks)
return False
review_decision = canmerge_data['reviewDecision']
@ -1784,11 +1788,11 @@ class GithubConnection(BaseConnection):
return resp.json()
@staticmethod
def _hasRequiredStatusChecks(allow_needs, canmerge_data):
def _getMissingStatusChecks(allow_needs, canmerge_data):
required_contexts = canmerge_data['requiredStatusCheckContexts']
if not required_contexts:
# There are no required contexts -> ok by definition
return True
return set()
# Strip allow_needs as we will set this in the gate ourselves
required_contexts = set(
@ -1798,9 +1802,9 @@ class GithubConnection(BaseConnection):
successful = set([s[0] for s in canmerge_data['status'].items()
if s[1] == 'SUCCESS'])
# Required contexts must be a subset of the successful contexts as
# we allow additional successful status contexts we don't care about.
return required_contexts.issubset(successful)
# Remove successful checks from the required contexts to get the
# remaining missing required status.
return required_contexts.difference(successful)
@cachetools.cached(cache=cachetools.TTLCache(maxsize=2048, ttl=3600),
key=lambda self, login, project: