Introduction to ReviewBoard

Review Board is a powerful web-based code review tool that offers developers an easy way to handle code reviews. It scales well from small projects to large companies and offers a variety of tools to take much of the stress and time out of the code review process. Review Board is written in the Python programming language and makes use of the Django web framework.

Installation
 
Install auxiliary packages if needed and all its dependencies:

$ sudo apt-get install python-setuptools
$ sudo apt-get install python-svn
$ sudo apt-get install python-subversion
$ sudo apt-get install apache2
$ sudo apt-get install libapache2-mod-python
$ sudo apt-get install git

Clone the ReviewBoard package and install it:

$ git clone git://github.com/reviewboard/reviewboard.git
$ cd reviewboard
$ sudo python setup.py develop

Also install post-review tool:

$ sudo easy_install -U RBTools

Set up the required site for the ReviewBoard (for Apache/SQLite backend, otherwise - see Creating Sites reference):

$ sudo rb-site install /var/www/reviews.example.com
$ sudo chown -R www-data /var/www/reviews.example.com/htdocs/media/uploaded  
$ sudo chown -R www-data /var/www/reviews.example.com/data
$ cd /etc/apache2/sites-available
 
$ sudo cp /var/www/reviews.example.com/conf/apache-modpython.conf reviews.example.com.conf
$ cd ../sites-enabled $ sudo ln -s ../sites-available/reviews.example.com.conf .

If necessary, change /etc/hosts to include reviews.example.com for testing purposes.

Restart apache and test the site:

$ sudo /etc/init.d/apache2 restart

You have to got this page:

Fig.1 Log In page

On that stage you can create necessary accounts to work with the system.

Setup the test environment

For testing purposes I install the SVN repo too (just an example, in the most cases I prefer DVCS systems):

$ cd  
$ svnadmin create test
$ sudo svnserve -d
$ svn co svn://localhost/$HOME/test svn_test
$ mkdir svn_test/trunk  
$ touch svn_test/trunk/README
$ cd svn_test
$ svn add trunk

Change ~/test/conf/svnserve.conf to allow required access (uncomment auth-access = write and password-db=passwd). Add required entries to passwd file (please notice that password should be in clear unencrypted text).
Commit changes:

$ svn ci -m"initial commit"

Setup the ReviewBoard system

Login as admin, go to Admin->Repositories->Add repository:

Fig.2 Change Repository page


As you can see, Review Board supports the following repo types:
  • Bazaar
  • CVS
  • Clear Case
  • Git
  • Mercurial
  • Perforce
  • Subversion
Also it can be integrated with the following bug trackers:
  • Bitbucket
  • Bugzilla
  • Github
  • Google Code
  • Redmine
  • Sourceforge
  • Trac
The initial functionality can be tested with the post-review tool in the source tree with uncommited changes:

$ post-review --username=username --bugs-closed=bug_number(s)

The command above creates a review request by user 'username', and it's also declared that this commit close certain bug(s).

Setup the Subversion hooks

Review Requests can be sent manually, but I'm always trying to automate the process as much as possible. So, let's set up the post-commit hooks. For that, we'll use the svn-hook-postcommit-review from the ReviewBoard sources (contrib/tools). Create a post-commit script in the hooks dir (~/test/hooks):

#!/bin/sh
REPOS="$1"
REV="$2"
/usr/bin/python /some/path/svn-hook-postcommit-review "$REPOS" "$REV" || exit 1


And make it executable:

$ chmod +x post-commit

Set up svn-hook-postcommit-review: POSTREVIEW_PATH (change it to /usr/local/bin or other dir where it's located), USERNAME and PASSWORD (change it to special user with “Can submit as user” Permission and “Can edit review request” Permission). If you've got some problem, you can set up DEBUG constant to True.

Set up svn properties of the checkout-ed sources for review board server:

$ svn propset reviewboard:url http://reviews.example.com .

Using the Review Board

Now all commits which contain "publish review" or similar messages (see the svn-hook-postcommit-review sources) will create review requests as well.

If add ticket number (and setup repository to use some bug-tracking system), the commit message should contain the required reference, for example, #. The link to the ticket will be created by Review Board automatically.

For example, for commit message like this:
 
Syntax has been fixed, publishreview #161

the result review request can look like this:


Fig. 3 Review Request page
Of course, it is not required to always use 'publish review' commands - the provided hook is just an example, it can be modified whatever you want (including creating requests for each commit). Regular expressions for getting corresponding bug/ticket number(s) are pretty ugly there, so probably you'll want to fix these (bug numbers are passed as parameter to --bugs-closed argument for post-review tool).

And of course, the main part - viewing diffs. Click the corresponding button 'View Diff':

Fig.4 Diff Viewer page
The reviews can add comments, approve or reject changes (for post-commit hook reject is mostly administrative measure rather than technical). General workflow is described on the corresponding Review Board page.

It's pretty difficult to cover all nuances of Review Board administration/usage, so all questions/remarks and suggestions are welcomed. But I hope you've got the whole idea and maybe it will be useful in your practice.

Comments

  1. Hi, Firstly thanks for the brief description mentioned.Its very beneficial for beginners.

    I am trying post-commit hook same way but no comments/diff getting published.

    -bash-3.2$ svn ci -m "zxcxvcxvcxvb zxcxcv zxcxcv. update review:162" Testing.txt
    Sending Testing.txt
    Transmitting file data .svn: Commit failed (details follow):
    svn: MERGE of '/repos/navision/trunk/Reports': 200 OK (http://svn)

    No diff on reviewboard. Can you suggest where going wrong?

    ReplyDelete
  2. post-commit hook is a usual Python script so you can debug it (like I suggested you can enable DEBUG there). My wild guess is that the script couldn't find the repository (because of missing propset reviewboard:url or some other reasons).

    The links in the article are obsolete, probably I have to update these :) But mostly the content is based on the official RB docs: http://www.reviewboard.org/docs/rbtools/dev/post-review/#automating-post-review

    ReplyDelete
  3. Thanks. I did try debug option. I am a newbie to python.
    Guess the error is here
    $>python /opt/repos/nav/hooks/svn-hook-postcommit-review /opt/repos/navision 6098-1
    $>
    import svn.fs
    ImportError: No module named svn.fs

    I install pysvn , but still got this error,not sure about svn-python how to install using swig, since i have installed svn1.6.11 on my redhat 64bit m/c.

    Can you share we anything else need to be added here?

    ReplyDelete
  4. I guess the Redhat package would be subversion-python, please try it. I don't have any Redhat distribution installed, so can't verify it, but AFAIK svn.fs is the Subversion binding to the Python (pysvn is a different package though), so if subversion-python won't work, you can try to search repos for the relevant bindings.

    ReplyDelete
  5. Hello Alexandre,'

    Thanks for the article.

    I am facing an issue while using Review-Board 2.0.6 and SVN. I want to have below mentioned Work-flow.

    1) Check-out the code from SVN
    2) Make some changes in the Code
    3) Create Review Request using RB-tools
    4) Perform the Review by Logging into Review-board
    5) Once the Review is done, Ship it!
    6) Admin-user of Review-Board Submits the Changes
    7) The Changes should be committed to SVN.

    I am able to successfully achieve steps 1-6, but the changes are not commited to SVN.i.e Step 7 is not working

    Please share some knowledge regarding how this can be achieve.


    Thanks

    Hardik Shah

    ReplyDelete
  6. Review Board doesn't automate the submit process, it should be done manually: https://www.reviewboard.org/docs/manual/dev/users/getting-started/workflow/ I guess there is a way to do it (RB can be extended), but unfortunately I don't have experience with that.

    ReplyDelete

Post a Comment

Popular posts from this blog

DIY: Business cards in LaTeX

Python vs JS vs PHP for embedded systems

Web application framework comparison by memory consumption