Title: [275613] trunk/Tools
Revision
275613
Author
[email protected]
Date
2021-04-07 10:58:00 -0700 (Wed, 07 Apr 2021)

Log Message

[build.webkit.org] Commit queue should post the identifier
https://bugs.webkit.org/show_bug.cgi?id=223829
<rdar://problem/75908321>

Reviewed by Aakash Jain.

* CISupport/ews-build/steps.py:
(PushCommitToWebKitRepo.url_for_revision): Use COMMITS_INFO_URL.
(PushCommitToWebKitRepo.url_for_identifier): Convert identifier
to commits.webkit.org URL.
(PushCommitToWebKitRepo.identifier_for_revision): Convert a commit
revision to an identifier string.
(PushCommitToWebKitRepo.comment_text_for_bug): Consult commits.webkit.org
to convert revision to identifier.
* CISupport/ews-build/steps_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/CISupport/ews-build/steps.py (275612 => 275613)


--- trunk/Tools/CISupport/ews-build/steps.py	2021-04-07 17:26:03 UTC (rev 275612)
+++ trunk/Tools/CISupport/ews-build/steps.py	2021-04-07 17:58:00 UTC (rev 275613)
@@ -3260,12 +3260,13 @@
         if rc == SUCCESS:
             log_text = self.log_observer.getStdout() + self.log_observer.getStderr()
             svn_revision = self.svn_revision_from_commit_text(log_text)
-            self.setProperty('bugzilla_comment_text', self.comment_text_for_bug(svn_revision))
-            commit_summary = 'Committed r{}'.format(svn_revision)
+            identifier = self.identifier_for_revision(svn_revision)
+            self.setProperty('bugzilla_comment_text', self.comment_text_for_bug(svn_revision, identifier))
+            commit_summary = 'Committed {}'.format(identifier)
             self.descriptionDone = commit_summary
-            self.setProperty('build_summary', 'Committed r{}'.format(svn_revision))
+            self.setProperty('build_summary', commit_summary)
             self.build.addStepsAfterCurrentStep([CommentOnBug(), RemoveFlagsOnPatch(), CloseBug()])
-            self.addURL('r{}'.format(svn_revision), self.url_for_revision(svn_revision))
+            self.addURL(identifier, self.url_for_identifier(identifier))
         else:
             retry_count = int(self.getProperty('retry_count', 0))
             if retry_count < self.MAX_RETRY:
@@ -3278,16 +3279,33 @@
             self.build.addStepsAfterCurrentStep([CommentOnBug(), SetCommitQueueMinusFlagOnPatch()])
         return rc
 
-    def url_for_revision(self, revision):
-        return 'https://commits.webkit.org/r{}'.format(revision)
+    def url_for_revision_details(self, revision):
+        return '{}r{}/json'.format(COMMITS_INFO_URL, revision)
 
-    def comment_text_for_bug(self, svn_revision=None):
+    def url_for_identifier(self, identifier):
+        return '{}{}'.format(COMMITS_INFO_URL, identifier)
+
+    def identifier_for_revision(self, revision):
+        try:
+            response = requests.get(self.url_for_revision_details(revision), timeout=60)
+            if response and response.status_code == 200:
+                return response.json().get('identifier', 'r{}'.format(revision))
+            else:
+                print('Non-200 status code received from {}: {}'.format(COMMITS_INFO_URL, response.status_code))
+                print(response.text)
+        except Exception as e:
+            print(e)
+        return 'r{}'.format(revision)
+
+    def comment_text_for_bug(self, svn_revision=None, identifier=None):
         patch_id = self.getProperty('patch_id', '')
         if not svn_revision:
             comment = 'commit-queue failed to commit attachment {} to WebKit repository.'.format(patch_id)
             comment += ' To retry, please set cq+ flag again.'
             return comment
-        comment = 'Committed r{}: <{}>'.format(svn_revision, self.url_for_revision(svn_revision))
+
+        identifier_str = identifier if identifier and '@' in identifier else '?'
+        comment = 'Committed r{} ({}): <{}>'.format(svn_revision, identifier_str, self.url_for_identifier(identifier))
         comment += '\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment {}.'.format(patch_id)
         return comment
 

Modified: trunk/Tools/CISupport/ews-build/steps_unittest.py (275612 => 275613)


--- trunk/Tools/CISupport/ews-build/steps_unittest.py	2021-04-07 17:26:03 UTC (rev 275612)
+++ trunk/Tools/CISupport/ews-build/steps_unittest.py	2021-04-07 17:58:00 UTC (rev 275613)
@@ -34,7 +34,7 @@
 from buildbot.test.util.misc import TestReactorMixin
 from buildbot.test.util.steps import BuildStepMixin
 from buildbot.util import identifiers as buildbot_identifiers
-from mock import call
+from mock import call, patch
 from twisted.internet import defer, error, reactor
 from twisted.python import failure, log
 from twisted.trial import unittest
@@ -4089,24 +4089,64 @@
     def tearDown(self):
         return self.tearDownBuildStep()
 
-    def test_success(self):
-        self.setupStep(PushCommitToWebKitRepo())
-        self.setProperty('patch_id', '1234')
-        self.expectRemoteCommands(
-            ExpectShell(workdir='wkdir',
-                        timeout=300,
-                        logEnviron=False,
-                        command=['git', 'svn', 'dcommit', '--rmdir']) +
-            ExpectShell.log('stdio', stdout='Committed r256729') +
-            0,
+    def mock_commits_webkit_org(self, identifier=None):
+        class Response(object):
+            def __init__(self, data="" status_code=200):
+                self.status_code = status_code
+                self.headers = {'Content-Type': 'text/json'}
+                self.text = json.dumps(data or {})
+
+            def json(self):
+                return json.loads(self.text)
+
+        return patch(
+            'requests.get',
+            lambda *args, **kwargs: Response(
+                data="" if identifier else dict(status='Not Found'),
+                status_code=200 if identifier else 404,
+            )
         )
-        self.expectOutcome(result=SUCCESS, state_string='Committed r256729')
-        with current_hostname(EWS_BUILD_HOSTNAME):
-            rc = self.runStep()
-        self.assertEqual(self.getProperty('bugzilla_comment_text'), 'Committed r256729: <https://commits.webkit.org/r256729>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
-        self.assertEqual(self.getProperty('build_finish_summary'), None)
-        return rc
 
+    def test_success(self):
+        with self.mock_commits_webkit_org(identifier='220797@main'):
+            self.setupStep(PushCommitToWebKitRepo())
+            self.setProperty('patch_id', '1234')
+            self.expectRemoteCommands(
+                ExpectShell(workdir='wkdir',
+                            timeout=300,
+                            logEnviron=False,
+                            command=['git', 'svn', 'dcommit', '--rmdir']) +
+                ExpectShell.log('stdio', stdout='Committed r256729') +
+                0,
+            )
+            self.expectOutcome(result=SUCCESS, state_string='Committed 220797@main')
+            with current_hostname(EWS_BUILD_HOSTNAME):
+                rc = self.runStep()
+            self.assertEqual(self.getProperty('bugzilla_comment_text'), 'Committed r256729 (220797@main): <https://commits.webkit.org/220797@main>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+            self.assertEqual(self.getProperty('build_finish_summary'), None)
+            self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
+            return rc
+
+    def test_success_no_identifier(self):
+        with self.mock_commits_webkit_org():
+            self.setupStep(PushCommitToWebKitRepo())
+            self.setProperty('patch_id', '1234')
+            self.expectRemoteCommands(
+                ExpectShell(workdir='wkdir',
+                            timeout=300,
+                            logEnviron=False,
+                            command=['git', 'svn', 'dcommit', '--rmdir']) +
+                ExpectShell.log('stdio', stdout='Committed r256729') +
+                0,
+            )
+            self.expectOutcome(result=SUCCESS, state_string='Committed r256729')
+            with current_hostname(EWS_BUILD_HOSTNAME):
+                rc = self.runStep()
+            self.assertEqual(self.getProperty('bugzilla_comment_text'), 'Committed r256729 (?): <https://commits.webkit.org/r256729>\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment 1234.')
+            self.assertEqual(self.getProperty('build_finish_summary'), None)
+            self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
+            return rc
+
     def test_failure_retry(self):
         self.setupStep(PushCommitToWebKitRepo())
         self.setProperty('patch_id', '2345')

Modified: trunk/Tools/ChangeLog (275612 => 275613)


--- trunk/Tools/ChangeLog	2021-04-07 17:26:03 UTC (rev 275612)
+++ trunk/Tools/ChangeLog	2021-04-07 17:58:00 UTC (rev 275613)
@@ -1,3 +1,21 @@
+2021-04-07  Jonathan Bedard  <[email protected]>
+
+        [build.webkit.org] Commit queue should post the identifier
+        https://bugs.webkit.org/show_bug.cgi?id=223829
+        <rdar://problem/75908321>
+
+        Reviewed by Aakash Jain.
+
+        * CISupport/ews-build/steps.py:
+        (PushCommitToWebKitRepo.url_for_revision): Use COMMITS_INFO_URL.
+        (PushCommitToWebKitRepo.url_for_identifier): Convert identifier
+        to commits.webkit.org URL.
+        (PushCommitToWebKitRepo.identifier_for_revision): Convert a commit
+        revision to an identifier string.
+        (PushCommitToWebKitRepo.comment_text_for_bug): Consult commits.webkit.org
+        to convert revision to identifier.
+        * CISupport/ews-build/steps_unittest.py:
+
 2021-04-07  Aakash Jain  <[email protected]>
 
         git-webkit find doesn't work well with unicode characters in author name
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to