Check Commits The Easy Way


In Chad Fowlers [Rails Recipes] I encountered the tip to use the continuous_builder plugin to automatically test your code after each commit. This to check, for example that all necessary files are committed.

The continuous_builder plugin however has two problems:
  • There is quite some superfluous code in there, including needless dependencies, for some Marshmellow-chatbot that seems to belong to Basecamp (a subscription-based project management-tool by 37 Signals)
  • It requires you to have access to the build-hooks of SVN, which means shell-access to your SVN-repository. Sourceforge.net does not allow this, nor does Rubyforge. To even remain silent of the additional overhead with regard to enabling your svn server to test your app.

This can be done much easier on the client-side, and simpler; in the spirit of less is more:

Add this to task_helpers.rb

class CommitCheckNotifier < ActionMailer::Base
def failure(error)
@subject = "Build broken"
@body = error
@recipients = ENV['USER']
@from = 'admin'
@sent_on = Time.now
end
end

Add this as do_check_commit.rake to lib/tasks

task :do_check_commit do
require File.join(File.dirname(__FILE__), '../task_helpers.rb')
runs = [
"cd /tmp; svn co https://svn.sourceforge.net/svnroot/logilogi/trunk logilogi",
"cp -f config/database.yml /tmp/logilogi/config/database.yml",
"cd /tmp/logilogi; rake test_units"]
runs.each do |run|
output = `#{run}`
process = $?
if process.exitstatus != 0
CommitCheckNotifier.deliver_failure(output)
break
end
end
end

(replace logilogi with your own project-name)

Calling rake do_check_commit will now checkout your code and test it, and if something goes wrong it will send an e-mail to the local user (the one that broke it). You might want to add your projects developers mailinglist to the recipients too.

Then create a do_commit.rake task in this same dir that calls rake do_check_commit, and it can also take care of other things like visualizing your class- structure or generating documentation to match the change (and not to forget it should also call svn commit, ...before the do_check_commit of course...).
Part of the LogiLogi Network: The LogiLogi Foundation - LogiLogi.org - OgOg.org
This is an old version for archival purposes, see www.LogiLogi.org for the current version.
< Edit this document | View history | Printer friendly (inc. links) >
Visited 1053 times
Document last modified Fri, 10 Nov 2006 19:43:10
All content is available under the GNU Free Documentation License. The LogiLogi-system is under the GPL
SourceForge.net Logo Zylon Internet Services-Groningen Logo
Visitor statistics