<commit_before>h1. 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":http://github.com/freelancing-god/ginger by "<NAME>":http://github.com/freelancing-god

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.

h2. 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

h2. 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.

h3. 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.

h3. 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

h3. Running Shell commands across multiple targets

Check dis out

  garlic shell  # "Example output":http://gist.github.com/21496
  
---
The following still needs to be updated for the new gem/cmd-line version

h2. 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
  # 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
  # ... commit some changes into 'my_change'
  rake garlic
  # ... everything is fine, so I can merge these into master, or send a pull request

h3. 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:<commit_msg>Give example of garlic generate<commit_after>h1. 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":http://github.com/freelancing-god/ginger by "<NAME>":http://github.com/freelancing-god

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.

h2. 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

h2. 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

h2. 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.

h3. 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.

h3. 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

h3. Running Shell commands across multiple targets

Check dis out

  garlic shell  # "Example output":http://gist.github.com/21496
  
---

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

h2. 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
  # 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
  # ... commit some changes into 'my_change'
  rake garlic
  # ... everything is fine, so I can merge these into master, or send a pull request

h3. 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:
{'fraction_non_alphanumeric': 0.0535438476059722, 'fraction_numerical': 0.004633602196670671, 'mean_word_length': 3.7228525121555918, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7078918', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1587, 'n_words': 867}