Skip to content
Permalink
Browse files
[EWS] Support PRs when sending build failure emails
https://bugs.webkit.org/show_bug.cgi?id=235926
<rdar://problem/88302122>

Reviewed by Aakash Jain.

* Tools/CISupport/ews-build/steps.py:
(GitHub.email_for_owners): Convert list of owners to an email address.
(GitHubMixin.should_send_email_for_pr): Check if the tested sha is outdated.
(BugzillaMixin.should_send_email_for_patch): Renamed from should_send_email.
(BugzillaMixin.should_send_email): Renamed to should_send_email_for_patch.
(AnalyzeCompileWebKitResults.send_email_for_new_build_failure): Draft different
email for failed patch than failed pull request build.
(AnalyzeLayoutTestsResults.send_email_for_new_test_failures):


Canonical link: https://commits.webkit.org/247249@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289784 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Feb 15, 2022
1 parent 2ad1ac8 commit 035f98aaadcb3f7b28c4cb9a9e010e3412509f36
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 21 deletions.
@@ -127,6 +127,14 @@ def credentials(cls):
print('Error reading GitHub credentials')
return None, None

@classmethod
def email_for_owners(cls, owners):
if not owners:
print('No owners defined, so email cannot be extracted')
return None
contributors, errors = Contributors.load(use_network=False)
return contributors.get(owners[0], {}).get('email'), errors


class GitHubMixin(object):
addURLs = False
@@ -184,6 +192,19 @@ def _is_hash_outdated(self, pr_json):
return -1
return 0 if pr_sha == self.getProperty('github.head.sha', '?') else 1

def should_send_email_for_pr(self, pr_number):
pr_json = self.get_pr_json(pr_number)
if not pr_json:
self._addToLog('stdio', 'Unable to fetch PR #{}\n'.format(pr_number))
return True

if 1 == self._is_hash_outdated(pr_json):
self._addToLog('stdio', 'Skipping email since hash {} on PR #{} is outdated\n'.format(
self.getProperty('github.head.sha', '?')[:HASH_LENGTH_TO_DISPLAY], pr_number,
))
return False
return True


class Contributors(object):
url = 'https://raw.githubusercontent.com/WebKit/WebKit/main/metadata/contributors.json'
@@ -317,16 +338,15 @@ def add_pr_details(self):
if title:
self.addURL('PR {}: {}'.format(pr_number, title), GitHub.pr_url(pr_number, repository_url))
if owners:
contributors, errors = Contributors.load(use_network=False)
email, errors = GitHub.email_for_owners(owners)
for error in errors:
print(error)
self._addToLog('stdio', error)
github_username = owners[0]
contributor = contributors.get(github_username, {})
display_name = contributor.get('email', github_username)
if display_name != github_username:
display_name = '{} ({})'.format(display_name, github_username)
self.addURL('PR by: {}'.format(display_name), '{}{}'.format(GITHUB_URL, github_username))
if email:
display_name = '{} ({})'.format(email, owners[0])
else:
display_name = owners[0]
self.addURL('PR by: {}'.format(display_name), '{}{}'.format(GITHUB_URL, owners[0]))
if revision:
self.addURL('Hash: {}'.format(revision[:HASH_LENGTH_TO_DISPLAY]), GitHub.commit_url(revision, repository_url))

@@ -1018,7 +1038,7 @@ def _is_bug_closed(self, bug_id):
return 1
return 0

def should_send_email(self, patch_id):
def should_send_email_for_patch(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))
@@ -2031,7 +2051,7 @@ def send_email_for_unexpected_build_failure(self):
print('Error in sending email for unexpected build failure: {}'.format(e))


class AnalyzeCompileWebKitResults(buildstep.BuildStep, BugzillaMixin):
class AnalyzeCompileWebKitResults(buildstep.BuildStep, BugzillaMixin, GitHubMixin):
name = 'analyze-compile-webkit-results'
description = ['analyze-compile-webkit-results']
descriptionDone = ['analyze-compile-webkit-results']
@@ -2123,14 +2143,36 @@ 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', '')
# FIXME: Support pull requests
if not patch_id or not self.should_send_email(patch_id):
pr_number = self.getProperty('github.number', '')
sha = self.getProperty('github.head.sha', '')[:HASH_LENGTH_TO_DISPLAY]

if patch_id and not self.should_send_email_for_patch(patch_id):
return
if pr_number and not self.should_send_email_for_pr(pr_number):
return
if not patch_id and not (pr_number and sha):
print('Unrecognized change type')
return

change_string = None
change_author = None
if patch_id:
change_author = self.getProperty('patch_author', '')
change_string = 'Patch {}'.format(patch_id)
elif pr_number and sha:
change_string = 'Hash {}'.format(sha)
change_author, errors = GitHub.email_for_owners(self.getProperty('owners', []))
for error in errors:
print(error)

if not change_author:
print('Failed to determine change author for hash {} belonging to PR #{}'.format(sha, patch_id))

This comment has been minimized.

Copy link
@aj062

aj062 Feb 15, 2022

Member

Seems like you missed my comment #114 (comment)

This message should be displayed in UI, as this will happen with people who are not in contributors.json

This comment has been minimized.

Copy link
@JonWBedard

JonWBedard Feb 15, 2022

Author Member

Oops! I did miss that, will address in a follow-up.

return

builder_name = self.getProperty('buildername', '')
bug_id = self.getProperty('bug_id', '')
bug_title = self.getProperty('bug_title', '')
issue_id = self.getProperty('bug_id', '') or pr_number
title = self.getProperty('bug_title', '') or self.getProperty('github.title', '')
worker_name = self.getProperty('workername', '')
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)
logs = self.error_logs.get(self.compile_webkit_step)
@@ -2139,17 +2181,22 @@ def send_email_for_new_build_failure(self):
else:
logs = self.filter_logs_containing_error(logs)

email_subject = 'Build failure for Patch {}: {}'.format(patch_id, bug_title)
email_subject = 'Build failure for {}: {}'.format(change_string, title)
email_text = 'EWS has detected build failure on {}'.format(builder_name)
email_text += ' while testing <a href="{}">Patch {}</a>'.format(Bugzilla.patch_url(patch_id), patch_id)
email_text += ' for <a href="{}">Bug {}</a>.'.format(Bugzilla.bug_url(bug_id), bug_id)
email_text += '\n\nFull details are available at: {}\n\nPatch author: {}'.format(build_url, patch_author)
if patch_id:
email_text += ' while testing <a href="{}">{}</a>'.format(Bugzilla.patch_url(patch_id), change_string)
email_text += ' for <a href="{}">Bug {}</a>.'.format(Bugzilla.bug_url(bug_id), bug_id)
if sha:
repository = self.getProperty('repository')
email_text += ' while testing <a href="{}">{}</a>'.format(GitHub.commit_url(sha, repository), change_string)
email_text += ' for <a href="{}">PR #{}</a>.'.format(GitHub.pr_url(pr_number, repository), pr_number)
email_text += '\n\nFull details are available at: {}\n\nChange author: {}'.format(build_url, change_author)
if logs:
logs = logs.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
email_text += '\n\nError lines:\n\n<code>{}</code>'.format(logs)
email_text += '\n\nTo unsubscribe 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)
self._addToLog('stdio', 'Sending email notification to {}'.format(change_author))
send_email_to_patch_author(change_author, email_subject, email_text, patch_id or self.getProperty('github.head.sha', ''))
except Exception as e:
print('Error in sending email for new build failure: {}'.format(e))

@@ -2962,7 +3009,7 @@ def send_email_for_pre_existing_failure(self, test_name):
def send_email_for_new_test_failures(self, test_names, exceed_failure_limit=False):
try:
patch_id = self.getProperty('patch_id', '')
if not self.should_send_email(patch_id):
if not self.should_send_email_for_patch(patch_id):
return
builder_name = self.getProperty('buildername', '')
bug_id = self.getProperty('bug_id', '')
@@ -1,3 +1,20 @@
2022-02-01 Jonathan Bedard <jbedard@apple.com>

[EWS] Support PRs when sending build failure emails
https://bugs.webkit.org/show_bug.cgi?id=235926
<rdar://problem/88302122>

Reviewed by Aakash Jain.

* CISupport/ews-build/steps.py:
(GitHub.email_for_owners): Convert list of owners to an email address.
(GitHubMixin.should_send_email_for_pr): Check if the tested sha is outdated.
(BugzillaMixin.should_send_email_for_patch): Renamed from should_send_email.
(BugzillaMixin.should_send_email): Renamed to should_send_email_for_patch.
(AnalyzeCompileWebKitResults.send_email_for_new_build_failure): Draft different
email for failed patch than failed pull request build.
(AnalyzeLayoutTestsResults.send_email_for_new_test_failures):

2022-02-07 Jon Lee <jonlee@apple.com>

Enable accelerated drawing in the iOS simulator

0 comments on commit 035f98a

Please sign in to comment.