Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure that email notifications are not sent for obsolete and r- patches
https://bugs.webkit.org/show_bug.cgi?id=215867

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(BugzillaMixin.should_send_email): Method to check if patch is obsolete/r-.
(AnalyzeCompileWebKitResults): Inherit from BugzillaMixin.
(AnalyzeCompileWebKitResults.send_email_for_new_build_failure): Check for patch state before sending email.
(AnalyzeLayoutTestsResults): Ditto.
(AnalyzeLayoutTestsResults.send_email_for_new_test_failures): Ditto.


Canonical link: https://commits.webkit.org/228710@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
aj062 committed Aug 27, 2020
1 parent c53e41d commit cb0090b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
35 changes: 31 additions & 4 deletions Tools/BuildSlaveSupport/ews-build/steps.py
Expand Up @@ -529,6 +529,27 @@ def _is_bug_closed(self, bug_id):
return 1
return 0

def should_send_email(self, patch_id):
patch_json = self.get_patch_json(patch_id)
if not patch_json:
self._addToLog('stdio', 'Unable to fetch patch {}'.format(patch_id))
return True

obsolete = patch_json.get('is_obsolete')
if obsolete == 1:
self._addToLog('stdio', 'Skipping email since patch {} is obsolete'.format(patch_id))
return False

review_denied = False
for flag in patch_json.get('flags', []):
if flag.get('name') == 'review' and flag.get('status') == '-':
review_denied = True

if review_denied:
self._addToLog('stdio', 'Skipping email since patch {} is marked r-'.format(patch_id))
return False
return True

def get_bugzilla_api_key(self):
try:
passwords = json.load(open('passwords.json'))
Expand Down Expand Up @@ -1387,7 +1408,7 @@ def evaluateCommand(self, cmd):
return shell.Compile.evaluateCommand(self, cmd)


class AnalyzeCompileWebKitResults(buildstep.BuildStep):
class AnalyzeCompileWebKitResults(buildstep.BuildStep, BugzillaMixin):
name = 'analyze-compile-webkit-results'
description = ['analyze-compile-webkit-results']
descriptionDone = ['analyze-compile-webkit-results']
Expand Down Expand Up @@ -1469,11 +1490,13 @@ def filter_logs_containing_error(self, logs, searchString='rror:', max_num_lines

def send_email_for_new_build_failure(self):
try:
patch_id = self.getProperty('patch_id', '')
if not self.should_send_email(patch_id):
return
builder_name = self.getProperty('buildername', '')
bug_id = self.getProperty('bug_id', '')
bug_title = self.getProperty('bug_title', '')
worker_name = self.getProperty('workername', '')
patch_id = self.getProperty('patch_id', '')
patch_author = self.getProperty('patch_author', '')
platform = self.getProperty('platform', '')
build_url = '{}#/builders/{}/builds/{}'.format(self.master.config.buildbotURL, self.build._builderid, self.build.number)
Expand All @@ -1492,6 +1515,7 @@ def send_email_for_new_build_failure(self):
logs = logs.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
email_text += u'\n\nError lines:\n\n<code>{}</code>'.format(logs)
email_text += '\n\nTo unsubscrible from these notifications or to provide any feedback please email aakash_jain@apple.com'
self._addToLog('stdio', 'Sending email notification to {}'.format(patch_author))
send_email_to_patch_author(patch_author, email_subject, email_text, patch_id)
except Exception as e:
print('Error in sending email for new build failure: {}'.format(e))
Expand Down Expand Up @@ -2058,7 +2082,7 @@ def commandComplete(self, cmd):
self._parseRunWebKitTestsOutput(logText)


class AnalyzeLayoutTestsResults(buildstep.BuildStep):
class AnalyzeLayoutTestsResults(buildstep.BuildStep, BugzillaMixin):
name = 'analyze-layout-tests-results'
description = ['analyze-layout-test-results']
descriptionDone = ['analyze-layout-tests-results']
Expand Down Expand Up @@ -2147,11 +2171,13 @@ def send_email_for_pre_existing_failure(self, test_name):

def send_email_for_new_test_failures(self, test_names):
try:
patch_id = self.getProperty('patch_id', '')
if not self.should_send_email(patch_id):
return
builder_name = self.getProperty('buildername', '')
bug_id = self.getProperty('bug_id', '')
bug_title = self.getProperty('bug_title', '')
worker_name = self.getProperty('workername', '')
patch_id = self.getProperty('patch_id', '')
patch_author = self.getProperty('patch_author', '')
build_url = '{}#/builders/{}/builds/{}'.format(self.master.config.buildbotURL, self.build._builderid, self.build.number)
test_names_string = ''
Expand All @@ -2167,6 +2193,7 @@ def send_email_for_new_test_failures(self, test_names):
email_text += '\n\nFull details are available at: {}\n\nPatch author: {}'.format(build_url, patch_author)
email_text += '\n\nLayout test failure{}:\n{}'.format(pluralSuffix, test_names_string)
email_text += '\n\nTo unsubscrible from these notifications or to provide any feedback please email aakash_jain@apple.com'
self._addToLog('stdio', 'Sending email notification to {}'.format(patch_author))
send_email_to_patch_author(patch_author, email_subject, email_text, patch_id)
except Exception as e:
print('Error in sending email for new layout test failures: {}'.format(e))
Expand Down
14 changes: 14 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,17 @@
2020-08-27 Aakash Jain <aakash_jain@apple.com>

Ensure that email notifications are not sent for obsolete and r- patches
https://bugs.webkit.org/show_bug.cgi?id=215867

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(BugzillaMixin.should_send_email): Method to check if patch is obsolete/r-.
(AnalyzeCompileWebKitResults): Inherit from BugzillaMixin.
(AnalyzeCompileWebKitResults.send_email_for_new_build_failure): Check for patch state before sending email.
(AnalyzeLayoutTestsResults): Ditto.
(AnalyzeLayoutTestsResults.send_email_for_new_test_failures): Ditto.

2020-08-27 Aakash Jain <aakash_jain@apple.com>

Send ews email notifications to myself
Expand Down

0 comments on commit cb0090b

Please sign in to comment.