Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

garlic is a set of commands/rake tasks to help with CI across multiple rails/dependency versions

tree: 7514a7f24e

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 bin
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 templates
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 README.textile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO
Octocat-spinner-32 garlic.gemspec
README.textile

garlic: lightweight continuous integration for rails using git

This is not a CI server, use cruisecontrol.rb for that. This is a simple set
of rake tasks that let you specify a bunch of rails builds to run against, and
dependencies to install.

This is aimed at testing plugins (or apps) against multiple versions of rails,
and allows specifying other plugin dependencies (and their versions and any
setup requried).

If you want to run your specs (or whatever) against different versions of gems
that you have installed, then check out ginger by Pat Allen

Garlic works by cloning git repos for all your dependencies (so they all must be
git repos), and then using git to checkout various tags and branches to build
your app against.

Get up and running quickly

You have a plugin and you want it tested against different versions of rails?

  • install garlic as a gem (see below)
  • cd into your (say, rspec tested) plugin directory
  garlic generate rspec > garlic.rb
  garlic install_repos
  garlic
  • See what happens, edit garlic.rb to change rails versions and other stuff.
  garlic --help # will probably help

Installing

Install the garlic gem

sudo gem install ianwhite-garlic —source=http://gems.github.com

(if it’s not installing as a gem from github)

git clone git://github.com/ianwhite/garlic cd garlic rake package sudo gem install pkg/*.gem

Example

To see garlic in action, download response_for, a rails plugin that uses
garlic for CI.

git clone git://github.com/ianwhite/response_for

run garlic

garlic all

This will clone all the required git repos (done only once), set up the target
railses (done once), then run the targets.

Once you’ve made some changes

You can prepare and run all the targets again (without fetching remote repos) by doing

garlic

This will prepare all the targets, using the current HEAD of the repos, and run the
CI task again.

Specifying particular targets

If you just want to run against a particular target or targets, you can use the TARGET or TARGETS
env var.

garlic -t edge

Running Shell commands across multiple targets

Check dis out

garlic shell # Example output

The following still needs to be updated for the new gem/cmd-line version

Example workflow

Let’s say I’m patching resources_controller.

First I grab it, and set up garlic

git clone git://github.com/ianwhite/resources_controller.git cd resources_controller rake get_garlic cp garlic_example.rb garlic.rb
  1. I could now edit garlic.rb to point the repos at my local copies, for speed

Now, I download and run the CI suite

rake garlic:all

Now, I make some changes

git checkout -b my_change
  1. … commit some changes into ‘my_change’
    rake garlic
  2. … everything is fine, so I can merge these into master, or send a pull request

How do I run the specs on uncommitted code?

The best way is to make the changes in one of the ‘work’ targets. For example:

  1. after running rake garlic:all
    cd garlic/work/edge/vendor/plugins/resources_controller
  2. … make changes without committing
    rake spec
  3. … it passes, so commit
    git commit -m “My great change”

Now you can push these changes back upstream to your local ‘master’ repo

git push origin my_changes # or you could push to master branch or whatever

Then cd back up there, and run rake garlic to verify your changes against the other
targets. If these all pass, you can push, or send a pull request

h2.How to add garlic to your repo (example: rails plugin)

1. require the garlic tasks into your own Rakefile

  1. rescue this just in case the plugin user doesn’t have garlic
    begin
    require ‘garlic’
    rescue LoadError
    end

2. add a garlic.rb

An example garlic.rb:

garlic do
  1. repos
    repo ‘rails’, :url => ‘git://github.com/rails/rails’
    repo ‘rspec’, :url => ‘git://github.com/dchelimsky/rspec’
    repo ‘rspec-rails’, :url => ‘git://github.com/dchelimsky/rspec-rails’
    repo ‘resources_controller’, :path => ‘.’
  1. targets
    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 ‘resources_controller’, :clone => true plugin ‘rspec’ plugin ‘rspec-rails’ do sh “script/generate rspec -f” end end run do cd “vendor/plugins/resources_controller” sh “rake spec:rcov:verify” end end end end

3. ignore the garlic artefacts

Example .gitignore

.garlic_work

4. Run it

rake garlic:all

And to run it again, once you’ve made changes

rake garlic

To make sure you’re running against the latest repos:

rake garlic:update_repos

Lend a hand

This is an early release, so there is plenty of scope for changes and improvement
If you want to lend a hand, get in touch.

© Ian White 2008 – ian.w.white@gmail.com
MIT Licence

Lent a hand

Thanks very much to:

  • Pat Allan
Something went wrong with that request. Please try again.