Merge "Update check-all-candidacies to use the email address in the candidacy"

This commit is contained in:
Zuul 2018-07-30 11:14:49 +00:00 committed by Gerrit Code Review
commit bc1924ba44

View File

@ -15,10 +15,13 @@ from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
import argparse import argparse
import os
from openstack_election import check_candidacy from openstack_election.cmds import ci_check_all_candidate_files as checks
from openstack_election import utils from openstack_election import utils
results = []
def get_reviews(): def get_reviews():
return utils.get_reviews('is:open project:%s file:^%s/%s/.*' % return utils.get_reviews('is:open project:%s file:^%s/%s/.*' %
@ -26,9 +29,16 @@ def get_reviews():
utils.conf['release'])) utils.conf['release']))
def print_member(filepath):
email = utils.get_email(filepath)
member = utils.lookup_member(email)
member_id = member.get('data', [{}])[0].get('id')
base = 'https://www.openstack.org/community/members/profile'
print('OSF member profile: %s/%s' % (base, member_id))
def main(): def main():
description = ('Check if the owner of open changes are valid candidates as' description = ('Check all open reviews for candidacies')
' described in the change')
parser = argparse.ArgumentParser(description) parser = argparse.ArgumentParser(description)
parser.add_argument('--limit', dest='limit', type=int, default=1, parser.add_argument('--limit', dest='limit', type=int, default=1,
help=('How many validating changes to report. ' help=('How many validating changes to report. '
@ -39,30 +49,50 @@ def main():
'Default: %(default)s')) 'Default: %(default)s'))
args = parser.parse_args() args = parser.parse_args()
projects = utils.get_projects(tag=args.tag, fallback_to_master=True)
for review in get_reviews(): for review in get_reviews():
if review['status'] != 'NEW': if review['status'] != 'NEW':
continue continue
print('Checking %s/%d' % review_url = '%s/%d' % (utils.GERRIT_BASE, review['_number'])
(utils.GERRIT_BASE, review['_number'])) print('Checking %s' % (review_url))
if not len(utils.candidate_files(review)): for filepath in utils.candidate_files(review):
print("[E] No candidacy added") email = utils.get_email(filepath)
continue team = os.path.basename(os.path.dirname(filepath))
owner = review.get('owner', {}) # Some kind souls remove the .placeholder file when they upload
try: # a candidacy
found = check_candidacy.check_candidacy_review(review['change_id'], if email == '.placeholder':
tag=args.tag, continue
limit=args.limit,
review=review) candiate_ok = checks.validate_filename(filepath)
except Exception as exc: if candiate_ok:
print("[E] %s\n\n" % (exc)) candiate_ok = checks.validate_member(filepath)
else:
if found: if candiate_ok:
print('SUCESS: %s is a valid candidate\n\n' % if utils.is_tc_election:
(owner['email'])) candiate_ok = checks.check_for_changes(projects, filepath,
args.limit)
print_member(filepath)
else:
print('Not checking for changes as this is a TC election')
else: else:
print('[E]: %s is not a valid candidate\n\n' % print('Not checking for changes as %s doesn\'t seem to '
(owner['email'])) 'describe a valid candidacy' % (filepath))
results.append((review_url, email, team, candiate_ok))
print('\n\n\n')
print('*' * 80)
for result in results:
(review_url, email, team, candiate_ok) = result
print(review_url)
if candiate_ok:
print(' SUCCESS: %s is a valid candidate for %s' % (email, team))
else:
print(' ERROR: Candidate %s is not valid, please review '
'previous messages for details.' % (email))
print('*' * 80)
return 0 return 0