Building Rails with Cerberus and multiruby
I've been poking at various continuous integration software lately. Most recently I gave Cerberus a spin, and I must say, even though the project is a bit immature, I like its approach. My test for CI is generally "can I use it on the Rails source" as I think that provides a level of complexity beyond what I'm likely to need for my own projects. Well, I had to contribute a bit of code to get Cerberus to that point, but it works. I also set up the box so that I can build with different ruby versions, thanks to multiruby. Here's my notes on getting all the ducks in a row, starting with a bare-metal Debian Lenny installation.
Note: the italicized installs currently fail on ruby 1.9.1.
Note: Currently, you'll need to either pull and build cerberus from my fork or from the ruby_builder branch in the official repo. With the next release after 0.5.0, you should be able to use the gem install method.
Note: Some of this depends on having pulled a copy of Rails to the box; the easiest way is to let Cerberus do a failing build and then create the databases.
Now you can run
Root Tasks
- log in as root
- adduser webadmin
- visudo - set webadmin up with sudo rights
webadmin Tasks
- log in as webadmin
Prerequisites for Ruby Compiles
- sudo apt-get install autoconf
- sudo apt-get install bison
- sudo apt-get install zlib1g-dev
- sudo apt-get install libzlib-ruby
- sudo apt-get install ruby-dev
rubygems install
- mkdir sources
- cd sources
- wget http://rubyforge.org/frs/download.php/56227/rubygems-1.3.3.tgz
- tar -xvzf rubygems-1.3.3.tgz
- cd rubygems-1.3.3/
- sudo ruby setup.rb
- sudo ln /usr/bin/gem1.8 /usr/bin/gem
fastcgi (we'll need fcgi gem later)
- cd ~/sources
- wget http://www.fastcgi.com/dist/fcgi.tar.gz
- tar -xvzf fcgi-2.4.0.tar.gz
- cd fcgi-2.4.0/
- ./configure
- make
- sudo make install
- sudo apt-get install libfcgi-dev
Databases
- sudo apt-get install mysql-server-5.0 libmysqlclient15-dev
- sudo apt-get install sqlite sqlite3 libsqlite-dev libsqlite3-dev
- sudo apt-get install postgresql postgresql-server-dev-8.3
- sudo su - postgres -c 'createuser -s webadmin'
- sudo su - postgres -c 'createuser -s rails'
memcached
- sudo apt-get install memcached
- sudo /etc/init.d/memcached start
multiruby Install
- sudo gem install ZenTest
- sudo multiruby_setup mri:svn:tag:v1_8_6_368
- sudo multiruby_setup mri:svn:tag:v1_8_7_160
- sudo multiruby_setup mri:svn:tag:v1_9_1_129
- sudo multiruby_setup update:rubygems
Gem Installs
- sudo multiruby -S gem install --no-ri --no-rdoc --development test-unit
- sudo multiruby -S gem install --no-ri --no-rdoc --development fcgi
- sudo multiruby -S gem install --no-ri --no-rdoc --development memcache-client
- sudo multiruby -S gem install --no-ri --no-rdoc --development mocha
- sudo multiruby -S gem install --no-ri --no-rdoc --development mysql
- sudo multiruby -S gem install --no-ri --no-rdoc --development pg
- sudo multiruby -S gem install --no-ri --no-rdoc rack
- sudo multiruby -S gem install --no-ri --no-rdoc thin
- sudo multiruby -S gem install --no-ri --no-rdoc --development rake
- sudo multiruby -S gem install --no-ri --no-rdoc --development sqlite-ruby
- sudo multiruby -S gem install --no-ri --no-rdoc --development sqlite3-ruby
- sudo multiruby -S gem install geminstaller
- sudo multiruby -S gem install SystemTimer
- sudo multiruby -S gem install json
Note: the italicized installs currently fail on ruby 1.9.1.
git
- sudo apt-get install git-core
Cerberus
- sudo gem install cerberus
Note: Currently, you'll need to either pull and build cerberus from my fork or from the ruby_builder branch in the official repo. With the next release after 0.5.0, you should be able to use the gem install method.
Create the Cerberus project and build it
- cerberus add http://github.com/rails/rails/tree/master APPLICATION_NAME=rails_master_187 SCM=git
- Edit the file ~/.cerberus/config.yml to include your own notifier information
- Edit the file ~/.cerberus/config/rails_master_187.yml to put in the custom build info:
---
publisher:
mail:
recipients: you@yourdomain.com
scm:
url: git://github.com/rails/rails.git
type: git
# branch: 2-3-stable
builder:
ruby:
task: ci/ci_build.rb
ruby_path: /home/webadmin/.multiruby/install/v1_8_7_160/bin/
success: Rails build finished sucessfully
failure: Rails build FAILED
brokeness: (\d+) failures, (\d+) errors
- cerberus build rails_master_187
Build databases for ActiveRecord
Note: Some of this depends on having pulled a copy of Rails to the box; the easiest way is to let Cerberus do a failing build and then create the databases.
- cd ~/.cerberus/work/rails_master_187/sources/activerecord/
- mysql -uroot -e 'grant all on *.* to rails@localhost;'
- mysql -urails -e 'create database activerecord_unittest;'
- mysql -urails -e 'create database activerecord_unittest2;'
- rake postgresql:build_databases
Ready to Go
Now you can run
cerberus build rails_master_187
to run a single build, or cerberus build rails_master_187 force=TRUE
to build even if nothing has changed in the repo, or cerberus buildall
to build everything you've defined. Hook it up to cron if you want periodic checks of the repo.