Continuous Integration with Garlic
April 24th, 2008
So I've been curled up in a ball, riding the git avalanche, trying to sort out my rails plugins - making sure they're getting tested against the latest and greatest.
Inspired by this ticket for rspec, git's coolness, some menthol snuff, and a lot of coffee, I came up with garlic.
It's an extremely lightweight set of rake tasks that let you test your plugins or app against various version of rails, and other dependencies.
If you want to see it in action (on one of my plugins), do this:
git clone git://github.com/ianwhite/inherit_views cd inherit_views rake cruise
Sit back, watch it download all the dependencies, then create rails apps for each set, and run the rcov task for the plugin in each one... (the download only happens the first time you do it).
You configure it using a little dsl, like this:
garlic do
# default paths are 'garlic/work', and 'garlic/repos'
work_path "tmp/work"
repo_path "tmp/repos"
# repo, give a url, specify :local to use a local repo (faster
# and will still update from the origin url)
repo 'rails', :url => 'git://github.com/rails/rails' #, :local => "~/dev/vendor/rails"
repo 'rspec', :url => 'git://github.com/dchelimsky/rspec'
repo 'rspec-rails', :url => 'git://github.com/ianwhite/rspec-rails'
repo 'inherit_views', :url => '.'
# for target, default repo is 'rails', default branch is 'master'
target 'edge'
target '2.0-stable', :branch => 'origin/2-0-stable'
target '2.0.2', :tag => 'v2.0.2'
all_targets do
prepare do
plugin 'rspec'
plugin 'rspec-rails', :branch => 'origin/aliased-render-partial' do
sh "script/generate rspec -f"
end
plugin 'inherit_views'
end
run do
cd "vendor/plugins/inherit_views" do
sh "rake spec:rcov:verify"
end
end
end
end
Notice that I'm using my fork of rpsec-rails, and the plugin specifies that it should use a particular branch 'aliased-render-partial'. The reason for this is that I have some outstanding tickets on rspec, which haven't been resolved. In the meantime, I can just use my patched version. If the patch gets accepted, I can just change the url, and garlic will inform me that I need to remove and run rake garlic:install_repos to get the new one. This is just making use of the awesomely cool coolness of git.
Also notice the block passed to the 'rspec-rails' plugin. This will be executed inside the rails target after the plugin has been installed. Finally the run block says what should happen for the actual CI. In this case cding into the plugin and running an rcov task.
It's new stuff
So it probably has bugs and stuff.
Sorry, comments are closed for this article.