cerberus 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,7 +1,12 @@
1
1
  = Cerberus Changelog
2
2
 
3
- == Version 0.1.0
3
+ == Version 0.1.1
4
+ Minor improvements
5
+
6
+ * Added 'buildall' command that build all projects added to Cerberus repository.
7
+ * Fixed tests on *nix
4
8
 
9
+ == Version 0.1.0
5
10
  Initial version of Cerberus tool
6
11
 
7
12
  * Implemented basic functionality required by Continuous Integration.
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- Copyright (c) 2006 Anatol Pomozov
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
1
+ Copyright (c) 2006 Anatol Pomozov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README CHANGED
@@ -1,7 +1,4 @@
1
- Cerberus developed by Anatol Pomozov (anatol.pomozov@gmail.com) and shared under MIT license.
2
-
3
- Cerberus is continuous integration (CI) software. Cerberus could be periodically run from scheduler
4
- and check if application tests are broken. If it happend then Cerberus sends notification to developers.
1
+ Cerberus is a Continuous Integration (CI) software. Cerberus could be periodically run from scheduler and check if application tests are broken. If it happens then Cerberus will send notification to developers. Cerberus perfectly works both on Windows and *nix platforms.
5
2
 
6
3
  For more CI theory read this document from Martin Fowler
7
4
  http://www.martinfowler.com/articles/continuousIntegration.html.
@@ -11,7 +8,6 @@ Requirements:
11
8
  rake - 0.7 or higher
12
9
  svn client - 1.2 or higher
13
10
 
14
-
15
11
  What 'Cerberus' name means?
16
12
  Quote from Wikipedia (http://en.wikipedia.org/wiki/Cerberus)
17
13
 
@@ -19,23 +15,22 @@ Cerberus or Kerberos (Kerberos, demon of the pit), was the hound of Hades-a mons
19
15
  He guarded the gate to Hades (the Greek underworld) and ensured that the dead could not leave and the living could not enter. His brother was Orthrus. He is the offspring of Echidna and Typhon.
20
16
 
21
17
 
22
- So Cerberus will guard your tests and not allow your project to go to the world of dead.
23
-
18
+ So Cerberus will guard your tests and not allow your project to go to the world of dead.
24
19
 
25
20
  To use Cerberus it is very easy. First install it. Easiest way to do it through RubyGems package manager.
26
21
 
27
22
  'gem install cerberus'
28
23
 
24
+ or get Cerberus distribution package right from download page http://rubyforge.org/frs/?group_id=1794
25
+
29
26
  then you need to add project that will be watched by Cerberus. Do it by
30
27
 
31
- cerberus add (DIR|SVN_URL)? #Adds project to list of watched applications
28
+ cerberus add (DIR|SVN_URL) APPLICATION_NAME=some_app RECIPIENTS=dev1@project.com,dev2@project.com
29
+
30
+ as second parameter you could pass URL to subversion repository or directory with working SVN folder.
32
31
 
33
- as second parameted you could pass URL to subversion repository or directory with working SVN folder.
34
- If this parameted absent then would be added project from current directory
32
+ Go to ~./cerberus and edit config.yml file (only once after installing Cerberus). Enter your configuration options here like email server, password, user_name and other options. See ActiveMailer description - Cerberus uses it as notification layer. My config file looks like this
35
33
 
36
- Go to ~./cerberus and edit config.yml file (only once after installing Cerberus). Enter your configuration options here
37
- like email server, password, user_name and other options. See ActiveMailer description - Cerberus uses it as notification
38
- layer. Mine config file looks like this
39
34
  mail:
40
35
  address: mail.somesever.com
41
36
  user_name: anatol
@@ -43,15 +38,14 @@ mail:
43
38
  domain: somesever.com
44
39
  authentication: login
45
40
 
46
- Also go to ~/.cerberus/config/<PROJECT_NAME>.yml and add comma-separated list of recipients for this project
47
- You could also change <PROJECT_NAME> to any other name. This name what Cerberus will use.
41
+ Also check ~/.cerberus/config/<APPLICATION_NAME>.yml and make sure that you have right options.
48
42
 
49
43
  And then run Cerberus
50
44
 
51
- cerberus build PROJECT_NAME #Run project
45
+ cerberus build APPLICATION_NAME #Run project
52
46
 
53
- It will check out latest sources and run tests for your app. If tests are broken - recipients will recieve notifications.
47
+ It will check out latest sources and run tests for your application. If tests are broken - recipients will receive notifications.
54
48
 
55
- But of course better run Cerberus automatically from Cron. Run it each 10 minutes for project will be ok.
49
+ But of course better run Cerberus automatically from Cron. Run Cerberus for project each 10 minutes would be ok.
56
50
 
57
51
  Well, thats all. If you have any questions, proposals - just let me know.
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ GEM_SPEC = Gem::Specification.new do |s|
40
40
 
41
41
  s.summary = "Cerberus is a Continuous Integration tool that could be easily run from Cron."
42
42
  s.description = <<-DESC.strip.gsub(/\n\s+/, " ")
43
- Cerberus is a Continuous Integration software for Ruby projects. CI helps you keep your project
43
+ Cerberus is a Continuous Integration software for Ruby projects. CI helps you keep your project
44
44
  in a good shape.
45
45
 
46
46
  For now Cerberus only work with projects that use Subversion but in the future it would be provided
@@ -70,7 +70,7 @@ GEM_SPEC = Gem::Specification.new do |s|
70
70
  s.author = "Anatol Pomozov"
71
71
  s.email = "anatol.pomozov@gmail.com"
72
72
  s.homepage = "http://rubyforge.org/projects/cerberus"
73
- s.rubyforge_project = "cerberus"
73
+ s.rubyforge_project = RUBY_FORGE_PROJECT
74
74
  end
75
75
 
76
76
 
@@ -120,6 +120,8 @@ end
120
120
 
121
121
  task :publish_news do
122
122
  require 'meta_project'
123
+
124
+ project = MetaProject::Project::XForge::RubyForge.new(RUBY_FORGE_PROJECT)
123
125
  Rake::XForge::NewsPublisher.new(project) do |publisher|
124
126
  publisher.user_name = RUBY_FORGE_USER
125
127
  publisher.password = ENV['RUBYFORGE_PASSWORD']
data/doc/FAQ CHANGED
@@ -0,0 +1,21 @@
1
+ * How to schedule Cerberus build on nnCron
2
+
3
+ nnCron has simple user interface and it is easy to add new task - just run task with AsLoggedUser option.
4
+ There is only issue - nnCron do not pass HOME environment variable to process so you need to add it to nncron.tab file.
5
+
6
+ You could add CERBERUS_HOME envronment variable or HOME (in last case CERBERUS_HOME would be calculated as
7
+ HOME/.cerberus)
8
+
9
+ Mine nncron.tab file looks like this
10
+
11
+
12
+
13
+ SET CERBERUS_HOME="C:\Documents and Settings\anatol\.cerberus"
14
+
15
+ #( [cerberus]watsjit
16
+ AsLoggedUser
17
+ Time: */15 * * * * *
18
+ Action:
19
+ SWHide NormalPriority
20
+ START-APPW: c:\progra~1\ruby\bin\cerberus.CMD build cerberus
21
+ )#
data/lib/cerberus/cli.rb CHANGED
@@ -11,7 +11,7 @@ module Cerberus
11
11
  say HELP if args.empty?
12
12
 
13
13
  command = args.shift
14
- say HELP unless %w(add build).include?(command)
14
+ say HELP unless %w(add build buildall).include?(command)
15
15
 
16
16
  cli_options = extract_options(args)
17
17
 
@@ -27,16 +27,10 @@ module Cerberus
27
27
  application_name = args.shift
28
28
 
29
29
  command = Cerberus::Build.new(application_name, cli_options)
30
- begin
31
- command.run
32
- rescue Exception => e
33
- File.open("#{HOME}/work/#{application_name}/error.log", File::WRONLY|File::APPEND|File::CREAT) do |f|
34
- f.puts Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
35
- f.puts e.message
36
- f.puts e.backtrace.collect{|line| ' '*5 + line}
37
- f.puts "\n"
38
- end
39
- end
30
+ command.run
31
+ when 'buildall'
32
+ command = Cerberus::BuildAll.new(cli_options)
33
+ command.run
40
34
  end
41
35
  end
42
36
 
@@ -62,6 +56,7 @@ module Cerberus
62
56
  cerberus add <URL> --- add project from svn repository to list watched of applications
63
57
  cerberus add <PATH> --- add project from local path to list of watched applications
64
58
  cerberus build <APPLICATION_NAME> --- build watched application
59
+ cerberus buildall --- build all watched applications
65
60
 
66
61
  Version #{Cerberus::VERSION::STRING}
67
62
  }.gsub("\n ","\n")
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
- require 'action_mailer'
3
2
  require 'fileutils'
4
3
 
5
4
  require 'cerberus/utils'
6
5
  require 'cerberus/constants'
7
6
  require 'cerberus/config'
8
7
 
8
+ require 'cerberus/notifier/email'
9
+
9
10
  module Cerberus
10
11
  class Add
11
12
  include Cerberus::Utils
@@ -18,7 +19,7 @@ module Cerberus
18
19
  checkout = Checkout.new(@path, @config)
19
20
  say "Can't find any svn application under #{@path}" unless checkout.url
20
21
 
21
- application_name = @config[:application_name] || File.basename(File.expand_path(@path)).strip
22
+ application_name = @config[:application_name] || extract_project_name(@path)
22
23
 
23
24
  create_default_config
24
25
 
@@ -34,6 +35,11 @@ module Cerberus
34
35
  end
35
36
 
36
37
  private
38
+ def extract_project_name(path)
39
+ path = File.expand_path(path) if test(?d, path)
40
+ File.basename(path).strip
41
+ end
42
+
37
43
  def create_default_config
38
44
  default_mail_config =
39
45
  {'mail'=>
@@ -70,36 +76,40 @@ module Cerberus
70
76
  end
71
77
 
72
78
  def run
73
- @checkout.update!
74
-
75
- previous_status = @status.recall
76
-
77
- state =
78
- if @checkout.has_changes? or not previous_status
79
- if status = make
80
- @status.keep(:succesful)
81
- previous_status == :failed ? :revived : :succesful
79
+ begin
80
+ previous_status = @status.recall
81
+ @checkout.update!
82
+
83
+ state =
84
+ if @checkout.has_changes? or not previous_status
85
+ if status = make
86
+ @status.keep(:succesful)
87
+ case previous_status
88
+ when :failed
89
+ :revival
90
+ when :succesful
91
+ :succesful
92
+ when false
93
+ :setup
94
+ end
95
+ else
96
+ @status.keep(:failed)
97
+ previous_status == :failed ? :broken : :failure
98
+ end
82
99
  else
83
- @status.keep(:failed)
84
- previous_status == :failed ? :broken : :failed
100
+ :unchanged
85
101
  end
86
- else
87
- :unchanged
88
- end
89
-
90
- case state
91
- when :failed
92
- Notifier.deliver_failure(self, @config)
93
- when :revived
94
- Notifier.deliver_revival(self, @config)
95
- when :broken
96
- Notifier.deliver_broken(self, @config)
97
- when :unchanged, :succesful
98
- unless previous_status #If it first time we build application then let everyone to know that we have Cerberus now
99
- Notifier.deliver_setup(self, @config)
100
- end
101
102
 
102
- # Smile, be happy, it's all good
103
+ if [:failure, :broken, :revival, :setup].include?(state)
104
+ Cerberus::Notifier::Email.notify(state, self, @config)
105
+ end
106
+ rescue Exception => e
107
+ File.open("#{HOME}/work/#{@config[:application_name]}/error.log", File::WRONLY|File::APPEND|File::CREAT) do |f|
108
+ f.puts Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
109
+ f.puts e.message
110
+ f.puts e.backtrace.collect{|line| ' '*5 + line}
111
+ f.puts "\n"
112
+ end
103
113
  end
104
114
  end
105
115
 
@@ -132,6 +142,23 @@ module Cerberus
132
142
  }
133
143
  end
134
144
  end
145
+
146
+ class BuildAll
147
+ def initialize(cli_options = {})
148
+ @cli_options = cli_options
149
+ end
150
+
151
+ def run
152
+ Dir["#{HOME}/config/*.yml"].each do |fn|
153
+ fn =~ %r{#{HOME}/config/(.*).yml}
154
+ application_name = $1
155
+
156
+ command = Cerberus::Build.new(application_name, @cli_options)
157
+ command.run
158
+ end
159
+ end
160
+ end
161
+
135
162
 
136
163
  class Checkout
137
164
  def initialize(path, options = {})
@@ -200,47 +227,4 @@ module Cerberus
200
227
  value.blank? ? false : value.to_sym
201
228
  end
202
229
  end
203
-
204
- class Notifier < ActionMailer::Base
205
- include Cerberus::Utils
206
-
207
- def failure(build, options)
208
- @subject = "Build broken by #{build.checkout.last_author} (##{build.checkout.current_revision})"
209
- send_message(build, options)
210
- end
211
-
212
- def broken(build, options)
213
- @subject = "Build still broken (##{build.checkout.current_revision})"
214
- send_message(build, options)
215
- end
216
-
217
- def revival(build, options)
218
- @subject = "Build fixed by #{build.checkout.last_author} (##{build.checkout.current_revision})"
219
- send_message(build, options)
220
- end
221
-
222
- def setup(build, options)
223
- @subject = "Cerberus set up for project (##{build.checkout.current_revision})"
224
- send_message(build, options)
225
- end
226
-
227
- private
228
- def send_message(build, options)
229
- mail_config = options[:mail] || {}
230
- [:authentication, :delivery_method].each do |k|
231
- mail_config[k] = mail_config[k].to_sym if mail_config[k]
232
- end
233
-
234
- ActionMailer::Base.delivery_method = mail_config[:delivery_method] if mail_config[:delivery_method]
235
- ActionMailer::Base.server_settings = mail_config
236
-
237
- @subject = "[#{options[:application_name]}] " + @subject
238
- @body = [ build.checkout.last_commit_message, build.output ].join("\n\n")
239
-
240
- @recipients, @sent_on = options[:recipients], Time.now
241
-
242
- @from = options[:sender] || "'Cerberus' <cerberus@example.com>"
243
- raise "Please specify recipient addresses for application '#{options[:application_name]}'" unless options[:recipients]
244
- end
245
- end
246
- end
230
+ end
@@ -0,0 +1,47 @@
1
+ require 'action_mailer'
2
+
3
+ module Cerberus
4
+ module Notifier
5
+ class Email
6
+ def self.notify(state, build, options)
7
+ Email.configure(options)
8
+ ActionMailerNotifier.deliver_message(state, build, options)
9
+ end
10
+
11
+ private
12
+ def self.configure(options)
13
+ mail_config = options[:mail] || {}
14
+ [:authentication, :delivery_method].each do |k|
15
+ mail_config[k] = mail_config[k].to_sym if mail_config[k]
16
+ end
17
+
18
+ ActionMailer::Base.delivery_method = mail_config[:delivery_method] if mail_config[:delivery_method]
19
+ ActionMailer::Base.server_settings = mail_config
20
+ end
21
+
22
+ class ActionMailerNotifier < ActionMailer::Base
23
+ def message(state, build, options)
24
+ subject =
25
+ case state
26
+ when :setup
27
+ "Cerberus set up for project (##{build.checkout.current_revision})"
28
+ when :broken
29
+ "Build still broken (##{build.checkout.current_revision})"
30
+ when :failure
31
+ "Build broken by #{build.checkout.last_author} (##{build.checkout.current_revision})"
32
+ when :revival
33
+ "Build fixed by #{build.checkout.last_author} (##{build.checkout.current_revision})"
34
+ end
35
+
36
+ @subject = "[#{options[:application_name]}] #{subject}"
37
+ @body = [ build.checkout.last_commit_message, build.output ].join("\n\n")
38
+
39
+ @recipients, @sent_on = options[:recipients], Time.now
40
+
41
+ @from = options[:sender] || "'Cerberus' <cerberus@example.com>"
42
+ raise "Please specify recipient addresses for application '#{options[:application_name]}'" unless options[:recipients]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,9 +1,9 @@
1
- module Cerberus
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 0
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
1
+ module Cerberus
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 1
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -2,14 +2,13 @@ require 'test_helper'
2
2
 
3
3
  require 'cerberus/cli'
4
4
 
5
- #require 'mocks/notifier'
6
-
7
5
  class FunctionalTest < Test::Unit::TestCase
8
6
  def setup
9
7
  FileUtils.rm_rf HOME
10
8
  end
11
9
 
12
10
  def teardown
11
+ Dir.chdir HOME + '/../' #We need change working directory to some non-removable dir otherwise we would have warning after removing that working directory absent
13
12
  FileUtils.rm_rf HOME
14
13
  end
15
14
 
@@ -41,7 +40,7 @@ class FunctionalTest < Test::Unit::TestCase
41
40
 
42
41
  def test_build
43
42
  add_application('myapp', SVN_URL)
44
-
43
+
45
44
  build = Cerberus::Build.new('myapp')
46
45
  build.run
47
46
  assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
@@ -85,11 +84,27 @@ class FunctionalTest < Test::Unit::TestCase
85
84
 
86
85
  def test_have_no_awkward_header
87
86
  add_application('myapp', SVN_URL)
88
-
87
+
89
88
  build = Cerberus::Build.new('myapp')
90
89
  build.run
91
90
 
92
91
  assert build.checkout.last_commit_message !~ /-rHEAD -v/
93
92
  assert_equal 0, build.checkout.last_commit_message.index('-' * 72)
94
93
  end
94
+
95
+ def test_have_no_awkward_header
96
+ add_application('myapp1', SVN_URL)
97
+ add_application('myapp2', SVN_URL)
98
+ add_application('myapp3', SVN_URL)
99
+ add_application('myapp4', SVN_URL)
100
+
101
+ build = Cerberus::BuildAll.new
102
+ build.run
103
+
104
+ for i in 1..4 do
105
+ status_file = HOME + "/work/myapp#{i}/status.log"
106
+ assert File.exists?(status_file)
107
+ assert_equal 'succesful', IO.read(status_file)
108
+ end
109
+ end
95
110
  end
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: cerberus
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2006-07-16 00:00:00 +04:00
6
+ version: 0.1.1
7
+ date: 2006-07-22 00:00:00 +04:00
8
8
  summary: Cerberus is a Continuous Integration tool that could be easily run from Cron.
9
9
  require_paths:
10
10
  - lib
11
11
  email: anatol.pomozov@gmail.com
12
12
  homepage: http://rubyforge.org/projects/cerberus
13
13
  rubyforge_project: cerberus
14
- description: Cerberus is a Continuous Integration software for Ruby projects. CI helps you keep your project in a good shape. For now Cerberus only work with projects that use Subversion but in the future it would be provided support for other VCS. Cerberus could be easily invoked from Cron (for Unix) or nnCron (for Windows) utilities.
14
+ description: Cerberus is a Continuous Integration software for Ruby projects. CI helps you keep your project in a good shape. For now Cerberus only work with projects that use Subversion but in the future it would be provided support for other VCS. Cerberus could be easily invoked from Cron (for Unix) or nnCron (for Windows) utilities.
15
15
  autorequire:
16
16
  default_executable: cerberus
17
17
  bindir: bin
@@ -37,8 +37,10 @@ files:
37
37
  - lib/cerberus/constants.rb
38
38
  - lib/cerberus/latch.rb
39
39
  - lib/cerberus/manager.rb
40
+ - lib/cerberus/notifier
40
41
  - lib/cerberus/utils.rb
41
42
  - lib/cerberus/version.rb
43
+ - lib/cerberus/notifier/email.rb
42
44
  - test/config_test.rb
43
45
  - test/data
44
46
  - test/functional_test.rb