diff --git a/.gitignore b/.gitignore index e293ed3..9efc19a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ doc/site/out doc/site/webgen.cache FIXME *.bak +CHANGES diff --git a/Changelog.txt b/Changelog.txt index 2e478bd..8f51b25 100644 --- a/Changelog.txt +++ b/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 diff --git a/Copyright.txt b/Copyright.txt index fdc3141..7c62ae5 100644 --- a/Copyright.txt +++ b/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 @@ -12,3 +12,4 @@ Ken Mayer Niklas Koponen Mike Gunderloy Joe Van Dyk +Andrew Timberlake \ No newline at end of file diff --git a/TODO b/TODO index 3fb4e51..b11b3a5 100644 --- a/TODO +++ b/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 diff --git a/doc/site/src/credits.page b/doc/site/src/credits.page index 1510744..9723f06 100644 --- a/doc/site/src/credits.page +++ b/doc/site/src/credits.page @@ -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 diff --git a/lib/cerberus/builder/bjam.rb b/lib/cerberus/builder/bjam.rb index a5b4027..57ed5be 100644 --- a/lib/cerberus/builder/bjam.rb +++ b/lib/cerberus/builder/bjam.rb @@ -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 @@ -29,4 +27,4 @@ def successful? def brokeness return nil end -end \ No newline at end of file +end diff --git a/lib/cerberus/builder/maven2.rb b/lib/cerberus/builder/maven2.rb index d4ce1ee..8c087e1 100644 --- a/lib/cerberus/builder/maven2.rb +++ b/lib/cerberus/builder/maven2.rb @@ -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` diff --git a/lib/cerberus/builder/rake.rb b/lib/cerberus/builder/rake.rb index bc4835f..050cbe9 100644 --- a/lib/cerberus/builder/rake.rb +++ b/lib/cerberus/builder/rake.rb @@ -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 diff --git a/lib/cerberus/builder/rant.rb b/lib/cerberus/builder/rant.rb index d3b2961..88087ef 100644 --- a/lib/cerberus/builder/rant.rb +++ b/lib/cerberus/builder/rant.rb @@ -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 diff --git a/lib/cerberus/builder/rspec.rb b/lib/cerberus/builder/rspec.rb index 01f997a..eb3c243 100644 --- a/lib/cerberus/builder/rspec.rb +++ b/lib/cerberus/builder/rspec.rb @@ -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 diff --git a/lib/cerberus/builder/ruby_base.rb b/lib/cerberus/builder/ruby_base.rb index fe936c3..014f5f4 100644 --- a/lib/cerberus/builder/ruby_base.rb +++ b/lib/cerberus/builder/ruby_base.rb @@ -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 diff --git a/lib/cerberus/constants.rb b/lib/cerberus/constants.rb index fc2d04d..161d3a7 100644 --- a/lib/cerberus/constants.rb +++ b/lib/cerberus/constants.rb @@ -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 diff --git a/lib/cerberus/manager.rb b/lib/cerberus/manager.rb index b84464b..efce318 100644 --- a/lib/cerberus/manager.rb +++ b/lib/cerberus/manager.rb @@ -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) diff --git a/lib/cerberus/publisher/base.rb b/lib/cerberus/publisher/base.rb index 6099d03..f3ce0f9 100644 --- a/lib/cerberus/publisher/base.rb +++ b/lib/cerberus/publisher/base.rb @@ -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 @@ -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 diff --git a/lib/cerberus/publisher/rss.rb b/lib/cerberus/publisher/rss.rb index 03d523e..1cccb23 100644 --- a/lib/cerberus/publisher/rss.rb +++ b/lib/cerberus/publisher/rss.rb @@ -24,6 +24,6 @@ def self.publish(state, manager, options) END - IO.write(config[:file], result, 'a') + IO.write(config[:file], result) end end diff --git a/lib/cerberus/scm/git.rb b/lib/cerberus/scm/git.rb index 5ac7c66..1489a8b 100644 --- a/lib/cerberus/scm/git.rb +++ b/lib/cerberus/scm/git.rb @@ -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) @@ -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 diff --git a/test/functional_test.rb b/test/functional_test.rb index 4a3bc43..86151aa 100644 --- a/test/functional_test.rb +++ b/test/functional_test.rb @@ -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' diff --git a/test/jabber_publisher_test.rb b/test/jabber_publisher_test.rb index 3fc6592..914e567 100644 --- a/test/jabber_publisher_test.rb +++ b/test/jabber_publisher_test.rb @@ -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 diff --git a/test/mail_publisher_test.rb b/test/mail_publisher_test.rb index 18a7dfb..dfd930f 100644 --- a/test/mail_publisher_test.rb +++ b/test/mail_publisher_test.rb @@ -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 diff --git a/test/rspec_builder_test.rb b/test/rspec_builder_test.rb index d3022f4..13647e1 100644 --- a/test/rspec_builder_test.rb +++ b/test/rspec_builder_test.rb @@ -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? @@ -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 @@ -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 ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ @@ -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 diff --git a/test/rss_publisher_test.rb b/test/rss_publisher_test.rb index 83b3db4..2b93943 100644 --- a/test/rss_publisher_test.rb +++ b/test/rss_publisher_test.rb @@ -15,7 +15,7 @@ def test_publisher xml = REXML::Document.new(IO.read(rss_file.path)) - assert_equal '[RSSlast message\nthis is output\n--\nThis email generated by Cerberus tool ver\. \d.\d(.\d)?, http://cerberus.rubyforge.org/}, xml.elements["rss/channel/item/description/"].get_text.value end diff --git a/test/twitter_publisher_test.rb b/test/twitter_publisher_test.rb index 3f92952..4b43bf0 100644 --- a/test/twitter_publisher_test.rb +++ b/test/twitter_publisher_test.rb @@ -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