> I'm currently writing a Review Board extension (ReviewBot) which aims to
> automate execution of static analysis tools on proposed code.
Great.
(RB below == ReviewBoard, not ReviewBot!)
> ** Ship-it if no problems
As I'm sure you know, review workflows differ -- for example, some
workflows allow commit when there's at least one ship-it. In that
workflow you probably prefer that the bot doesn't give a ship-it
(otherwise, it's hard to prioritize your effort as a reviewer because you
can't see quickly which reviews have a ship-it already and which don't).
It would be nice if ReviewBot were to be as flexible as RB itself about
that kind of variation.
While an arbitrary hook that can perform any action is completely
flexible, no matter how simple it is to write a plugin, there's always
some annoying work to implement the hook and adapt it to your PEP8 tool
(or whatever it is the plugin does). Nothing beats just installing
somebody else's plugin and having it just work.
So, another way to preserve that flexibility, which I think is better
because it's more convenient for the various kinds of RB user involved,
would be for plugins to stay out of doing concrete actions like adding
concrete RB comments, adding issues, adding a ship-it, etc. This is in
contrast to your web-hook idea as you first stated it, where the hook gets
to make whatever RB API calls it likes. Having the plugins not be
responsible for those actions does also have the advantage that it would
decouple the plugins from RB. In principle, that would mean users of
other review tools (notably gerrit) could contribute plugins that would
work on RB (as well as on gerrit) -- your web hook idea fits well with
that hope.
This makes life easy for people deploying RB, because they can just
install the PEP8 plugin somebody else wrote, and start off by leaving
ReviewBot set to its default behaviour for what actions to perform.
Maybe they then have five minutes later to change some ReviewBot
configuration to set a few flags like "Don't give a ship-it".
It makes life easy for plugin authors because they get an API to code to
that's much simpler than the full RB API (see below). And maybe a gerrit
user already wrote the plugin they want, so they have nothing to do (maybe
wishful thinking, but seems there's scope for a little bit of cooperation
here).
Probably 90% of workflows could be dealt with using built-in ReviewBot
code plus a couple of configuration options (add a ship it or not, add
issues or not), but there's always the option of adding another hook in
future to customize the actions arbitrarily.
> Mike Conley and I discussed the possibilities of a WebHooks extension to
> solve this problem. When a review is published, a web request could be
> fired off to ReviewBot on another server, which could run each tool, and
> then use the API to post the reviews.
Sounds easy (to use). What arguments would the hook take?
Per my points above re flexibility to workflow and ease of use: how about,
rather than suggesting that plugins use the full RB API, just exposing a
very simple ReviewBot API to the plugins, which allows only for submitting
a set of abstract comments. By "abstract", I just mean not actual RB
comments, but rather along the lines of (suitably REST-encoded) tuples
(file path, start line number, end line number, severity). ReviewBot
itself is then responsible for turning those into concrete RB comments,
issues, ship-its, etc.
(Side issue: With the severity field there I'm thinking it might be useful
to allow for indicating potential problems where the tool can't be sure
that the problem is real.)
Of course there's nothing here to stop the plugins doing RB API calls: I'm
just suggesting that providing a simpler alternative is easier for both
plugin authors and RB deployers.
> Another option Christian Hammond mentioned to me was using distributed task
> queues (See python Celery: http://celeryproject.org/). This is something
> being looked in to already for distributing the diff processing, and could
> also be applied to ReviewBot.
Perhaps that solves some problems for reviewboard (fair enough). It
doesn't sound like it solves a problem for ReviewBot plugin authors or
people deploying RB?
Oops, that was much longer than I intended, sorry!
John
Hi!
I am trying to scratch my specific itch - namely, I'd like to have the
report from Yasca (www.yasca.org, sample:
http://embraceunity.com/wp-content/uploads/2010/09/Yasca-Report-20100911054536.html) included in ReviewBoard. Your approach seems to be more generic one and from what I see you've managed to predict more hurdles than I've been aware of.
Please let me know if I can be of any further help. Your idea seems to
be a perfect resolution to my problem :-).
Regards,
Marcin
== Concurrent Review ==When the Extension sends a message to the Broker, it includes a username and password; the worker uses these credentials when communicating with the Web API. Review Board only allows a single review draft per user, per review request (This is for good reasons). This poses problems when a review request is updated before the initial Review Bot reviews are complete. Review Bot will begin reviewing the new code, and the reviews will combine. This also causes the second worker to fail mid review. Additionally, if we make it so each analysis tool is executed in parallel, we will have the same issue.What I propose to solve this problem is to have the Extension actually commit completed reviews. A worker should construct a review without repeatedly hitting the Web API, and then POST this to the Extension in a single request. The Extension will then handle actually committing the review to the database.Can you think of any shortcomings to this solution?
=== elegant ===Each tool to be executed should be a distinct message to the Broker. Queues are actually dynamically created in the Broker when either a message is generated for the queue, or a worker listens on the queue. These queues will correspond to a specific analysis tool. When workers are started, they should be set to listen to all queues which correspond to their installed tools.
=== common ===Discovering all of the installed tools could be accomplished by adding an 'info' task to the Review Bot workers. Instead of executing a review, this task could just inform the Review Board instance which tools are installed on its server. A message to execute this task could be broadcast to all queues, and the Extension could display these results in the admin panel. I still think configuring which tools are executed automatically should be manually configured, but this could help populate the admin interface with helpful information.Can you think of a better way to handle this stuff? Could either method be modified to solve more of the problems I mentioned? Have I overlooked something? What method do you like best?
== Analysis Tool API ==The current API I've set up for each analysis tool to perform it's review is very basic. Right now the tool can set the top body and bottom body of the review manually, and comment using a simple `comment(msg, line)` method. What API would you like to see?
Also, each entry point is just a simple function, which isn't given much help in executing it's analysis. I'd like to convert the entry points over to a base class each tool can inherit from, which could provide some common operations, and helpful methods. Imagining you are writing a plug-in for a new analysis tool, what would you like to see from this base class?
== Configuration ==Currently all configuration for Review Bot takes place in the Extension. This includes settings the tools should follow when commenting/opening issues. I really like this design as it makes administration very simple, and allows the Broker and workers to be shared between many Review Board instances all with distinct settings.Something I can't seem to solve is how I can allow tool specific configuration in this environment. E.g. A tool provides a severity with it's warnings, how can a cutoff point be set for when an issue is raised in Review Board? Every tool is slightly different, and some tools may require some very unique configuration, how can I handle this? Is this even worth handling?
I can see the pros of this, but what things specifically does it fail to address?
I've always regretted that we've used "comment" for diff comments. Seems fine at first until you start supporting other formats. I'd rename to "diff_comment." Who knows, maybe you'll operate on file attachments of certain types later.
Is it worth having a flag for an issue? Maybe some things are issues and some are just suggestions?
You can probably keep this side of it expansive though by not hard-coding methods, and instead mapping a name from the message to something like "handle_<name>" and dynamically invoking it.
Does the Review Board side of things know anything about the tools? If so, each tool could provide a Form class we can render as part of the settings page. Kind of like what we do for auth backends (though in that case, we only show one at a time, but they're all in the HTML).
I can see the pros of this, but what things specifically does it fail to address?The main issue I'm having is figuring out how I can only hit the RB server once for the patched files. I don't know if it's something I should even be worrying about though.
I've always regretted that we've used "comment" for diff comments. Seems fine at first until you start supporting other formats. I'd rename to "diff_comment." Who knows, maybe you'll operate on file attachments of certain types later.
Good point. I've had the idea of Review Bot reviewing parts of the request other than the code in the back of my mind, and this is a distinction I hadn't thought of.Is it worth having a flag for an issue? Maybe some things are issues and some are just suggestions?
To handle the raising of issues, I've imaged a global configuration for each Review Board instance which looks like this:
- Modified Code: [No Comment || Comment || Comment & Issue]
- Unmodified Code: [No Comment || Comment || Comment & Issue]
- Ship It?: [ No || Yes If no issues on modified code || Yes if no issues]
I think this will be treated as a suggestion though; I would like to give the tool the option to ignore the settings and decide themselves, since this scheme may not make sense for some tools (especially with a wide range of severities). I thought this could be done by providing two interfaces to the tool:
- A lower-level commenting interface where they specify if the comment should be an Issue.
- A higher-level interface where they just provide the comment/line and it decides the issue state according to the settings, and then calls the lower-level interface.
I know this can't handle every case out there, and per tool configuration is really what is needed, but I think this is a good start.You can probably keep this side of it expansive though by not hard-coding methods, and instead mapping a name from the message to something like "handle_<name>" and dynamically invoking it.
I'm not sure I fully understand what you are getting at here. Are you proposing a "handle_<name>" method for each piece of the request (file attachment, code file, etc.)? Do you think you could elaborate a little more for me?
Does the Review Board side of things know anything about the tools? If so, each tool could provide a Form class we can render as part of the settings page. Kind of like what we do for auth backends (though in that case, we only show one at a time, but they're all in the HTML).The Review Board extension knows nothing about the tools at the moment. I've kept the python packages separate so the web server doesn't get forced to install a bunch of analysis tools. Here are a few ideas I have for dealing with the configuration of each tool:
- Let the plugin author deal with it. If they want special configuration, they need to allow something on the worker side.
- Allow plugin authors to write their own RB extension, which will plugin to the Review Bot extension and provide the configuration. This would give them a lot more control, but would require quite a bit of extra work. Also, if many tools take advantage of this, the RB extension admin panel will become bloated.
- Allow plugin authors to write plugin for the RB extension. This would be distinct from writing a RB extension in that they would just provide a special entry point my extension knows about.
- Return some sort of configuration schema with the "info" request I've mentioned before. This could be optionally defined in the tool's class, and returned with the other information about the tool.
I definitely like 4 the best for a number of reasons. All information about the tool is kept in a single plugin for Review Bot and everything is dynamic based on what tools are installed in the worker pool. I have no idea what format this schema should take, or how powerful it should be. Any ideas here?
I have noticed the following:the 'bot' gave a 'Ship it' even when issues were raised (I ticked the Ship It with no issues'Also I then updated the review to change the reviewer - and reviewbot gave another 'Ship it' but did not rerun the output.I would expect it to not rerun as the diff was not updated.