Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
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. Canonical link: https://commits.webkit.org/47475@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@56181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
10 changed files
with
233 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -37,7 +37,7 @@ | ||
from webkitpy.outputcapture import OutputCapture | ||
|
||
|
||
class TestQueue(AbstractQueue): | ||
class TestQueue(AbstractPatchQueue): | ||
name = "test-queue" | ||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2009, Google Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following disclaimer | ||
# in the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of Google Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import os | ||
|
||
from webkitpy.commands.queues import AbstractQueue | ||
from webkitpy.irc.ircproxy import IRCProxy | ||
from webkitpy.webkit_logging import log | ||
|
||
|
||
class SheriffBot(AbstractQueue): | ||
name = "sheriff-bot" | ||
|
||
# AbstractQueue methods | ||
|
||
def begin_work_queue(self): | ||
AbstractQueue.begin_work_queue(self) | ||
self.tool.ensure_irc_connected() | ||
|
||
def work_item_log_path(self, svn_revision): | ||
return os.path.join("%s-logs" % self.name, "%s.log" % svn_revision) | ||
|
||
def next_work_item(self): | ||
# FIXME: Call methods that analyze the build bots. | ||
return None # FIXME: Should be an SVN revision number. | ||
|
||
def should_proceed_with_work_item(self, svn_revision): | ||
# Currently, we don't have any reasons not to proceed with work items. | ||
return True | ||
|
||
def process_work_item(self, svn_revision): | ||
message = "r%s appears to have broken the build." % svn_revision | ||
self.tool.irc().post(message) | ||
# FIXME: What if run_webkit_patch throws an exception? | ||
self.run_webkit_patch([ | ||
"create-rollout", | ||
"--force-clean", | ||
"--non-interactive", | ||
"--parent-command=%s" % self.name, | ||
# FIXME: We also need to CC the reviewer, committer, and contributor. | ||
"--cc=%s" % ",".join(self.watchers), | ||
svn_revision | ||
]) | ||
|
||
def handle_unexpected_error(self, svn_revision, message): | ||
log(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,43 @@ | ||
# Copyright (C) 2010 Google Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are | ||
# met: | ||
# | ||
# * Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# * Redistributions in binary form must reproduce the above | ||
# copyright notice, this list of conditions and the following disclaimer | ||
# in the documentation and/or other materials provided with the | ||
# distribution. | ||
# * Neither the name of Google Inc. nor the names of its | ||
# contributors may be used to endorse or promote products derived from | ||
# this software without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
import os | ||
|
||
from webkitpy.commands.queuestest import QueuesTest | ||
from webkitpy.commands.sheriffbot import SheriffBot | ||
from webkitpy.mock_bugzillatool import MockBugzillaTool | ||
|
||
class SheriffBotTest(QueuesTest): | ||
def test_sheriff_bot(self): | ||
expected_stderr = { | ||
"begin_work_queue": "CAUTION: sheriff-bot will discard all local changes in \"%s\"\nRunning WebKit sheriff-bot.\n" % os.getcwd(), | ||
"next_work_item": "", | ||
"process_work_item": "MOCK: irc.post: r29837 appears to have broken the build.\n", | ||
"handle_unexpected_error": "Mock error message\n" | ||
} | ||
self.assert_queue_outputs(SheriffBot(), work_item=29837, expected_stderr=expected_stderr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters