|
Lines 89-95
class GitHub(object):
a/Tools/CISupport/ews-build/steps.py_sec1
|
| 89 |
return '{}pull/{}'.format(repository_url, pr_number) |
89 |
return '{}pull/{}'.format(repository_url, pr_number) |
| 90 |
|
90 |
|
| 91 |
|
91 |
|
| 92 |
class ConfigureBuild(buildstep.BuildStep): |
92 |
class Contributors(object): |
|
|
93 |
url = 'https://raw.githubusercontent.com/WebKit/WebKit/main/metadata/contributors.json' |
| 94 |
contributors = {} |
| 95 |
|
| 96 |
@classmethod |
| 97 |
def load_from_disk(cls): |
| 98 |
cwd = os.path.abspath(os.path.dirname(__file__)) |
| 99 |
repo_root = os.path.dirname(os.path.dirname(os.path.dirname(cwd))) |
| 100 |
contributors_path = os.path.join(repo_root, 'metadata/contributors.json') |
| 101 |
try: |
| 102 |
with open(contributors_path, 'rb') as contributors_json: |
| 103 |
return json.load(contributors_json), None |
| 104 |
except Exception as e: |
| 105 |
return {}, 'Failed to load {}\n'.format(contributors_path) |
| 106 |
|
| 107 |
@classmethod |
| 108 |
def load_from_github(cls): |
| 109 |
try: |
| 110 |
response = requests.get(cls.url, timeout=60) |
| 111 |
if response.status_code != 200: |
| 112 |
return {}, 'Failed to access {} with status code: {}\n'.format(cls.url, response.status_code) |
| 113 |
return response.json(), None |
| 114 |
except Exception as e: |
| 115 |
return {}, 'Failed to access {url}\n'.format(url=cls.url) |
| 116 |
|
| 117 |
@classmethod |
| 118 |
def load(cls): |
| 119 |
errors = [] |
| 120 |
contributors_json, error = cls.load_from_github() |
| 121 |
if error: |
| 122 |
errors.append(error) |
| 123 |
|
| 124 |
if not contributors_json: |
| 125 |
contributors_json, error = cls.load_from_disk() |
| 126 |
if error: |
| 127 |
errors.append(error) |
| 128 |
|
| 129 |
contributors = {} |
| 130 |
for value in contributors_json: |
| 131 |
name = value.get('name') |
| 132 |
emails = value.get('emails') |
| 133 |
github_username = value.get('github') |
| 134 |
if name and emails: |
| 135 |
bugzilla_email = emails[0].lower() # We're requiring that the first email is the primary bugzilla email |
| 136 |
contributors[bugzilla_email] = {'name': name, 'status': value.get('status')} |
| 137 |
if github_username and name and emails: |
| 138 |
contributors[github_username] = dict( |
| 139 |
printable='{} <{}>'.format(name, emails[0].lower()), |
| 140 |
status=value.get('status'), |
| 141 |
email=emails[0], |
| 142 |
) |
| 143 |
return contributors, errors |
| 144 |
|
| 145 |
|
| 146 |
class ConfigureBuild(buildstep.BuildStep, GitHubMixin): |
| 93 |
name = 'configure-build' |
147 |
name = 'configure-build' |
| 94 |
description = ['configuring build'] |
148 |
description = ['configuring build'] |
| 95 |
descriptionDone = ['Configured build'] |
149 |
descriptionDone = ['Configured build'] |
|
Lines 958-1001
class ValidatePatch(buildstep.BuildStep, BugzillaMixin):
a/Tools/CISupport/ews-build/steps.py_sec2
|
| 958 |
class ValidateCommiterAndReviewer(buildstep.BuildStep): |
1012 |
class ValidateCommiterAndReviewer(buildstep.BuildStep): |
| 959 |
name = 'validate-commiter-and-reviewer' |
1013 |
name = 'validate-commiter-and-reviewer' |
| 960 |
descriptionDone = ['Validated commiter and reviewer'] |
1014 |
descriptionDone = ['Validated commiter and reviewer'] |
| 961 |
url = 'https://raw.githubusercontent.com/WebKit/WebKit/main/metadata/contributors.json' |
|
|
| 962 |
contributors = {} |
| 963 |
|
| 964 |
def load_contributors_from_disk(self): |
| 965 |
cwd = os.path.abspath(os.path.dirname(__file__)) |
| 966 |
repo_root = os.path.dirname(os.path.dirname(os.path.dirname(cwd))) |
| 967 |
contributors_path = os.path.join(repo_root, 'metadata/contributors.json') |
| 968 |
try: |
| 969 |
with open(contributors_path, 'rb') as contributors_json: |
| 970 |
return json.load(contributors_json) |
| 971 |
except Exception as e: |
| 972 |
self._addToLog('stdio', 'Failed to load {}\n'.format(contributors_path)) |
| 973 |
return {} |
| 974 |
|
| 975 |
def load_contributors_from_github(self): |
| 976 |
try: |
| 977 |
response = requests.get(self.url, timeout=60) |
| 978 |
if response.status_code != 200: |
| 979 |
self._addToLog('stdio', 'Failed to access {} with status code: {}\n'.format(self.url, response.status_code)) |
| 980 |
return {} |
| 981 |
return response.json() |
| 982 |
except Exception as e: |
| 983 |
self._addToLog('stdio', 'Failed to access {url}\n'.format(url=self.url)) |
| 984 |
return {} |
| 985 |
|
1015 |
|
| 986 |
def load_contributors(self): |
1016 |
def __init__(self, *args, **kwargs): |
| 987 |
contributors_json = self.load_contributors_from_github() |
1017 |
super(ValidateCommiterAndReviewer, self).__init__(*args, **kwargs) |
| 988 |
if not contributors_json: |
1018 |
self.contributors = {} |
| 989 |
contributors_json = self.load_contributors_from_disk() |
|
|
| 990 |
|
| 991 |
contributors = {} |
| 992 |
for value in contributors_json: |
| 993 |
name = value.get('name') |
| 994 |
emails = value.get('emails') |
| 995 |
if name and emails: |
| 996 |
bugzilla_email = emails[0].lower() # We're requiring that the first email is the primary bugzilla email |
| 997 |
contributors[bugzilla_email] = {'name': name, 'status': value.get('status')} |
| 998 |
return contributors |
| 999 |
|
1019 |
|
| 1000 |
@defer.inlineCallbacks |
1020 |
@defer.inlineCallbacks |
| 1001 |
def _addToLog(self, logName, message): |
1021 |
def _addToLog(self, logName, message): |
|
Lines 1012-1018
class ValidateCommiterAndReviewer(buildstep.BuildStep):
a/Tools/CISupport/ews-build/steps.py_sec3
|
| 1012 |
|
1032 |
|
| 1013 |
def fail_build(self, email, status): |
1033 |
def fail_build(self, email, status): |
| 1014 |
reason = '{} does not have {} permissions'.format(email, status) |
1034 |
reason = '{} does not have {} permissions'.format(email, status) |
| 1015 |
comment = '{} does not have {} permissions according to {}.'.format(email, status, self.url) |
1035 |
comment = '{} does not have {} permissions according to {}.'.format(email, status, Contributors.url) |
| 1016 |
comment += '\n\nRejecting attachment {} from commit queue.'.format(self.getProperty('patch_id', '')) |
1036 |
comment += '\n\nRejecting attachment {} from commit queue.'.format(self.getProperty('patch_id', '')) |
| 1017 |
self.setProperty('bugzilla_comment_text', comment) |
1037 |
self.setProperty('bugzilla_comment_text', comment) |
| 1018 |
|
1038 |
|
|
Lines 1037-1043
class ValidateCommiterAndReviewer(buildstep.BuildStep):
a/Tools/CISupport/ews-build/steps.py_sec4
|
| 1037 |
return contributor.get('name') |
1057 |
return contributor.get('name') |
| 1038 |
|
1058 |
|
| 1039 |
def start(self): |
1059 |
def start(self): |
| 1040 |
self.contributors = self.load_contributors() |
1060 |
self.contributors, errors = Contributors.load() |
|
|
1061 |
for error in errors: |
| 1062 |
print(error) |
| 1063 |
self._addToLog('stdio', error) |
| 1064 |
|
| 1041 |
if not self.contributors: |
1065 |
if not self.contributors: |
| 1042 |
self.finished(FAILURE) |
1066 |
self.finished(FAILURE) |
| 1043 |
self.descriptionDone = 'Failed to get contributors information' |
1067 |
self.descriptionDone = 'Failed to get contributors information' |