Changeset 275613 in webkit


Ignore:
Timestamp:
Apr 7, 2021 10:58:00 AM (3 years ago)
Author:
Jonathan Bedard
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:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/CISupport/ews-build/steps.py

    r275287 r275613  
    32613261            log_text = self.log_observer.getStdout() + self.log_observer.getStderr()
    32623262            svn_revision = self.svn_revision_from_commit_text(log_text)
    3263             self.setProperty('bugzilla_comment_text', self.comment_text_for_bug(svn_revision))
    3264             commit_summary = 'Committed r{}'.format(svn_revision)
     3263            identifier = self.identifier_for_revision(svn_revision)
     3264            self.setProperty('bugzilla_comment_text', self.comment_text_for_bug(svn_revision, identifier))
     3265            commit_summary = 'Committed {}'.format(identifier)
    32653266            self.descriptionDone = commit_summary
    3266             self.setProperty('build_summary', 'Committed r{}'.format(svn_revision))
     3267            self.setProperty('build_summary', commit_summary)
    32673268            self.build.addStepsAfterCurrentStep([CommentOnBug(), RemoveFlagsOnPatch(), CloseBug()])
    3268             self.addURL('r{}'.format(svn_revision), self.url_for_revision(svn_revision))
     3269            self.addURL(identifier, self.url_for_identifier(identifier))
    32693270        else:
    32703271            retry_count = int(self.getProperty('retry_count', 0))
     
    32793280        return rc
    32803281
    3281     def url_for_revision(self, revision):
    3282         return 'https://commits.webkit.org/r{}'.format(revision)
    3283 
    3284     def comment_text_for_bug(self, svn_revision=None):
     3282    def url_for_revision_details(self, revision):
     3283        return '{}r{}/json'.format(COMMITS_INFO_URL, revision)
     3284
     3285    def url_for_identifier(self, identifier):
     3286        return '{}{}'.format(COMMITS_INFO_URL, identifier)
     3287
     3288    def identifier_for_revision(self, revision):
     3289        try:
     3290            response = requests.get(self.url_for_revision_details(revision), timeout=60)
     3291            if response and response.status_code == 200:
     3292                return response.json().get('identifier', 'r{}'.format(revision))
     3293            else:
     3294                print('Non-200 status code received from {}: {}'.format(COMMITS_INFO_URL, response.status_code))
     3295                print(response.text)
     3296        except Exception as e:
     3297            print(e)
     3298        return 'r{}'.format(revision)
     3299
     3300    def comment_text_for_bug(self, svn_revision=None, identifier=None):
    32853301        patch_id = self.getProperty('patch_id', '')
    32863302        if not svn_revision:
     
    32883304            comment += ' To retry, please set cq+ flag again.'
    32893305            return comment
    3290         comment = 'Committed r{}: <{}>'.format(svn_revision, self.url_for_revision(svn_revision))
     3306
     3307        identifier_str = identifier if identifier and '@' in identifier else '?'
     3308        comment = 'Committed r{} ({}): <{}>'.format(svn_revision, identifier_str, self.url_for_identifier(identifier))
    32913309        comment += '\n\nAll reviewed patches have been landed. Closing bug and clearing flags on attachment {}.'.format(patch_id)
    32923310        return comment
  • trunk/Tools/CISupport/ews-build/steps_unittest.py

    r275287 r275613  
    3535from buildbot.test.util.steps import BuildStepMixin
    3636from buildbot.util import identifiers as buildbot_identifiers
    37 from mock import call
     37from mock import call, patch
    3838from twisted.internet import defer, error, reactor
    3939from twisted.python import failure, log
     
    40904090        return self.tearDownBuildStep()
    40914091
    4092     def test_success(self):
    4093         self.setupStep(PushCommitToWebKitRepo())
    4094         self.setProperty('patch_id', '1234')
    4095         self.expectRemoteCommands(
    4096             ExpectShell(workdir='wkdir',
    4097                         timeout=300,
    4098                         logEnviron=False,
    4099                         command=['git', 'svn', 'dcommit', '--rmdir']) +
    4100             ExpectShell.log('stdio', stdout='Committed r256729') +
    4101             0,
    4102         )
    4103         self.expectOutcome(result=SUCCESS, state_string='Committed r256729')
    4104         with current_hostname(EWS_BUILD_HOSTNAME):
    4105             rc = self.runStep()
    4106         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.')
    4107         self.assertEqual(self.getProperty('build_finish_summary'), None)
    4108         return rc
     4092    def mock_commits_webkit_org(self, identifier=None):
     4093        class Response(object):
     4094            def __init__(self, data=None, status_code=200):
     4095                self.status_code = status_code
     4096                self.headers = {'Content-Type': 'text/json'}
     4097                self.text = json.dumps(data or {})
     4098
     4099            def json(self):
     4100                return json.loads(self.text)
     4101
     4102        return patch(
     4103            'requests.get',
     4104            lambda *args, **kwargs: Response(
     4105                data=dict(identifier=identifier) if identifier else dict(status='Not Found'),
     4106                status_code=200 if identifier else 404,
     4107            )
     4108        )
     4109
     4110    def test_success(self):
     4111        with self.mock_commits_webkit_org(identifier='220797@main'):
     4112            self.setupStep(PushCommitToWebKitRepo())
     4113            self.setProperty('patch_id', '1234')
     4114            self.expectRemoteCommands(
     4115                ExpectShell(workdir='wkdir',
     4116                            timeout=300,
     4117                            logEnviron=False,
     4118                            command=['git', 'svn', 'dcommit', '--rmdir']) +
     4119                ExpectShell.log('stdio', stdout='Committed r256729') +
     4120                0,
     4121            )
     4122            self.expectOutcome(result=SUCCESS, state_string='Committed 220797@main')
     4123            with current_hostname(EWS_BUILD_HOSTNAME):
     4124                rc = self.runStep()
     4125            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.')
     4126            self.assertEqual(self.getProperty('build_finish_summary'), None)
     4127            self.assertEqual(self.getProperty('build_summary'), 'Committed 220797@main')
     4128            return rc
     4129
     4130    def test_success_no_identifier(self):
     4131        with self.mock_commits_webkit_org():
     4132            self.setupStep(PushCommitToWebKitRepo())
     4133            self.setProperty('patch_id', '1234')
     4134            self.expectRemoteCommands(
     4135                ExpectShell(workdir='wkdir',
     4136                            timeout=300,
     4137                            logEnviron=False,
     4138                            command=['git', 'svn', 'dcommit', '--rmdir']) +
     4139                ExpectShell.log('stdio', stdout='Committed r256729') +
     4140                0,
     4141            )
     4142            self.expectOutcome(result=SUCCESS, state_string='Committed r256729')
     4143            with current_hostname(EWS_BUILD_HOSTNAME):
     4144                rc = self.runStep()
     4145            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.')
     4146            self.assertEqual(self.getProperty('build_finish_summary'), None)
     4147            self.assertEqual(self.getProperty('build_summary'), 'Committed r256729')
     4148            return rc
    41094149
    41104150    def test_failure_retry(self):
  • trunk/Tools/ChangeLog

    r275612 r275613  
     12021-04-07  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [build.webkit.org] Commit queue should post the identifier
     4        https://bugs.webkit.org/show_bug.cgi?id=223829
     5        <rdar://problem/75908321>
     6
     7        Reviewed by Aakash Jain.
     8
     9        * CISupport/ews-build/steps.py:
     10        (PushCommitToWebKitRepo.url_for_revision): Use COMMITS_INFO_URL.
     11        (PushCommitToWebKitRepo.url_for_identifier): Convert identifier
     12        to commits.webkit.org URL.
     13        (PushCommitToWebKitRepo.identifier_for_revision): Convert a commit
     14        revision to an identifier string.
     15        (PushCommitToWebKitRepo.comment_text_for_bug): Consult commits.webkit.org
     16        to convert revision to identifier.
     17        * CISupport/ews-build/steps_unittest.py:
     18
    1192021-04-07  Aakash Jain  <aakash_jain@apple.com>
    220
Note: See TracChangeset for help on using the changeset viewer.