Wednesday, January 22, 2014

REVIEWBOARD INSTALLATION IN WINDOWS

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. For too long, code reviews have been too much of a chore. This is largely due to the lack of quality tools available, leaving developers to resort to e-mail and bug tracker-based solutions.
 


We've seen a lot of time and energy wasted doing code reviews both in open source projects and at companies. In both cases, code reviews were typically done over e-mail. A significant amount of time was spent in forming review requests, switching between the diff and the e-mail, and trying to understand what parts of the code the reviewer was referring to.

Reviewboard has huge supporters online and it has got decent documentation which guides the users to install it in their corporate environment. In spite of this, I would say that installing reviewboard is fairly tricky as we have to bring many third party applications to work together.

In this document, we’ll see how to install reviewboard and post reviews using svn.
Most of the documentation has been taken from the reviewboard site itself.

I had great difficulty finding the compatible versions for installing in windows. So, I have added the package names as well.


Review Board supports the following database servers:



  • MySQL v5.0.31 or newer – We used Mysql
  • PostgreSQL
  • Sqlite v3
And the following web servers:
  • Apache + mod_python or fastcgi – We used Apache
  • lighttpd + fastcgi
  

Python Support:



You can install Python by running the latest Python 2.5 Installer for Windows Or we can also use Python 2.7 Installer. You’ll then need to run the latest Python Setuptools Installer.Once Python and Setuptools are installed, you’ll need to add a couple directories to your system path.
  • Open Start ? Control Panel and navigate to the System icon.
  • Click on the Advanced tab.
  • Click Environment Variables.
  • Find PATH in System variables and click Edit.
  • Add ;C:\Python25;C:\Python25\Scripts (substitute your Python directory if it’s not C:\Python25) to the end of the list.


Installing patch

You can download the installer for GNU patch.exe. Follow the instructions in the installer and make sure patch.exe in your PATH.
 



Installing memcached

Memcached is a high-performance caching server used by Review Board. While optional, it’s strongly recommended in order to have a fast, responsive server. Along with memcached, we need the python-memcached Python bindings.
  •  Download memcached for Windows.
  •  Unzip this to the directory you want to keep memcached in (for example, C:\memcached).
  •  If running Vista, you’ll need to set this to run as an administrator. Right-click on memcached.exe and click Properties. Click the Compatibility tab and then check Run this program as an administrator.
  •  Install the service from the command line by typing the following from the memcached directory:
    •  memcached.exe -d install
  •  Start the server through the Microsoft Management Console.
  •  Install python-memcached by typing the following:
    •  easy_install python-memcached


 Installing Python Imaging Library  



  • Review Board requires the Python Imaging Library (PIL). To install this, download the latest version that matches your Python version at the PIL website.
  • Installing PyCrypto
  • Review Board requires PyCrypto for SSH repository support. To install this, download the latest version that matches your Python version at the PyCrypto Win32 downloads page.
  • Installing Review Board
  • To install Review Board and its required dependencies (Djblets, Django-Evolution, Django, and paramiko, flup) in one go, type:
    •  easy_install ReviewBoard
  •  This will automatically download and install the latest stable release of Review Board and the required versions of its core dependencies.
  • Installing Database Bindings
    • · To install MYSQL, type:
    •  $ easy_install mysql-python
  • Subversion
  • Installing Amazon S3 Support (optional)
    •  $ easy_install django-storages
  • Installing Development Tools (optional)
If you plan to work on Review Board’s source code, there are a few additional packages you’ll need to install:
o nose
o Sphinx

You can install these in one go by typing:
  •  $ easy_install nose Sphinx

Once you’ve finished getting Review Board itself installed, you’ll want to create your site.


CREATING REVIEWBOARD SITE

Once Review Board is installed, a site must be created. Each site maps to a domain, subdomain, or directory installation.To create a site, you will use the rb-site install command.You will need to decide on a place to install the site. In the examples here, we will use /var/www/reviews.example.com. The directory should not exist yet. rb-site will create it.

C:\Documents and Settings\RB-test>rb-site install "C:\Program Files\reviewboard

 
* Welcome to the Review Board site installation wizard
This will prepare a Review Board site installation in:
C:\Program Files\reviewboard
We need to know a few things before we can prepare your site for
installation. This will only take a few minutes.
 

* Make sure you have the modules you need
Depending on your installation, you may need certain Python
modules and servers that are missing.
If you need support for any of the following, you will need to
install the necessary modules and restart the install.
Databases (optional):

* PostgreSQL (psycopg2)
* What's the host name for this site?

This should be the fully-qualified host name without the
http://,
port or path.


Domain Name: reviewboard.test.com
 

* What URL path points to Review Board?
Typically, Review Board exists at the root of a URL. For example,
  
http://reviews.example.com/. In this case, you would specify "/".
However, if you want to listen to, say,
http://example.com/reviews/, you can specify "/reviews/".
Note that this is the path relative to the domain and should not
include the domain name.

The default is /

Root Path [/]:
 

* What URL will point to the media files?
While most installations distribute media files on the same server
as the rest of Review Board, some custom installs may instead have
a separate server for this purpose.

The default is media/

Media URL [media/]:
 

* What database type will you be using?
You can type either the name or the number from the list below.

(1) mysql
(2) sqlite3 (not supported for production use)

Database Type: mysql

* What database name should Review Board use?
NOTE: You need to create this database and grant user modification
rights before continuing. See your database documentation for more
information.

The default is reviewboard

Database Name [reviewboard]:

* What is the database server's address?
This should be specified in hostname:port form. The port is
optional if you're using a standard port for the database type.

The default is localhost
Database Server [localhost]:

* What is the login and password for this database?
This must be a user that has table creation and modification
rights on the database you already specified.

Database Username: root
Database Password:

* What cache mechanism should be used?
memcached is strongly recommended. Use it unless you have a good
reason not to.

You can type either the name or the number from the list below.

(1) memcached (recommended)
(2) file

Cache Type: memcached

* What memcached connection string should be used?
This is generally in the format of memcached://hostname:port/

The default is memcached://localhost:11211/

Memcache Server [memcached://localhost:11211/]:

 
* What web server will you be using?

You can type either the name or the number from the list below.

(1) apache
(2) lighttpd

Web Server: apache

* What Python loader module will you be using?
Based on our experiences, we recommend using wsgi with Review
Board.

You can type either the name or the number from the list below.

(1) wsgi (recommended)
(2) fastcgi
(3) modpython (no longer supported)

Python Loader: wsgi
 

* Create an administrator account

To configure Review Board, you'll need an administrator account.
It is advised to have one administrator and then use that account
to grant administrator permissions to your personal user account.
If you plan to use NIS or LDAP, use an account name other than
your NIS/LDAP account so as to prevent conflicts.

The default is admin

Username [admin]: test5

Password:

E-Mail Address: abc@example.com

* Installing the site...
Building site directories ... OK
Building site configuration files ... OK
Creating database ... Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.
OK
Performing migrations ... No evolution required.
OK
Creating administrator account ... OK
Saving site settings ... OK  

* The site has been installed

The site has been installed in C:\Program Files\rapitest.test.com

Sample configuration files for web servers and cron are available
in the conf/ directory.
You need to modify the ownership of the following directories and
their contents to be owned by the web server:

* C:\Program Files\rapitest.test.com\htdocs\media\uploaded
* C:\Program Files\rapitest.test.com\data
For more information, visit:

http://www.reviewboard.org/docs/manual/dev/admin/sites/creating-
sites/

Login to the reviewboard Now and you can create other users as well.

T
ROUBLESHOOTING GUIDELINES
  • Check the errors.log in apache logs to see the following error messages:
    • [modwsgi]: load module mod_wsgi.so failed on windows
    • Solution: Copy the mod_wsgi.so from the current directory to C:\Program Files\Apache Software Foundation\Apache2.2\modules
  • InvalidCacheBackendError: Memcached cache backend requires either the 'memcache' or 'cmemcache' library
    • Solution: 
      • Step 1: Copy paste the following code in memcached.py:
 class CacheClass(BaseMemcachedCache):
 def __init__(self, server, params):
 try:
 import cmemcache as memcache
 import warnings
 warnings.warn(
 "Support for the 'cmemcache' library has been deprecated. Please use python-memcached or pyblimc instead.",
 DeprecationWarning
 )
 except ImportError:
 try:
 import memcache
 except:
 raise InvalidCacheBackendError(
 "Memcached cache backend requires either the 'memcache' or 'cmemcache' library"
 )
 super(CacheClass, self).__init__(server, params,
 library=memcache,
 value_not_found_exception=ValueError)
 class MemcachedCache(BaseMemcachedCache):
 "An implementation of a cache binding using python-memcached"
 def __init__(self, server, params):
 try:
 import cmemcache as memcache
 except ImportError:
 try:
 import cmemcached as memcache
 except ImportError:
 try:
 import memcache
 except ImportError:
 raise InvalidCacheBackendError(
 "Memcached cache backend requires either the 'memcache' or 'cmemcache' library"
 )
 super(MemcachedCache, self).__init__(server, params,
 library=memcache,
 value_not_found_exception=ValueError)
 


      •  Step 2: easy_install python-memcached
        •  This might lead to few more errors. Run the following steps to overcome them.
          •  easy_install MySQL-python
          •  easy_install recaptcha-client
          •  easy_install paramiko
          •  easy_install pytz
          •  Install the pycrypto-2.2.win32-py2.7.exe
  •  Install MinGW.exe and Add the path where dlltool.exe is located: C:\MinGW\mingw32\bin; to system variables. (Go to control panel-> system-> Advanced -> Environmental Variables -> System Variables -> PATH. Don't forget to add semicolon 

LIST OF PACKAGES USED  

1. ActivePython-2.7.2.5-win32-x86.msi
 2. apache_1.3.17-win32-src.msi
 3. diffutils-2.8.7-1.exe
 4. GetGnuWin32-0.6.3.exe
 5. httpd-2.2.22-win32-x86-no_ssl.msi
 6. memcached-1.2.6-win32-src.zip
 7. memcached.exe
 8. memcached.py
 9. mercurial-2.2.3.win32-py2.7.exe
 10. MinGW.exe
 11. mingw-get-inst-20120426.exe
 12. mingw.ini
 13. mod_wsgi.so
 14. mysql-5.5.24-win32.msi
 15. MySQL-python-1.2.3.win32-py2.7.exe
 16. patch-2.5.9-7-setup.exe
 17. PIL-1.1.7.win32-py2.7.exe
 18. py27-pysvn-svn1612-1.7.4-1321.exe
 19. pycrypto-2.2.win32-py2.7.exe
 20. ReceivedFiles\Reviewboardpackages
 21. setupfiles
 22. setupfiles.zip
 23. setuptools-0.6c11.win32-py2.7.exe
 24. Slik-Subversion-1.7.5-win32.msi
 25. Slik-Subversion-1.7.8-win32.msi
 26. TortoiseSVN-1.7.7.22907-win32-svn-1.7.5.m
 27. TroubleShooting.txt


POST REVIEWS AND SVN CLIENT SET-UP
Here are the steps to set the  svn repo on desktop. Here , we are assuming that you are on a client machine and you want to post reviews from that machine.
  •  Download ActivePython-2.7.2.5-win32-x86.msi from http://www.activestate.com/activepython/downloads
  • Download TortoiseSVN-1.7.7.22907-win32-svn-1.7.5.msi from http://code.google.com/p/myc/downloads/detail?name=TortoiseSVN-1.7.7.22907-win32-svn-1.7.5.msi&can=4&q=
    •  Install Active python
    •  Install Setup tools
    •  Open command prompt and type "easy_install RBTools"
    •  Install tortoise svn
  •  To set up local repository:
    •  Right click on Desktop -> Tortoise SVN -> Settings-> General -> context Menu. Select all options
    •  Go to C folder and create a folder  named "Repository"
    •  Right click on Repository folder and select "SVN repository create here"
    •  Install silk-subversion ; install diff-utils.exe
    •  In the command prompt type
    •  To post reviews:
      •  Go to the working directory and the location where you have added files
      •  Svn add "file1"
      •  Post-review –server=http://reviewboard.test.com 
      •  Svn commit "file1"