Changeset 56181 in webkit


Ignore:
Timestamp:
Mar 18, 2010 12:49:36 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-18 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

First cut at SheriffBot
https://bugs.webkit.org/show_bug.cgi?id=36253

This patch contains a first attempt at writing a sheriff bot.
Currently, we're missing the logic that actually finds the SVN revision
numbers to complain about, but once we have that, we'll have the rest
of the infrustructure to ping IRC and to file bugs.

There's a lot to fill in for the SheriffBot, but this patch give us the
framework in which to do it.

This patch required a bit of refactoring of AbstractQueue because
SheriffBot is the first bot that doesn't process patches (it processes
SVN revisions). Accordingly, I've factored out AbstractPatchQueue to
hold the parts of AbstractQueue that are specific to dealing with
patches. Some of the choices here might not be obvious yet, but we can
tweak them as our needs become clearer.

  • Scripts/webkitpy/commands/queues.py:
  • Scripts/webkitpy/commands/queues_unittest.py:
  • Scripts/webkitpy/commands/sheriffbot.py: Added.
  • Scripts/webkitpy/commands/sheriffbot_unittest.py: Added.
  • Scripts/webkitpy/mock_bugzillatool.py:

Added a MockIRC object to the mock tool.

  • Scripts/webkitpy/multicommandtool.py:

Added a finalize method so the tool can disconnect from IRC
cleanly instead of just droping the socket.

  • Scripts/webkitpy/multicommandtool_unittest.py:
  • Scripts/webkitpy/patch/patcher.py:

Added support for talking to IRC.

  • Scripts/webkitpy/unittests.py:

We should add a commands/unittests.py file at some point to make
the commands module more self-contained.

Location:
trunk/WebKitTools
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r56179 r56181  
     12010-03-18  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        First cut at SheriffBot
     6        https://bugs.webkit.org/show_bug.cgi?id=36253
     7
     8        This patch contains a first attempt at writing a sheriff bot.
     9        Currently, we're missing the logic that actually finds the SVN revision
     10        numbers to complain about, but once we have that, we'll have the rest
     11        of the infrustructure to ping IRC and to file bugs.
     12
     13        There's a lot to fill in for the SheriffBot, but this patch give us the
     14        framework in which to do it.
     15
     16        This patch required a bit of refactoring of AbstractQueue because
     17        SheriffBot is the first bot that doesn't process patches (it processes
     18        SVN revisions).  Accordingly, I've factored out AbstractPatchQueue to
     19        hold the parts of AbstractQueue that are specific to dealing with
     20        patches.  Some of the choices here might not be obvious yet, but we can
     21        tweak them as our needs become clearer.
     22
     23        * Scripts/webkitpy/commands/queues.py:
     24        * Scripts/webkitpy/commands/queues_unittest.py:
     25        * Scripts/webkitpy/commands/sheriffbot.py: Added.
     26        * Scripts/webkitpy/commands/sheriffbot_unittest.py: Added.
     27        * Scripts/webkitpy/mock_bugzillatool.py:
     28            Added a MockIRC object to the mock tool.
     29        * Scripts/webkitpy/multicommandtool.py:
     30            Added a finalize method so the tool can disconnect from IRC
     31            cleanly instead of just droping the socket.
     32        * Scripts/webkitpy/multicommandtool_unittest.py:
     33        * Scripts/webkitpy/patch/patcher.py:
     34            Added support for talking to IRC.
     35        * Scripts/webkitpy/unittests.py:
     36            We should add a commands/unittests.py file at some point to make
     37            the commands module more self-contained.
     38
    1392010-03-18  Antti Koivisto  <koivisto@iki.fi>
    240
  • trunk/WebKitTools/Scripts/webkitpy/commands/queues.py

    r56145 r56181  
    7070            log("Failed to CC watchers.")
    7171
    72     def _update_status(self, message, patch=None, results_file=None):
    73         self.tool.status_server.update_status(self.name, message, patch, results_file)
    74 
    75     def _did_pass(self, patch):
    76         self._update_status(self._pass_status, patch)
    77 
    78     def _did_fail(self, patch):
    79         self._update_status(self._fail_status, patch)
    80 
    81     def _did_error(self, patch, reason):
    82         message = "%s: %s" % (self._error_status, reason)
    83         self._update_status(message, patch)
     72    def run_webkit_patch(self, args):
     73        webkit_patch_args = [self.tool.path()]
     74        # FIXME: This is a hack, we should have a more general way to pass global options.
     75        webkit_patch_args += ["--status-host=%s" % self.tool.status_server.host]
     76        webkit_patch_args += map(str, args)
     77        self.tool.executive.run_and_throw_if_fail(webkit_patch_args)
     78
     79    # QueueEngineDelegate methods
    8480
    8581    def queue_log_path(self):
    8682        return "%s.log" % self.name
    8783
    88     def work_item_log_path(self, patch):
    89         return os.path.join("%s-logs" % self.name, "%s.log" % patch.bug_id())
     84    def work_item_log_path(self, work_item):
     85        raise NotImplementedError, "subclasses must implement"
    9086
    9187    def begin_work_queue(self):
     
    113109        raise NotImplementedError, "subclasses must implement"
    114110
    115     def run_webkit_patch(self, args):
    116         webkit_patch_args = [self.tool.path()]
    117         # FIXME: This is a hack, we should have a more general way to pass global options.
    118         webkit_patch_args += ["--status-host=%s" % self.tool.status_server.host]
    119         webkit_patch_args += map(str, args)
    120         self.tool.executive.run_and_throw_if_fail(webkit_patch_args)
    121 
    122     def log_progress(self, patch_ids):
    123         log("%s in %s [%s]" % (pluralize("patch", len(patch_ids)), self.name, ", ".join(map(str, patch_ids))))
     111    # Command methods
    124112
    125113    def execute(self, options, args, tool, engine=QueueEngine):
     
    137125
    138126
    139 class CommitQueue(AbstractQueue, StepSequenceErrorHandler):
     127class AbstractPatchQueue(AbstractQueue):
     128    def _update_status(self, message, patch=None, results_file=None):
     129        self.tool.status_server.update_status(self.name, message, patch, results_file)
     130
     131    def _did_pass(self, patch):
     132        self._update_status(self._pass_status, patch)
     133
     134    def _did_fail(self, patch):
     135        self._update_status(self._fail_status, patch)
     136
     137    def _did_error(self, patch, reason):
     138        message = "%s: %s" % (self._error_status, reason)
     139        self._update_status(message, patch)
     140
     141    def work_item_log_path(self, patch):
     142        return os.path.join("%s-logs" % self.name, "%s.log" % patch.bug_id())
     143
     144    def log_progress(self, patch_ids):
     145        log("%s in %s [%s]" % (pluralize("patch", len(patch_ids)), self.name, ", ".join(map(str, patch_ids))))
     146
     147
     148class CommitQueue(AbstractPatchQueue, StepSequenceErrorHandler):
    140149    name = "commit-queue"
    141150    def __init__(self):
    142         AbstractQueue.__init__(self)
    143 
    144     # AbstractQueue methods
     151        AbstractPatchQueue.__init__(self)
     152
     153    # AbstractPatchQueue methods
    145154
    146155    def begin_work_queue(self):
    147         AbstractQueue.begin_work_queue(self)
     156        AbstractPatchQueue.begin_work_queue(self)
    148157        self.committer_validator = CommitterValidator(self.tool.bugs)
    149158
     
    241250
    242251
    243 class AbstractReviewQueue(AbstractQueue, PersistentPatchCollectionDelegate, StepSequenceErrorHandler):
     252class AbstractReviewQueue(AbstractPatchQueue, PersistentPatchCollectionDelegate, StepSequenceErrorHandler):
    244253    def __init__(self, options=None):
    245         AbstractQueue.__init__(self, options)
     254        AbstractPatchQueue.__init__(self, options)
    246255
    247256    def _review_patch(self, patch):
     
    262271        return status == "Pass" or status == "Fail" or status.startswith("Error:")
    263272
    264     # AbstractQueue methods
     273    # AbstractPatchQueue methods
    265274
    266275    def begin_work_queue(self):
    267         AbstractQueue.begin_work_queue(self)
     276        AbstractPatchQueue.begin_work_queue(self)
    268277        self._patches = PersistentPatchCollection(self)
    269278
  • trunk/WebKitTools/Scripts/webkitpy/commands/queues_unittest.py

    r56137 r56181  
    3838
    3939
    40 class TestQueue(AbstractQueue):
     40class TestQueue(AbstractPatchQueue):
    4141    name = "test-queue"
    4242
  • trunk/WebKitTools/Scripts/webkitpy/mock_bugzillatool.py

    r56151 r56181  
    374374
    375375
     376class MockIRC(object):
     377
     378    def post(self, message):
     379        log("MOCK: irc.post: %s" % message)
     380
     381    def disconnect(self):
     382        log("MOCK: irc.disconnect")
     383
     384
    376385class MockStatusServer(object):
    377386
     
    392401        self.buildbot = MockBuildBot()
    393402        self.executive = Mock()
     403        self._irc = None
    394404        self.user = MockUser()
    395405        self._scm = MockSCM()
     
    399409        return self._scm
    400410
     411    def ensure_irc_connected(self):
     412        if not self._irc:
     413            self._irc = MockIRC()
     414
     415    def irc(self):
     416        return self._irc
     417
    401418    def path(self):
    402419        return "echo"
  • trunk/WebKitTools/Scripts/webkitpy/multicommandtool.py

    r53066 r56181  
    264264        raise NotImplementedError, "subclasses must implement"
    265265
     266    def command_completed(self):
     267        pass
     268
    266269    def should_show_in_main_help(self, command):
    267270        return command.show_in_main_help
     
    297300            return 0 # FIXME: Should this really be 0?
    298301
    299         return command.check_arguments_and_execute(options, args, self)
     302        result = command.check_arguments_and_execute(options, args, self)
     303        self.command_completed()
     304        return result
  • trunk/WebKitTools/Scripts/webkitpy/multicommandtool_unittest.py

    r52725 r56181  
    7373        MultiCommandTool.__init__(self, name="trivial-tool", commands=commands)
    7474
    75     def path():
     75    def path(self):
    7676        return __file__
    7777
  • trunk/WebKitTools/Scripts/webkitpy/patch/patcher.py

    r56178 r56181  
    6262        self.buildbot = BuildBot()
    6363        self.executive = Executive()
     64        self._irc = None
    6465        self.user = User()
    6566        self._scm = None
     
    8283        return self._scm
    8384
     85    # FIXME: Add a parameter for nickname?
     86    def ensure_irc_connected(self):
     87        if not self._irc:
     88            self._irc = IRCProxy()
     89
     90    def irc(self):
     91        # We don't automatically construct IRCProxy here because constructing
     92        # IRCProxy actually connects to IRC.  We want clients to explicitly
     93        # connect to IRC.
     94        return self._irc
     95
    8496    def path(self):
    8597        return self._path
     98
     99    def command_completed(self):
     100        if self._irc:
     101            self._irc.disconnect()
    86102
    87103    def should_show_in_main_help(self, command):
  • trunk/WebKitTools/Scripts/webkitpy/unittests.py

    r56125 r56181  
    4141from webkitpy.commands.queries_unittest import *
    4242from webkitpy.commands.queues_unittest import *
     43from webkitpy.commands.sheriffbot_unittest import *
    4344from webkitpy.committers_unittest import *
    4445from webkitpy.credentials_unittest import *
Note: See TracChangeset for help on using the changeset viewer.