David - Musings of an SRE

Getting Integrity up and running w/ email notification and test database raking

After spending a couple of hours trying to get integrity setup, I thought I’ll share and document my process for future reference.

So what is Integrity?

From their website: “As soon as you push your commits, Integrity builds your code, run your tests and makes sure everything works fine. It then reports the build status using various notifiers back to you and your team so everyone is on the same page and problems can be fixed right away.”

In a nutshell, Integrity is a Continous Integration Server which helps to ensure that your codebase is properly integrated and working at every stage of your development. Integrity’s website is pretty straight-forward and simple to understand, head on over to their webpage at http://integrityapp.com and follow the instructions on the page. The bottom part of the page is pretty confusing so what I basically did was to:

$ gem install bundler
$ git clone git://github.com/integrity/integrity
$ cd integrity
$ git checkout -b deploy v0.4.1
$ bundle install
$ bundle lock
$ rake db

Open up the default init.rb and add in the following lines in between the Integrity.configure block

c.user "username"
c.pass "password"

What this does is tell Integrity to set a HTTP Authentication check for the application so that only people with the proper credentials can access your application.

So here’s where the confusion starts.

The tutorial over at Integrityapp.com makes no mention about how to get your database.yml file copied into the builds/ directory. If you’re like most developers (and I hope you are), your database.yml file will not be injected into your repository, so how do we setup Integrity such that it would be able to copy the proper .yml file and configure it according to your settings?

First, setup a rake task that does the magic of copying. In your /lib/tasks create a .rake file and copy the following:

namespace :test do
 task :move_test_db_config do
   require 'ftools'
   File.move(RAILS_ROOT+"/config/database.yml.test",
RAILS_ROOT+"/config/database.yml")
 end
end

This rake task will copy the file database.yml.test to database.yml, so you’re going to need to create a database.yml.test file in your /config directory. You don’t have to put in other information like your development/production settings since all integrity needs is your test environment. Here’s mine:

test:
 adapter: sqlite3
 database: db/test.sqlite3
 pool: 5
 timeout: 5000

Yeah, dead simple.

With that said and done, all you need to do now is to start the app, access the app, and create a new project. In the ‘build script’ field, replace it with “rake test:move_test_db_config” and you’re done! As for notifications, just follow the instructions at Integrity.

protip: Make sure you give the user that is running the webserver (apache/thin) access to the remote git repository that you want to track. Use SSH key authentication for best results.

Source: