We've been talking a lot about improving our code at work and code reviews have come up several times, and we've even had a few informal code review but they always seem a bit tedious. I dug around a bit looking at online tools too help and discovered Review Board:
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.
What I liked about Review Board was it's integration with version control (in our case SVN, but many others are supported) which allows for reviews of small bits of code, pre-commit.
The work flow goes something like:
So pull up a chair, get comfortable and lets install Review Board...
Review Board is built using Python which I've never tinkered with. My initial attempt was to install it directly on my clunker WinXP box at work but that quickly spiraled into a mess and I promptly gave up. After a few posts on the Review Board mailing list I decided to instead install Review Board on Linux running on a VM. It was a bit of trial and error but I eventually got things working.
The official installation instructions are available on the Review Board site but I found a few areas where they were incomplete. One of the biggest issues I had was finding finding a suitable version of my VM tool (VirtualBox), Linux (Ubuntu) and Review Board that would all play nicely together. Here's what I ended up with:
First I downloaded and installed VirtualBox. I originally had downloaded VirtualBox 3.0 and Ubuntu 9.10, but had issues getting those running together and installing Review Board. Lots of errors! Think there may be some issues with the recently released VirtualBox 3.
VirtualBox 2.2.4 however installed fine, as did Ubuntu Server 8.10. I did a standard install, then manually installed the following with apt-get:
apache2 python2.5 build-essential python-dev python-setuptools patch memcached libmemcache-dev mysql
The first real issue I had was installing cmemcache. The installation instructions on the Review Board site were incorrect but after a bit of Googling I found "Installing cmemcache on Ubuntu" which worked:
wget http://gijsbert.org/downloads/cmemcache/cmemcache-0.91.tar.bz2 tar -xvf cmemcache-0.95.tar.bz2 cd cmemcache-0.95 sudo python setup.py install
This would not install at all on Ubuntu 9.10 for me - but on 8.10 I didn't have any issues.
Next I setup mySQL - you must have a database setup before doing the ReviewBoard install!
mysql -u root -p (enter password) create database reviewboard; GRANT ALL on reviewboard.* TO reviewboard@localhost IDENTIFIED BY 'password'
Since I wanted this to be accessible to everyone on our team I next had to figure out how to allow access to the VM from outside - turns out this is fairly easy with VirtualBox with a bit of port forwarding. Make sure your VM is NOT running and enter this into a Windows command line (my VM is named "reviewboard"):
VBoxManage setextradata reviewboard "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" 80 VBoxManage setextradata reviewboard "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" 80 VBoxManage setextradata reviewboard "VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" TCP
Note: the VM name is case sensitive! After I had set this up I went back and tweaked my VM name and suddenly everything stopped working.
Adjust your ports accordingly. I didn't have anything else running on this machine so I used the standard port 80.
Restart your VirtualBox and you should be able to open a browser on the Windows host and hit http://localhost and get the standard "It Works!" Apache screen.
Now we can proceed with the Review Board install - this is fairly easy:
$ easy_install ReviewBoard
This should chug along and complete without errors. If anything goes wrong doublecheck you installed everything mentioned above.
Next connect things to mySQL:
$ apt-get install python-mysqldb
The installation instructions at this point mention installing source control but I skipped this step as I already have an existing SVN repository setup elsewhere.
UpDate: Turns out you DO need to install the source control bits. When I started adjusting the settings I added a link to our repository but when I went to create a "New Review Request" I got an error. Someone on the mailing list had the same issue and mentioned installing the Python SVN module. Doh!
$ apt-get install subversion python-svn
I'm not sure if you actually need Subversion installed as well if you are going to connect to another repository but for now I'll install and will update this post if I find out it is not needed.
They also discuss installing PyLucene for searching but I skipped this step as well. The installation instructions mention "It can be complicated to install, and requires a working Java installation".
This is the basic Review Board install but before you can do anything you need to configure a 'site'.
This is relatively straight forward as well. First decide where you want your site to live. I decided to keep it simple and put it into a directory called "reviewboard"
$ rb-site install /var/www/reviewboard
Next you will be asked a series of questions which for the most part you can select the default.
When this completes you will have a new directory in /var/www called reviewboard. Next you need to set some permissions. The official instructions recommend:
$ chown -R www-data /var/www/reviewboard/htdocs/media/uploaded
I cheated and just did:
$ chmod 777 /var/www/reviewboard
You do NOT want to do this on any system that is publicly accessible!!!
The final step is to configure Apache. They provide you with some sample conf files. I did the following:
$ cd /etc/apache2/sites-available $ cp /var/www/reviewboard/conf/apache-modpython.conf reviewboard.conf $ cd ../sites-enabled $ ln -s ../sites-available/reviewboard.conf .
This copies the conf file and links to the proper Apache directories.
By default there is already a 'default' or '000-default' file in sites-enabled. Go ahead and delete this to save yourself some headaches.
Restart Apache and you should have a working Review Board installation!