Changeset 220715 in webkit


Ignore:
Timestamp:
Aug 14, 2017 2:14:10 PM (7 years ago)
Author:
dbates@webkit.org
Message:

webkit-patch: Passing --no-review should submit patch to EWS by default
https://bugs.webkit.org/show_bug.cgi?id=148899

Reviewed by David Kilzer.

Make "webkit-patch upload --no-review" and "webkit-patch post-commits --no-review" submit
the patch(es) for EWS analysis by default. Add a new optional command line argument, --no-ews,
to these commands to not submit a non-reviewed patch(es) for EWS analysis.

Frequently I want to post a draft of a patch without review to have the EWS bots process
it to catch build and test breakage before I clean it up and post it for formal review.
Currently this requires using "webkit-patch upload --no-review --open-bug" to upload the
patch and open the bug in Safari so that I can click the Submit for EWS analysis button.
We should teach "webkit-patch upload" and "webkit-patch post-commits" how to do this.

  • Scripts/webkitpy/common/net/bugzilla/bugzilla.py:

(Bugzilla._parse_attachment_id_from_add_patch_to_bug_response): Add helper function to
parse the attachment id from the response page after adding an attachment to the bug.
(Bugzilla.add_patch_to_bug): Modified to parse and return the attachment id from the
HTTP response after uploading the patch.

  • Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:

(MockBugzilla.add_patch_to_bug): Return a dummy attachment id for testing purposes.

  • Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:

(testparse_attachment_id_from_add_patch_to_bug_response): Added.

  • Scripts/webkitpy/tool/commands/upload.py:

(Upload): Add step SubmitToEWS to the list of steps when uploading a patch.
(PostCommits.init): Add --no-ews option to the list of applicable option flags for
this command.
(PostCommits.execute): Submit the patch to EWS, if applicable.

  • Scripts/webkitpy/tool/commands/upload_unittest.py:

(test_upload): Set options.ews to False as the upload command expects this option
to be specified.
(test_upload_with_no_review_and_ews): Added.

  • Scripts/webkitpy/tool/steps/init.py: Import module SubmitToEWS.
  • Scripts/webkitpy/tool/steps/options.py:

(Options): Added command line option --no-ews (defaults: False - submit to EWS).

  • Scripts/webkitpy/tool/steps/postdiff.py:

(PostDiff.options): Add --no-ews option to the list of applicable option flags for
this command.
(PostDiff.run): Submit the patch to EWS, if applicable.

  • Scripts/webkitpy/tool/steps/submittoews.py: Added.

(SubmitToEWS):
(SubmitToEWS.options): Return an empty array as we this step does not have any command line options.
(SubmitToEWS.run): Submit the specified attachment ids for EWS analysis.

Location:
trunk/Tools
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r220711 r220715  
     12017-08-14  Daniel Bates  <dabates@apple.com>
     2
     3        webkit-patch: Passing --no-review should submit patch to EWS by default
     4        https://bugs.webkit.org/show_bug.cgi?id=148899
     5
     6        Reviewed by David Kilzer.
     7
     8        Make "webkit-patch upload --no-review" and "webkit-patch post-commits --no-review" submit
     9        the patch(es) for EWS analysis by default. Add a new optional command line argument, --no-ews,
     10        to these commands to not submit a non-reviewed patch(es) for EWS analysis.
     11
     12        Frequently I want to post a draft of a patch without review to have the EWS bots process
     13        it to catch build and test breakage before I clean it up and post it for formal review.
     14        Currently this requires using "webkit-patch upload --no-review --open-bug" to upload the
     15        patch and open the bug in Safari so that I can click the Submit for EWS analysis button.
     16        We should teach "webkit-patch upload" and "webkit-patch post-commits" how to do this.
     17
     18        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
     19        (Bugzilla._parse_attachment_id_from_add_patch_to_bug_response): Add helper function to
     20        parse the attachment id from the response page after adding an attachment to the bug.
     21        (Bugzilla.add_patch_to_bug): Modified to parse and return the attachment id from the
     22        HTTP response after uploading the patch.
     23        * Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py:
     24        (MockBugzilla.add_patch_to_bug): Return a dummy attachment id for testing purposes.
     25        * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py:
     26        (test__parse_attachment_id_from_add_patch_to_bug_response): Added.
     27        * Scripts/webkitpy/tool/commands/upload.py:
     28        (Upload): Add step SubmitToEWS to the list of steps when uploading a patch.
     29        (PostCommits.__init__): Add --no-ews option to the list of applicable option flags for
     30        this command.
     31        (PostCommits.execute): Submit the patch to EWS, if applicable.
     32        * Scripts/webkitpy/tool/commands/upload_unittest.py:
     33        (test_upload): Set options.ews to False as the upload command expects this option
     34        to be specified.
     35        (test_upload_with_no_review_and_ews): Added.
     36        * Scripts/webkitpy/tool/steps/__init__.py: Import module SubmitToEWS.
     37        * Scripts/webkitpy/tool/steps/options.py:
     38        (Options): Added command line option --no-ews (defaults: False - submit to EWS).
     39        * Scripts/webkitpy/tool/steps/postdiff.py:
     40        (PostDiff.options): Add --no-ews option to the list of applicable option flags for
     41        this command.
     42        (PostDiff.run): Submit the patch to EWS, if applicable.
     43        * Scripts/webkitpy/tool/steps/submittoews.py: Added.
     44        (SubmitToEWS):
     45        (SubmitToEWS.options): Return an empty array as we this step does not have any command line options.
     46        (SubmitToEWS.run): Submit the specified attachment ids for EWS analysis.
     47
    1482017-08-14  Ryan Haddad  <ryanhaddad@apple.com>
    249
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py

    r216108 r220715  
    621621        self.browser.submit()
    622622
     623    @staticmethod
     624    def _parse_attachment_id_from_add_patch_to_bug_response(response_html):
     625        match = re.search('<title>Attachment (?P<attachment_id>\d+) added to Bug \d+</title>', response_html)
     626        if match:
     627            return match.group('attachment_id')
     628        _log.warning('Unable to parse attachment id')
     629        return None
     630
    623631    # FIXME: The arguments to this function should be simplified and then
    624632    # this should be merged into add_attachment_to_bug
     
    653661            _log.info(comment_text)
    654662            self.browser['comment'] = comment_text
    655         self.browser.submit()
     663        response = self.browser.submit()
     664        return self._parse_attachment_id_from_add_patch_to_bug_response(response.read())
    656665
    657666    # FIXME: There has to be a more concise way to write this method.
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_mock.py

    r174408 r220715  
    462462            _log.info(comment_text)
    463463            _log.info("-- End comment --")
     464        return '10001'
    464465
    465466    def add_cc_to_bug(self, bug_id, ccs):
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py

    r214238 r220715  
    342342        title_html_bugzilla_425 = "<title>Bug 101640 Submitted &ndash; Testing webkit-patch again</title>"
    343343        self.assertEqual(bugzilla._check_create_bug_response(title_html_bugzilla_425), '101640')
     344
     345    def test__parse_attachment_id_from_add_patch_to_bug_response(self):
     346        bugzilla = Bugzilla()
     347
     348        title_html = '<title>Attachment 317591 added to Bug 175247</title>'
     349        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), '317591')
     350
     351        title_html = '<title>Attachment 317591; malformed</title>'
     352        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), None)
     353
     354        title_html = '<title>Attachment A added to Bug 175247</title>'
     355        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), None)
    344356
    345357
  • trunk/Tools/Scripts/webkitpy/tool/commands/upload.py

    r220372 r220715  
    285285        steps.EnsureBugIsOpenAndAssigned,
    286286        steps.PostDiff,
     287        steps.SubmitToEWS,
    287288    ]
    288289    long_help = """upload uploads the current diff to bugs.webkit.org.
     
    322323            steps.Options.review,
    323324            steps.Options.request_commit,
     325            steps.Options.ews,
    324326        ]
    325327        Command.__init__(self, options=options, requires_local_commits=True)
     
    357359            description = options.description or commit_message.description(lstrip=True, strip_url=True)
    358360            comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id)
    359             tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
     361            attachment_id = tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
     362
     363            # We only need to submit --no-review patches to EWS as patches posted for review are
     364            # automatically submitted to EWS by EWSFeeder.
     365            if not options.review and options.ews:
     366                state = {'attachment_ids': [attachment_id]}
     367                steps.SubmitToEWS(tool, options).run(state)
    360368
    361369
  • trunk/Tools/Scripts/webkitpy/tool/commands/upload_unittest.py

    r220372 r220715  
    124124        options.request_commit = False
    125125        options.review = True
     126        options.submit_to_ews = False
    126127        options.sort_xcode_project = False
    127128        options.suggest_reviewers = False
     
    132133MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=True, mark_for_commit_queue=False, mark_for_landing=False
    133134MOCK: user.open_url: http://example.com/50000
     135"""
     136        self.assert_execute_outputs(Upload(), [50000], options=options, expected_logs=expected_logs)
     137
     138    def test_upload_with_no_review_and_ews(self):
     139        options = MockOptions()
     140        options.cc = None
     141        options.check_style = True
     142        options.check_style_filter = None
     143        options.comment = None
     144        options.description = 'MOCK description'
     145        options.non_interactive = False
     146        options.request_commit = False
     147        options.review = False
     148        options.ews = True
     149        options.sort_xcode_project = False
     150        options.suggest_reviewers = False
     151        expected_logs = """MOCK: user.open_url: file://...
     152Was that diff correct?
     153Obsoleting 2 old patches on bug 50000
     154MOCK reassign_bug: bug_id=50000, assignee=None
     155MOCK add_patch_to_bug: bug_id=50000, description=MOCK description, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=False
     156MOCK: user.open_url: http://example.com/50000
     157MOCK: submit_to_ews: 10001
    134158"""
    135159        self.assert_execute_outputs(Upload(), [50000], options=options, expected_logs=expected_logs)
  • trunk/Tools/Scripts/webkitpy/tool/steps/__init__.py

    r220372 r220715  
    6161from webkitpy.tool.steps.runtests import RunTests
    6262from webkitpy.tool.steps.sortxcodeprojectfiles import SortXcodeProjectFiles
     63from webkitpy.tool.steps.submittoews import SubmitToEWS
    6364from webkitpy.tool.steps.suggestreviewers import SuggestReviewers
    6465from webkitpy.tool.steps.update import Update
  • trunk/Tools/Scripts/webkitpy/tool/steps/options.py

    r220372 r220715  
    4646    description = make_option("-m", "--description", action="store", type="string", dest="description", help="Description string for the attachment")
    4747    email = make_option("--email", action="store", type="string", dest="email", help="Email address to use in ChangeLogs.")
     48    ews = make_option('--no-ews', action='store_false', dest='ews', default=True, help='Do not submit the patch to EWS for analysis (only applies when using --no-review).')
    4849    force_clean = make_option("--force-clean", action="store_true", dest="force_clean", default=False, help="Clean working directory before applying patches (removes local changes and commits)")
    4950    git_commit = make_option("-g", "--git-commit", action="store", dest="git_commit", help="Operate on a local commit. If a range, the commits are squashed into one. <ref>.... includes the working copy changes. UPSTREAM can be used for the upstream/tracking branch.")
  • trunk/Tools/Scripts/webkitpy/tool/steps/postdiff.py

    r202319 r220715  
    4040            Options.request_commit,
    4141            Options.open_bug,
     42            Options.ews,
    4243        ]
    4344
     
    4849        bug_id = state["bug_id"]
    4950
    50         self._tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)
     51        attachment_id = self._tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)
    5152        if self._options.open_bug:
    5253            self._tool.user.open_url(self._tool.bugs.bug_url_for_bug_id(bug_id))
     54
     55        # We only need to submit --no-review patches to EWS as patches posted for review are
     56        # automatically submitted to EWS by EWSFeeder.
     57        if not self._options.review and self._options.ews:
     58            state['attachment_ids'] = [attachment_id]
Note: See TracChangeset for help on using the changeset viewer.