Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/cpjolicoeur/cerberus
Browse files Browse the repository at this point in the history
  • Loading branch information
phinze committed Aug 3, 2009
2 parents c0b7cb4 + 794b16c commit 33d9723
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ doc/site/out
doc/site/webgen.cache
FIXME
*.bak
CHANGES
17 changes: 17 additions & 0 deletions Changelog.txt
@@ -1,5 +1,22 @@
= Cerberus Changelog

== Version 0.6.1
New configuration options, and bugfixes

* added 'build_dir' option for setting custom build directory
* added 'setup_script' option for a custom script to be run before build command
* Projects using the Git SCM were not getting the full diff output in their
Publishers

== Version 0.6
New Ruby builder, bugfixes, and refactoring

* added new Ruby builder for using custom ruby scripts to build projects
* fixed issue with require explicit version of the twitter4r gem
* refactoring and cleanup of the git SCM code
* some cleanup of the 'cerberus status' command output
* only check for process exit status or abort message for ruby_base builder

== Version 0.5
Bugfixes and Ticket Support

Expand Down
3 changes: 2 additions & 1 deletion Copyright.txt
@@ -1,7 +1,7 @@
If you have contributed to Cerberus, you deserve to be on this list.
Contact us (see: Authors.txt) and we will add you.

Cerberus is Copyright (C) 2006-2009 by the following:
Cerberus is Copyright (C) 2006-2009 by the following contributors:

Anatol Pomozov
Xavier Shay
Expand All @@ -12,3 +12,4 @@ Ken Mayer
Niklas Koponen
Mike Gunderloy
Joe Van Dyk
Andrew Timberlake
1 change: 1 addition & 0 deletions TODO
@@ -1 +1,2 @@
* make --verbose option work with all SCM, Builders and Publishers
* update rake builder to only check exit status or aborted msg
3 changes: 3 additions & 0 deletions doc/site/src/credits.page
Expand Up @@ -14,3 +14,6 @@ The following people made notable contributions to the Cerberus tool:
* [Craig Jolicoeur](http://craigjolicoeur.com) - Twitter publisher support & project maintenance
* Ken Mayer - patches related to properly checking shell command exitstatus
* Niklas Koponen - patches for builder CRON-like scheduling and custom publishers
* [Mike Gunderloy](http://afreshcup.com/) - Custom ruby Builder support
* [Joe Van Dyk](http://fixieconsulting.com/) - Git SCM cleanup
* [Andrew Timberlake](http://ramblingsonrails.com) - Custom build script support
4 changes: 1 addition & 3 deletions lib/cerberus/builder/bjam.rb
Expand Up @@ -8,8 +8,6 @@ def initialize(config)
end

def run
Dir.chdir @config[:application_root]

#set correct mountpoint if it present
build_dir = @config[:builder, :bjam, :build_dir]
Dir.chdir(build_dir) if build_dir
Expand All @@ -29,4 +27,4 @@ def successful?
def brokeness
return nil
end
end
end
1 change: 0 additions & 1 deletion lib/cerberus/builder/maven2.rb
Expand Up @@ -8,7 +8,6 @@ def initialize(config)
end

def run
Dir.chdir @config[:application_root]
cmd = @config[:builder, :maven2, :cmd] || 'mvn'
task = @config[:builder, :maven2, :task] || 'test'
@output = `#{@config[:bin_path]}#{cmd} #{system_properties} #{settings} #{task} 2>&1`
Expand Down
4 changes: 4 additions & 0 deletions lib/cerberus/builder/rake.rb
Expand Up @@ -4,4 +4,8 @@ class Cerberus::Builder::Rake < Cerberus::Builder::RubyBase
def initialize(config)
super(config, "rake")
end

def successful?
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!") and @output.include?("0 failures, 0 errors")
end
end
4 changes: 4 additions & 0 deletions lib/cerberus/builder/rant.rb
Expand Up @@ -4,4 +4,8 @@ class Cerberus::Builder::Rant < Cerberus::Builder::RubyBase
def initialize(config)
super(config, "rant")
end

def successful?
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!") and @output.include?("0 failures, 0 errors")
end
end
1 change: 0 additions & 1 deletion lib/cerberus/builder/rspec.rb
Expand Up @@ -6,7 +6,6 @@ def initialize(config)
end

def run
Dir.chdir @config[:application_root]
@output = if @config[:builder, @name.to_sym, :task]
`#{@config[:bin_path]}rake #{@config[:builder, @name.to_sym, :task]} 2>&1`
else
Expand Down
3 changes: 1 addition & 2 deletions lib/cerberus/builder/ruby_base.rb
Expand Up @@ -10,13 +10,12 @@ def initialize(config, name, cmd = name)
end

def run
Dir.chdir @config[:application_root]
@output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @name.to_sym, :task]} 2>&1`
successful?
end

def successful?
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!") and @output.include?("0 failures, 0 errors")
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
end

def brokeness
Expand Down
4 changes: 2 additions & 2 deletions lib/cerberus/constants.rb
Expand Up @@ -2,7 +2,7 @@ module Cerberus
HOME = File.expand_path(ENV['CERBERUS_HOME'] || '~/.cerberus')
CONFIG_FILE = "#{HOME}/config.yml"

LOCK_WAIT = 30 * 60 #30 minutes
LOCK_WAIT = 30 * 60 # 30 minutes

VERSION = '0.5.5'
VERSION = '0.6.1'
end
3 changes: 3 additions & 0 deletions lib/cerberus/manager.rb
Expand Up @@ -113,6 +113,9 @@ def run
@scm.update!

if @scm.has_changes? or @config[:force] or @status.previous_build_successful.nil?
Dir.chdir File.join(@config[:application_root], @config[:build_dir] || '')
`#{@config[:setup_script]}` if @config[:setup_script]

build_successful = @builder.run
@status.keep(build_successful, @scm.current_revision, @builder.brokeness)

Expand Down
10 changes: 5 additions & 5 deletions lib/cerberus/publisher/base.rb
Expand Up @@ -7,7 +7,7 @@ def self.formatted_message(state, manager, options)
subject =
case state.current_state
when :setup
"Cerberus set up for project (##{manager.scm.current_revision})"
"Cerberus set up for project (#{manager.scm.current_revision})"
when :broken
additional_message = nil
if state.previous_brokeness and state.current_brokeness
Expand All @@ -19,15 +19,15 @@ def self.formatted_message(state, manager, options)
' and getting worse'
end
end
"Build still broken#{additional_message} (##{manager.scm.current_revision})"
"Build still broken#{additional_message} (#{manager.scm.current_revision})"

#FIXME instead of using last author as person that broken build try to guess it. I.e. only if one author since last commit did commit - then he broken it.
when :failed
"Build broken by #{manager.scm.last_author} (##{manager.scm.current_revision})"
"Build broken by #{manager.scm.last_author} (#{manager.scm.current_revision})"
when :revival
"Build fixed by #{manager.scm.last_author} (##{manager.scm.current_revision})"
"Build fixed by #{manager.scm.last_author} (#{manager.scm.current_revision})"
when :successful
"Build successful (##{manager.scm.current_revision})"
"Build successful (#{manager.scm.current_revision})"
else
raise "Unknown build state '#{state.current_state.to_s}'"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cerberus/publisher/rss.rb
Expand Up @@ -24,6 +24,6 @@ def self.publish(state, manager, options)
</rss>
END

IO.write(config[:file], result, 'a')
IO.write(config[:file], result)
end
end
5 changes: 3 additions & 2 deletions lib/cerberus/scm/git.rb
Expand Up @@ -21,6 +21,7 @@ def update!
encoded_url = (@config[:scm, :url].include?(' ') ? "\"#{@config[:scm, :url]}\"" : @config[:scm, :url])
@new = true
@status = execute("clone", "#{encoded_url} #{@path}", false)
execute('config', 'pager.diff false') # turn off git-diff $PAGER by default
if branch = @config[:scm, :branch]
execute('branch', "--track #{branch} #{remote_head}")
execute('checkout', branch)
Expand All @@ -37,8 +38,8 @@ def new?
@new == true
end

def current_revision
@revision
def current_revision( _full=false )
_full ? @revision : @revision.slice(0,8)
end

def url
Expand Down
2 changes: 1 addition & 1 deletion test/functional_test.rb
Expand Up @@ -63,7 +63,7 @@ def test_build
#Check outpus that run needed tasks
assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
assert output !~ /Task 'custom1' has been invoked/
assert_equal '[myapp] Cerberus set up for project (#2)', mail.subject
assert_equal '[myapp] Cerberus set up for project (2)', mail.subject
assert output =~ %r{http://someurl.changeset.com/2}

status_file = HOME + '/work/myapp/status.log'
Expand Down
2 changes: 1 addition & 1 deletion test/jabber_publisher_test.rb
Expand Up @@ -16,7 +16,7 @@ def test_publisher
assert messages.size > 2
assert_equal 'google.com', messages[0].to.domain
assert_equal 'jit1', messages[0].to.node
assert_equal '[MegaApp] Build still broken (#1232)', messages[0].subject
assert_equal '[MegaApp] Build still broken (1232)', messages[0].subject
assert !messages[0].body.nil?
end
end
2 changes: 1 addition & 1 deletion test/mail_publisher_test.rb
Expand Up @@ -21,6 +21,6 @@ def test_publisher
assert_equal 1, mails.size
mail = mails[0]
assert_equal 'haha', mail.from_addrs[0].address
assert_equal '[MyApp] Cerberus set up for project (#1232)', mail.subject
assert_equal '[MyApp] Cerberus set up for project (1232)', mail.subject
end
end
41 changes: 39 additions & 2 deletions test/rspec_builder_test.rb
Expand Up @@ -17,6 +17,9 @@ def test_builder
builder.output = RSPEC_TEST_OK_OUTPUT
assert builder.successful?

builder.output = RSPEC_TEST_OK_OUTPUT_ALT
assert builder.successful?

builder.output = RSPEC_TEST_OK_OUTPUT_WITH_PENDING
assert builder.successful?

Expand All @@ -26,7 +29,7 @@ def test_builder

builder.output = RSPEC_TEST_ERROR_OUTPUT_WITH_PENDING
assert !builder.successful?
assert_equal 1, builder.brokeness
assert_equal 3, builder.brokeness
end
end

Expand Down Expand Up @@ -59,6 +62,40 @@ def test_builder
770 examples, 0 failures, 6 pending
END

RSPEC_TEST_OK_OUTPUT_ALT = <<-END
Git commit message (fixes #111)
diff...
(in /Users/deployer/.cerberus/work/webapp/sources)
Profiling enabled.
..................................................................................................................................................
.................................................................................................................................................
Top 10 slowest examples:
6.0324890 Setting should update the modified_time_unix attribute after
destroy
3.0633630 Recorded should update the modified_time_unix whenever the
wildcard value is updated in nvp
3.0267280 Setting should update the modified_time_unix attribute after
save
0.8593440 Audit searching for auditables should find audits for a
deleted package and its children
0.7079580 Package a fully activatable valid package should delete all
child records when destroyed
0.3543940 POST create should audit a time segment split
0.3363000 Package a fully activatable valid package should insert into
the db successfully
0.3159420 Audit searching for auditables should find audits for a
deleted number
0.2989840 Audit searching for auditables should find all auditables in
1 week as default
0.2906990 POST create should audit the created profile
Finished in 35.621931 seconds
291 examples, 0 failures
END

RSPEC_TEST_OK_OUTPUT_WITH_PENDING =<<-END
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /Library/Ruby/Gems/1.8/gems/rspec-1.1.12/bin/spec spec/views/clients/show.html.erb_spec.rb spec/models/role_spec.rb spec/models/dashboard_spec.rb spec/models/client_spec.rb spec/helpers/admin/users_helper_spec.rb spec/controllers/sessions_controller_spec.rb spec/models/query_dates_spec.rb spec/helpers/heatmaps_helper_spec.rb spec/helpers/passwords_helper_spec.rb spec/controllers/admin/reports_controller_spec.rb spec/models/role_assignment_spec.rb spec/models/default_role_spec.rb spec/controllers/sites_controller_spec.rb spec/controllers/dashboards_controller_spec.rb spec/models/widget_instance_spec.rb spec/models/widget_spec.rb spec/controllers/admin/roles_controller_spec.rb spec/models/user_spec.rb spec/models/right_spec.rb spec/views/clients/new.html.erb_spec.rb spec/helpers/reports_helper_spec.rb spec/controllers/reports_controller_spec.rb spec/models/site_spec.rb spec/helpers/admin/rights_helper_spec.rb spec/models/data_warehouse_spec.rb spec/helpers/users_helper_spec.rb spec/helpers/clients_helper_spec.rb spec/helpers/admin/roles_helper_spec.rb spec/views/clients/index.html.erb_spec.rb spec/controllers/users_controller_spec.rb spec/controllers/clients_routing_spec.rb spec/controllers/clients_controller_spec.rb spec/controllers/admin/users_controller_spec.rb spec/controllers/access_control_spec.rb spec/models/query_cache_key_spec.rb spec/views/clients/edit.html.erb_spec.rb spec/controllers/passwords_controller_spec.rb spec/controllers/authenticated_system_spec.rb spec/helpers/application_helper_spec.rb spec/models/report_spec.rb spec/models/query_spec.rb spec/helpers/admin/reports_helper_spec.rb spec/controllers/queries_controller_spec.rb spec/controllers/application_controller_spec.rb spec/models/excel_export_spec.rb spec/controllers/admin/rights_controller_spec.rb -O spec/spec.opts
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Expand Down Expand Up @@ -98,5 +135,5 @@ def test_builder
Finished in 0.245002 seconds
15 examples, 1 failure, 1 pending
15 examples, 3 failures, 1 pending
END
2 changes: 1 addition & 1 deletion test/rss_publisher_test.rb
Expand Up @@ -15,7 +15,7 @@ def test_publisher

xml = REXML::Document.new(IO.read(rss_file.path))

assert_equal '[RSS<App] Build still broken (#1235)', xml.elements["rss/channel/item/title/"].get_text.value
assert_equal '[RSS<App] Build still broken (1235)', xml.elements["rss/channel/item/title/"].get_text.value
assert_match %r{<pre>last message\nthis is output\n--\nThis email generated by Cerberus tool ver\. \d.\d(.\d)?, http://cerberus.rubyforge.org/</pre>},
xml.elements["rss/channel/item/description/"].get_text.value
end
Expand Down
2 changes: 1 addition & 1 deletion test/twitter_publisher_test.rb
Expand Up @@ -14,6 +14,6 @@ def test_publisher

statuses = Twitter::Client.statuses
assert_equal 1, statuses.size
assert_equal '[TestApp] Build still broken (#1232)', statuses.first
assert_equal '[TestApp] Build still broken (1232)', statuses.first
end
end

0 comments on commit 33d9723

Please sign in to comment.