Title: [256737] trunk/Tools
Revision
256737
Author
[email protected]
Date
2020-02-17 08:48:00 -0800 (Mon, 17 Feb 2020)

Log Message

EWS should be able to comment on Bugzilla
https://bugs.webkit.org/show_bug.cgi?id=201927

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(BugzillaMixin.comment_on_bug): Method to comment on bugzilla bug.
(BugzillaMixin.remove_flags_on_patch): Drive-by fix to correctly identify failure based on status code.
(BugzillaMixin.close_bug): Ditto.
(CommentOnBug): Build step to comment on bugzilla bug.

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/ews-build/steps.py (256736 => 256737)


--- trunk/Tools/BuildSlaveSupport/ews-build/steps.py	2020-02-17 16:45:29 UTC (rev 256736)
+++ trunk/Tools/BuildSlaveSupport/ews-build/steps.py	2020-02-17 16:48:00 UTC (rev 256737)
@@ -439,6 +439,9 @@
         flags = [{'name': 'review', 'status': 'X'}, {'name': 'commit-queue', 'status': 'X'}]
         try:
             response = requests.put(patch_url, json={'flags': flags, 'Bugzilla_api_key': self.get_bugzilla_api_key()})
+            if response.status_code not in [200, 201]:
+                self._addToLog('stdio', 'Unable to remove flags on patch {}. Unexpected response code from bugzilla: {}'.format(patch_id, response.status_code))
+                return FAILURE
         except Exception as e:
             self._addToLog('stdio', 'Error in removing flags on Patch {}'.format(patch_id))
             return FAILURE
@@ -448,12 +451,29 @@
         bug_url = '{}rest/bug/{}'.format(BUG_SERVER_URL, bug_id)
         try:
             response = requests.put(bug_url, json={'status': 'RESOLVED', 'resolution': 'FIXED', 'Bugzilla_api_key': self.get_bugzilla_api_key()})
+            if response.status_code not in [200, 201]:
+                self._addToLog('stdio', 'Unable to close bug {}. Unexpected response code from bugzilla: {}'.format(bug_id, response.status_code))
+                return FAILURE
         except Exception as e:
             self._addToLog('stdio', 'Error in closing bug {}'.format(bug_id))
             return FAILURE
         return SUCCESS
 
+    def comment_on_bug(self, bug_id, comment_text):
+        bug_comment_url = '{}rest/bug/{}/comment'.format(BUG_SERVER_URL, bug_id)
+        if not comment_text:
+            return FAILURE
+        try:
+            response = requests.post(bug_comment_url, data="" comment_text, 'Bugzilla_api_key': self.get_bugzilla_api_key()})
+            if response.status_code not in [200, 201]:
+                self._addToLog('stdio', 'Unable to comment on bug {}. Unexpected response code from bugzilla: {}'.format(bug_id, response.status_code))
+                return FAILURE
+        except Exception as e:
+            self._addToLog('stdio', 'Error in commenting on bug {}'.format(bug_id))
+            return FAILURE
+        return SUCCESS
 
+
 class ValidatePatch(buildstep.BuildStep, BugzillaMixin):
     name = 'validate-patch'
     description = ['validate-patch running']
@@ -574,6 +594,31 @@
         return {u'step': u'Failed to close bug {}'.format(self.bug_id)}
 
 
+class CommentOnBug(buildstep.BuildStep, BugzillaMixin):
+    name = 'comment-on-bugzilla-bug'
+    flunkOnFailure = False
+    haltOnFailure = False
+
+    def start(self):
+        self.bug_id = self.getProperty('bug_id', '')
+        self.comment_text = self.getProperty('bugzilla_comment_text', '')
+
+        if not self.comment_text:
+            self._addToLog('stdio', 'bugzilla_comment_text build property not found.\n')
+            self.descriptionDone = 'No bugzilla comment found'
+            self.finished(WARNINGS)
+            return None
+
+        rc = self.comment_on_bug(self.bug_id, self.comment_text)
+        self.finished(rc)
+        return None
+
+    def getResultSummary(self):
+        if self.results == SUCCESS:
+            return {u'step': u'Added comment on bug {}'.format(self.bug_id)}
+        return {u'step': u'Failed to add comment on bug {}'.format(self.bug_id)}
+
+
 class UnApplyPatchIfRequired(CleanWorkingDirectory):
     name = 'unapply-patch'
     descriptionDone = ['Unapplied patch']

Modified: trunk/Tools/ChangeLog (256736 => 256737)


--- trunk/Tools/ChangeLog	2020-02-17 16:45:29 UTC (rev 256736)
+++ trunk/Tools/ChangeLog	2020-02-17 16:48:00 UTC (rev 256737)
@@ -1,3 +1,16 @@
+2020-02-17  Aakash Jain  <[email protected]>
+
+        EWS should be able to comment on Bugzilla
+        https://bugs.webkit.org/show_bug.cgi?id=201927
+
+        Reviewed by Jonathan Bedard.
+
+        * BuildSlaveSupport/ews-build/steps.py:
+        (BugzillaMixin.comment_on_bug): Method to comment on bugzilla bug.
+        (BugzillaMixin.remove_flags_on_patch): Drive-by fix to correctly identify failure based on status code.
+        (BugzillaMixin.close_bug): Ditto.
+        (CommentOnBug): Build step to comment on bugzilla bug.
+
 2020-02-17  Antti Koivisto  <[email protected]>
 
         [macOS] Add trace points for layer flush runloop observer
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to