cerberus 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +159 -129
- data/LICENSE +21 -21
- data/README +75 -75
- data/Rakefile +161 -159
- data/bin/cerberus +2 -2
- data/lib/cerberus/builder/maven2.rb +38 -38
- data/lib/cerberus/builder/rake.rb +7 -7
- data/lib/cerberus/builder/rant.rb +7 -7
- data/lib/cerberus/builder/rspec.rb +13 -0
- data/lib/cerberus/builder/ruby_base.rb +48 -47
- data/lib/cerberus/cli.rb +73 -70
- data/lib/cerberus/component_lazy_loader.rb +2 -0
- data/lib/cerberus/config.example.yml +28 -28
- data/lib/cerberus/config.rb +47 -46
- data/lib/cerberus/constants.rb +8 -8
- data/lib/cerberus/latch.rb +26 -26
- data/lib/cerberus/manager.rb +296 -267
- data/lib/cerberus/publisher/base.rb +47 -47
- data/lib/cerberus/publisher/gmailer.rb +17 -0
- data/lib/cerberus/publisher/irc.rb +27 -27
- data/lib/cerberus/publisher/jabber.rb +25 -25
- data/lib/cerberus/publisher/mail.rb +36 -36
- data/lib/cerberus/publisher/netsmtp_tls_fix.rb +66 -66
- data/lib/cerberus/publisher/rss.rb +27 -28
- data/lib/cerberus/scm/cvs.rb +48 -48
- data/lib/cerberus/scm/darcs.rb +70 -70
- data/lib/cerberus/scm/svn.rb +83 -83
- data/lib/cerberus/utils.rb +156 -156
- data/test/config_test.rb +45 -45
- data/test/functional_test.rb +288 -287
- data/test/integration_test.rb +104 -104
- data/test/irc_publisher_test.rb +18 -18
- data/test/jabber_publisher_test.rb +21 -21
- data/test/mail_publisher_test.rb +25 -25
- data/test/maven2_builer_test.rb +81 -81
- data/test/mock/irc.rb +20 -20
- data/test/mock/manager.rb +10 -10
- data/test/mock/xmpp4r.rb +19 -19
- data/test/rss_publisher_test.rb +21 -21
- data/test/test_helper.rb +105 -105
- metadata +58 -40
- data/lib/cerberus/helper/xchar.rb +0 -61
@@ -1,47 +1,48 @@
|
|
1
|
-
require 'cerberus/builder/base'
|
2
|
-
|
3
|
-
class Cerberus::Builder::RubyBase
|
4
|
-
attr_reader :output
|
5
|
-
|
6
|
-
def initialize(config, cmd)
|
7
|
-
@config = config
|
8
|
-
@cmd = cmd
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
1
|
+
require 'cerberus/builder/base'
|
2
|
+
|
3
|
+
class Cerberus::Builder::RubyBase
|
4
|
+
attr_reader :output
|
5
|
+
|
6
|
+
def initialize(config, name, cmd = name)
|
7
|
+
@config = config
|
8
|
+
@cmd = cmd
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
Dir.chdir @config[:application_root]
|
14
|
+
@output = `#{@config[:bin_path]}#{choose_exec()} #{@config[:builder, @name.to_sym, :task]} 2>&1`
|
15
|
+
successful?
|
16
|
+
end
|
17
|
+
|
18
|
+
def successful?
|
19
|
+
$?.exitstatus == 0 and not @output.include?("#{@cmd} aborted!")
|
20
|
+
end
|
21
|
+
|
22
|
+
def brokeness
|
23
|
+
if @output =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
|
24
|
+
$1.to_i + $2.to_i
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def choose_exec
|
30
|
+
ext = ['']
|
31
|
+
|
32
|
+
if os() == :windows
|
33
|
+
ext << '.bat' << '.cmd'
|
34
|
+
end
|
35
|
+
|
36
|
+
silence_stream(STDERR) {
|
37
|
+
ext.each do |e|
|
38
|
+
begin
|
39
|
+
out = `#{@config[:bin_path]}#{@cmd}#{e} --version 2>&1`
|
40
|
+
return "#{@cmd}#{e}" if out =~ /#{@cmd}/
|
41
|
+
rescue
|
42
|
+
end
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
raise "#{@cmd} builder did not find. Make sure that such script exists and have executable permissions."
|
47
|
+
end
|
48
|
+
end
|
data/lib/cerberus/cli.rb
CHANGED
@@ -1,70 +1,73 @@
|
|
1
|
-
require 'cerberus/manager'
|
2
|
-
require 'cerberus/utils'
|
3
|
-
require 'cerberus/constants'
|
4
|
-
|
5
|
-
module Cerberus
|
6
|
-
class CLI
|
7
|
-
def initialize(*args)
|
8
|
-
say HELP if args.empty?
|
9
|
-
|
10
|
-
command = args.shift
|
11
|
-
say HELP unless %w(add build buildall list).include?(command)
|
12
|
-
|
13
|
-
cli_options = extract_options(args)
|
14
|
-
|
15
|
-
case command
|
16
|
-
when 'add'
|
17
|
-
path = args.shift || Dir.pwd
|
18
|
-
|
19
|
-
command
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
command
|
30
|
-
|
31
|
-
|
32
|
-
command
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
cerberus
|
63
|
-
cerberus
|
64
|
-
cerberus
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
|
1
|
+
require 'cerberus/manager'
|
2
|
+
require 'cerberus/utils'
|
3
|
+
require 'cerberus/constants'
|
4
|
+
|
5
|
+
module Cerberus
|
6
|
+
class CLI
|
7
|
+
def initialize(*args)
|
8
|
+
say HELP if args.empty?
|
9
|
+
|
10
|
+
command = args.shift
|
11
|
+
say HELP unless %w(add remove build buildall list).include?(command)
|
12
|
+
|
13
|
+
cli_options = extract_options(args)
|
14
|
+
|
15
|
+
case command
|
16
|
+
when 'add'
|
17
|
+
path = args.shift || Dir.pwd
|
18
|
+
command = Cerberus::AddCommand.new(path, cli_options)
|
19
|
+
command.run
|
20
|
+
when 'remove'
|
21
|
+
command = Cerberus::RemoveCommand.new(args.shift, cli_options)
|
22
|
+
command.run
|
23
|
+
when 'build'
|
24
|
+
say HELP if args.empty?
|
25
|
+
|
26
|
+
application_name = args.shift
|
27
|
+
|
28
|
+
command = Cerberus::BuildCommand.new(application_name, cli_options)
|
29
|
+
command.run
|
30
|
+
when 'buildall'
|
31
|
+
command = Cerberus::BuildAllCommand.new(cli_options)
|
32
|
+
command.run
|
33
|
+
when 'list'
|
34
|
+
command = Cerberus::ListCommand.new(cli_options)
|
35
|
+
command.run
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def extract_options(args)
|
41
|
+
result = {}
|
42
|
+
args_copy = args.dup
|
43
|
+
args_copy.each do |arg|
|
44
|
+
case arg
|
45
|
+
when /^(\w+)=(.*)$/
|
46
|
+
result[$1.downcase.to_sym] = $2
|
47
|
+
args.delete(arg)
|
48
|
+
when '--force'
|
49
|
+
result[:force] = true
|
50
|
+
args.delete(arg)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
result
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
HELP = %{
|
59
|
+
Cerberus is a lightweight command-line Continuous Integration tool for Ruby.
|
60
|
+
|
61
|
+
Usage:
|
62
|
+
cerberus add <URL> --- add project from svn repository to list watched of applications
|
63
|
+
cerberus add <PATH> --- add project from local path to list of watched applications
|
64
|
+
cerberus remove <NAME> --- remove given project from cerberus
|
65
|
+
cerberus build <NAME> --- build watched application
|
66
|
+
cerberus buildall --- build all watched applications
|
67
|
+
cerberus list --- see the list of all watched applications
|
68
|
+
|
69
|
+
Version: #{Cerberus::VERSION}
|
70
|
+
Cerberus Path: "#{Cerberus::HOME}"
|
71
|
+
Cerberus Homepage: http://cerberus.rubyforge.org
|
72
|
+
}.gsub("\n ","\n")
|
73
|
+
end
|
@@ -38,6 +38,7 @@ module Cerberus
|
|
38
38
|
module Publisher
|
39
39
|
TYPES = {
|
40
40
|
:mail => 'Mail', #Cerberus::Publisher
|
41
|
+
:gmailer => 'Gmailer',
|
41
42
|
:jabber => 'Jabber',
|
42
43
|
:irc => 'IRC',
|
43
44
|
:rss => 'RSS',
|
@@ -56,6 +57,7 @@ module Cerberus
|
|
56
57
|
TYPES = {
|
57
58
|
:maven2 => 'Maven2', #Cerberus::Builder
|
58
59
|
:rake => 'Rake',
|
60
|
+
:rspec => 'RSpec',
|
59
61
|
:rant => 'Rant',
|
60
62
|
:bjam => 'Bjam'
|
61
63
|
}
|
@@ -1,29 +1,29 @@
|
|
1
|
-
publisher:
|
2
|
-
# active: mail jabber rss campfire
|
3
|
-
mail:
|
4
|
-
address: smtp.gmail.com
|
5
|
-
port: 587
|
6
|
-
domain: gmail.com
|
7
|
-
authentication: plain
|
8
|
-
user_name: someuser
|
9
|
-
password: somepassword
|
10
|
-
# on_event: all
|
11
|
-
# jabber:
|
12
|
-
# jid: somemailbox@gmail.com/cerberus
|
13
|
-
# password: somepassword
|
14
|
-
# irc:
|
15
|
-
# nick: cerb
|
16
|
-
# server: irc.freenode.net
|
17
|
-
# channel: cerberus
|
18
|
-
# campfire:
|
19
|
-
# url: http://someemail:password@cerberustool.campfirenow.com/room/51660
|
20
|
-
# rss:
|
21
|
-
# file: /usr/www/rss.xml
|
22
|
-
#builder:
|
23
|
-
# rake:
|
24
|
-
# task: migrate test
|
25
|
-
#changeset_url: POINT_TO_YOUR_TRAC/changeset/
|
26
|
-
#hook:
|
27
|
-
# rcov:
|
28
|
-
# on_event: successful, setup #by default - run hook for any state
|
1
|
+
publisher:
|
2
|
+
# active: mail jabber rss campfire
|
3
|
+
mail:
|
4
|
+
address: smtp.gmail.com
|
5
|
+
port: 587
|
6
|
+
domain: gmail.com
|
7
|
+
authentication: plain
|
8
|
+
user_name: someuser
|
9
|
+
password: somepassword
|
10
|
+
# on_event: all
|
11
|
+
# jabber:
|
12
|
+
# jid: somemailbox@gmail.com/cerberus
|
13
|
+
# password: somepassword
|
14
|
+
# irc:
|
15
|
+
# nick: cerb
|
16
|
+
# server: irc.freenode.net
|
17
|
+
# channel: cerberus
|
18
|
+
# campfire:
|
19
|
+
# url: http://someemail:password@cerberustool.campfirenow.com/room/51660
|
20
|
+
# rss:
|
21
|
+
# file: /usr/www/rss.xml
|
22
|
+
#builder:
|
23
|
+
# rake:
|
24
|
+
# task: migrate test
|
25
|
+
#changeset_url: POINT_TO_YOUR_TRAC/changeset/
|
26
|
+
#hook:
|
27
|
+
# rcov:
|
28
|
+
# on_event: successful, setup #by default - run hook for any state
|
29
29
|
# action: 'export CERBERUS_HOME=/home/anatol && sudo chown www-data -R /home/anatol/cerberus && rcov' #Add here any hook you want
|
data/lib/cerberus/config.rb
CHANGED
@@ -1,47 +1,48 @@
|
|
1
|
-
require 'cerberus/constants'
|
2
|
-
require 'cerberus/utils'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
merge!(YAML.load(IO.read(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
d.
|
30
|
-
@config
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
1
|
+
require 'cerberus/constants'
|
2
|
+
require 'cerberus/utils'
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module Cerberus
|
6
|
+
class Config
|
7
|
+
def initialize(app_name = nil, cli_options = {})
|
8
|
+
@config = HashWithIndifferentAccess.new
|
9
|
+
if app_name
|
10
|
+
merge!(YAML.load(ERB.new(IO.read(CONFIG_FILE)).result)) if test(?f, CONFIG_FILE)
|
11
|
+
merge!(YAML.load(ERB.new(IO.read(HOME + "/config/#{app_name}.yml")).result))
|
12
|
+
end
|
13
|
+
merge!(cli_options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](*path)
|
17
|
+
c = @config
|
18
|
+
path.each{|p|
|
19
|
+
c = c[p]
|
20
|
+
return if c.nil?
|
21
|
+
}
|
22
|
+
c
|
23
|
+
end
|
24
|
+
|
25
|
+
def merge!(hash, overwrite = true)
|
26
|
+
if overwrite
|
27
|
+
@config.deep_merge!(hash)
|
28
|
+
else
|
29
|
+
d = HashWithIndifferentAccess.new(hash)
|
30
|
+
d.deep_merge!(@config)
|
31
|
+
@config = d
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def inspect
|
36
|
+
@config.inspect
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def symbolize_hash(hash)
|
41
|
+
hash.each_pair{|k,v|
|
42
|
+
if v === Hash
|
43
|
+
hash[k] = HashWithIndifferentAccess.new(symbolize_hash(v))
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
47
48
|
end
|
data/lib/cerberus/constants.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
module Cerberus
|
2
|
-
HOME = File.expand_path(ENV['CERBERUS_HOME'] || '~/.cerberus')
|
3
|
-
CONFIG_FILE = "#{HOME}/config.yml"
|
4
|
-
|
5
|
-
LOCK_WAIT = 30 * 60 #30 minutes
|
6
|
-
|
7
|
-
VERSION = '0.3.
|
8
|
-
end
|
1
|
+
module Cerberus
|
2
|
+
HOME = File.expand_path(ENV['CERBERUS_HOME'] || '~/.cerberus')
|
3
|
+
CONFIG_FILE = "#{HOME}/config.yml"
|
4
|
+
|
5
|
+
LOCK_WAIT = 30 * 60 #30 minutes
|
6
|
+
|
7
|
+
VERSION = '0.3.6'
|
8
|
+
end
|
data/lib/cerberus/latch.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Cerberus
|
4
|
-
class Latch
|
5
|
-
#Emulate File.flock
|
6
|
-
def self.lock(lock_file, options = {})
|
7
|
-
if File.exists?(lock_file)
|
8
|
-
modif_time = File::Stat.new(lock_file).mtime
|
9
|
-
ttl = options[:lock_ttl]
|
10
|
-
|
11
|
-
if ttl and modif_time + ttl < Time.now
|
12
|
-
File.delete(lock_file)
|
13
|
-
else
|
14
|
-
return
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
FileUtils.mkpath(File.dirname(lock_file))
|
20
|
-
File.new(lock_file, 'w').close
|
21
|
-
yield
|
22
|
-
ensure
|
23
|
-
File.delete(lock_file)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Cerberus
|
4
|
+
class Latch
|
5
|
+
#Emulate File.flock
|
6
|
+
def self.lock(lock_file, options = {})
|
7
|
+
if File.exists?(lock_file)
|
8
|
+
modif_time = File::Stat.new(lock_file).mtime
|
9
|
+
ttl = options[:lock_ttl]
|
10
|
+
|
11
|
+
if ttl and modif_time + ttl < Time.now
|
12
|
+
File.delete(lock_file)
|
13
|
+
else
|
14
|
+
return
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
FileUtils.mkpath(File.dirname(lock_file))
|
20
|
+
File.new(lock_file, 'w').close
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
File.delete(lock_file)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|