cruisestatus 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +9 -9
- data/Rakefile +7 -0
- data/cruisestatus.gemspec +5 -2
- data/lib/cruisestatus/command.rb +59 -42
- data/lib/cruisestatus/version.rb +1 -1
- data/spec/cruisestatus/command_spec.rb +21 -15
- data/spec/cruisestatus/run_code_run_parser_spec.rb +16 -0
- data/spec/spec_helper.rb +2 -2
- metadata +12 -2
data/README.rdoc
CHANGED
@@ -44,28 +44,28 @@ enters 'y' at the prompt, +cruisestatus+ will return a zero status regardless
|
|
44
44
|
of build failures.
|
45
45
|
|
46
46
|
For example:
|
47
|
-
|
47
|
+
$ cruisestatus -p http://runcoderun.com/api/v1/json/tobytripp
|
48
48
|
|
49
49
|
Build FAILURES: cruisestatus
|
50
50
|
Are you sure you want to check in? (y/n): y
|
51
51
|
|
52
|
-
|
52
|
+
$ echo $?
|
53
53
|
0
|
54
54
|
|
55
|
-
|
55
|
+
$ cruisestatus -p http://runcoderun.com/api/v1/json/tobytripp
|
56
56
|
|
57
57
|
Build FAILURES: cruisestatus
|
58
58
|
Are you sure you want to check in? (y/n): n
|
59
59
|
|
60
|
-
|
60
|
+
$ echo $?
|
61
61
|
1
|
62
|
-
toby@Tobys-Mac:(git)cruisestatus[master]/$
|
63
62
|
|
64
63
|
You can use this to abort check-ins onto broken builds. (See the post-commit
|
65
|
-
hook in
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
hook in
|
65
|
+
http://github.com/tobytripp/git-pre-commit/blob/master/git-hooks/post-commit
|
66
|
+
for example). As you know, if the CI build is broken, no one should be
|
67
|
+
checking in new code unless they're fixing the build. You can use
|
68
|
+
+cruisestatus+ to help keep developers honest in that regard.
|
69
69
|
|
70
70
|
== Note on Patches/Pull Requests
|
71
71
|
|
data/Rakefile
CHANGED
@@ -8,11 +8,16 @@ begin
|
|
8
8
|
gem.name = "cruisestatus"
|
9
9
|
gem.summary = %Q{Check the build status on a cruise.rb server}
|
10
10
|
gem.description = %Q{Allows scripts and applications to check the status of your project's build.}
|
11
|
+
|
11
12
|
gem.email = "toby.tripp+git@gmail.com"
|
12
13
|
gem.homepage = "http://github.com/tobytripp/cruisestatus"
|
13
14
|
gem.authors = ["Toby Tripp"]
|
15
|
+
|
14
16
|
gem.version = CruiseStatus::Version::STRING
|
17
|
+
|
15
18
|
gem.add_dependency "json_pure", ">= 1.2.0"
|
19
|
+
gem.add_dependency "highline", ">= 1.5.2"
|
20
|
+
|
16
21
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
17
22
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
23
|
end
|
@@ -27,6 +32,8 @@ Spec::Rake::SpecTask.new
|
|
27
32
|
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
33
|
spec.pattern = 'spec/**/*_spec.rb'
|
29
34
|
spec.rcov = true
|
35
|
+
|
36
|
+
spec.rcov_opts = ['--exclude', 'lib\/spec,bin\/spec,gems,spec_helper']
|
30
37
|
end
|
31
38
|
|
32
39
|
task :spec => :check_dependencies
|
data/cruisestatus.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cruisestatus}
|
8
|
-
s.version = "1.3.
|
8
|
+
s.version = "1.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Toby Tripp"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-11}
|
13
13
|
s.default_executable = %q{cruisestatus}
|
14
14
|
s.description = %q{Allows scripts and applications to check the status of your project's build.}
|
15
15
|
s.email = %q{toby.tripp+git@gmail.com}
|
@@ -61,13 +61,16 @@ Gem::Specification.new do |s|
|
|
61
61
|
|
62
62
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
63
63
|
s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
|
64
|
+
s.add_runtime_dependency(%q<highline>, [">= 1.5.2"])
|
64
65
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
65
66
|
else
|
66
67
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
68
|
+
s.add_dependency(%q<highline>, [">= 1.5.2"])
|
67
69
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
68
70
|
end
|
69
71
|
else
|
70
72
|
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
73
|
+
s.add_dependency(%q<highline>, [">= 1.5.2"])
|
71
74
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
72
75
|
end
|
73
76
|
end
|
data/lib/cruisestatus/command.rb
CHANGED
@@ -1,20 +1,14 @@
|
|
1
|
-
require "readline"
|
2
1
|
require "optparse"
|
2
|
+
|
3
|
+
require "highline"
|
4
|
+
require "highline/import"
|
3
5
|
require "cruisestatus/version"
|
4
6
|
|
5
7
|
class CruiseStatus::Command
|
6
|
-
|
7
|
-
|
8
|
-
def self.run!( argv )
|
9
|
-
@prompt = nil
|
10
|
-
|
11
|
-
opts = OptionParser.new do |o|
|
12
|
-
o.version = CruiseStatus::Version::STRING
|
13
|
-
o.release = CruiseStatus::Version::RELEASE
|
14
|
-
o.banner = <<-EOS
|
8
|
+
USAGE = <<-EOS
|
15
9
|
Usage: #{File.basename($0)} [options] BUILD_URL
|
16
10
|
|
17
|
-
|
11
|
+
Reads the feed at BUILD_URL and reports if the build[s] passed.
|
18
12
|
|
19
13
|
Examples:
|
20
14
|
# CruiseControl.rb:
|
@@ -24,47 +18,70 @@ class CruiseStatus::Command
|
|
24
18
|
|
25
19
|
# RunCodeRun.com:
|
26
20
|
#{File.basename($0)} http://runcoderun.com/api/v1/json/myusername
|
27
|
-
|
21
|
+
|
28
22
|
Options:
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
EOS
|
24
|
+
|
25
|
+
DEFAULT_PROMPT = "Are you <%= color 'sure', :underline %> you want to check in? (y/n): "
|
26
|
+
|
27
|
+
attr_writer :prompt
|
28
|
+
|
29
|
+
def self.run!( argv )
|
30
|
+
self.new.run( argv )
|
31
|
+
end
|
32
|
+
|
33
|
+
def are_you_sure?( status )
|
34
|
+
agree( prompt ) ? 0 : 1
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize()
|
38
|
+
@prompt = false
|
39
|
+
end
|
40
|
+
|
41
|
+
def run( argv )
|
42
|
+
argv = parse_options( argv )
|
43
|
+
|
44
|
+
return Kernel.abort( @options.to_s ) if argv.empty?
|
45
|
+
|
46
|
+
status = CruiseStatus.new argv.last
|
47
|
+
|
48
|
+
if status.pass?
|
49
|
+
say "Build <%= color 'PASSED', :green, :bold %>"
|
50
|
+
0
|
51
|
+
else
|
52
|
+
say "Build <%= color 'FAILURES', :red, :bold %>:"
|
53
|
+
status.failures.each do |failure|
|
54
|
+
say " * " + $terminal.color( failure, :red )
|
55
|
+
end
|
56
|
+
return are_you_sure?( status ) if @prompt
|
57
|
+
1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse_options( argv )
|
62
|
+
@options = OptionParser.new do |option|
|
63
|
+
option.version = CruiseStatus::Version::STRING
|
64
|
+
option.release = CruiseStatus::Version::RELEASE
|
65
|
+
option.banner = CruiseStatus::Command::USAGE
|
66
|
+
|
67
|
+
option.on(
|
32
68
|
"-p", "--prompt", "=[PROMPT]",
|
33
69
|
"Prompt the user if the build has failed.",
|
34
|
-
"#{File.basename($0)} will exit with a non-zero status if the user
|
70
|
+
"#{File.basename($0)} will exit with a non-zero status if the user " \
|
71
|
+
"does not respond 'y' to the prompt."
|
35
72
|
) do |val|
|
36
73
|
if val == true
|
37
|
-
|
74
|
+
self.prompt = DEFAULT_PROMPT
|
38
75
|
else
|
39
|
-
|
76
|
+
self.prompt = val
|
40
77
|
end
|
41
78
|
end
|
42
79
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
if argv.empty?
|
47
|
-
abort opts.to_s
|
48
|
-
else
|
49
|
-
status = CruiseStatus.new argv.last
|
50
|
-
|
51
|
-
if status.pass?
|
52
|
-
puts "Build PASSED"
|
53
|
-
0
|
54
|
-
else
|
55
|
-
return are_you_sure?( status ) if @prompt
|
56
|
-
1
|
57
|
-
end
|
58
|
-
end
|
80
|
+
|
81
|
+
@options.parse! argv
|
59
82
|
end
|
60
83
|
|
61
|
-
def
|
62
|
-
|
63
|
-
input = ""
|
64
|
-
while( input && input.strip.empty? )
|
65
|
-
input = Readline.readline @prompt
|
66
|
-
end
|
67
|
-
|
68
|
-
input.strip.downcase[0,1] == "y" ? 0 : 1
|
84
|
+
def prompt
|
85
|
+
@prompt || DEFAULT_PROMPT
|
69
86
|
end
|
70
87
|
end
|
data/lib/cruisestatus/version.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe CruiseStatus::Command do
|
4
4
|
before :each do
|
5
5
|
@status = mock( "cruisestatus" )
|
6
6
|
@status.stub!( :pass? ).and_return true
|
7
7
|
@status.stub!( :failure_message ).and_return "FAILURES"
|
8
|
+
@status.stub!( :failures ).and_return %w[failedBuild1 failedBuild2]
|
8
9
|
|
9
10
|
CruiseStatus.stub!( :new ).with( "url" ).and_return @status
|
11
|
+
|
12
|
+
@old_terminal = $terminal
|
13
|
+
$terminal = HighLine.new( StringIO.new, @output = StringIO.new )
|
14
|
+
end
|
15
|
+
|
16
|
+
after :each do
|
17
|
+
$terminal = @old_terminal
|
10
18
|
end
|
11
19
|
|
12
20
|
it "passes the given url to the cruise status checker" do
|
@@ -25,48 +33,46 @@ describe CruiseStatus::Command do
|
|
25
33
|
end
|
26
34
|
|
27
35
|
it "aborts if no url is provided" do
|
28
|
-
|
36
|
+
Kernel.should_receive( :abort )
|
29
37
|
CruiseStatus::Command.run! []
|
30
38
|
end
|
31
39
|
|
32
|
-
|
33
40
|
describe "when given the 'prompt' option" do
|
34
41
|
before :each do
|
35
42
|
@status.stub!( :pass? ).and_return false
|
36
43
|
end
|
37
44
|
|
38
45
|
it "passes the url to the status checker" do
|
39
|
-
|
46
|
+
$terminal.should_receive( :agree ).
|
40
47
|
with( CruiseStatus::Command::DEFAULT_PROMPT ).
|
41
|
-
and_return
|
48
|
+
and_return true
|
49
|
+
CruiseStatus.should_receive( :new ).with( "url" ).and_return @status
|
42
50
|
|
43
51
|
CruiseStatus::Command.run! %w[-p url]
|
44
52
|
end
|
45
53
|
|
46
54
|
it "prompts the user if the build has failed" do
|
47
|
-
|
55
|
+
$terminal.should_receive( :agree ).
|
48
56
|
with( CruiseStatus::Command::DEFAULT_PROMPT ).
|
49
|
-
and_return
|
57
|
+
and_return true
|
50
58
|
|
51
|
-
|
52
|
-
CruiseStatus::Command.run! %w[-p url]
|
53
|
-
end
|
59
|
+
CruiseStatus::Command.run! %w[-p url]
|
54
60
|
|
55
|
-
output.should
|
61
|
+
@output.string.should =~ /Build.*FAILURES/
|
56
62
|
end
|
57
63
|
|
58
64
|
it "returns 0 if the user enters 'y' at the prompt" do
|
59
|
-
|
65
|
+
$terminal.should_receive( :agree ).
|
60
66
|
with( CruiseStatus::Command::DEFAULT_PROMPT ).
|
61
|
-
and_return
|
67
|
+
and_return true
|
62
68
|
|
63
69
|
CruiseStatus::Command.run!( %w[-p url] ).should == 0
|
64
70
|
end
|
65
71
|
|
66
72
|
it "returns 1 if the user enters 'n' at the prompt" do
|
67
|
-
|
73
|
+
$terminal.should_receive( :agree ).
|
68
74
|
with( CruiseStatus::Command::DEFAULT_PROMPT ).
|
69
|
-
and_return
|
75
|
+
and_return false
|
70
76
|
|
71
77
|
CruiseStatus::Command.run!( %w[-p url] ).should == 1
|
72
78
|
end
|
@@ -25,6 +25,22 @@ describe CruiseStatus::RunCodeRunParser do
|
|
25
25
|
@parser.failures.should == ["cruisestatus"]
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe "on connection error" do
|
30
|
+
before :each do
|
31
|
+
io = StringIO.new "/"
|
32
|
+
io.stub!( :read ).and_raise Exception
|
33
|
+
|
34
|
+
@parser = CruiseStatus::RunCodeRunParser.new io
|
35
|
+
@parser.check
|
36
|
+
end
|
37
|
+
|
38
|
+
it "reports the error as a failure" do
|
39
|
+
@parser.failures.should_not be_empty
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
28
44
|
end
|
29
45
|
|
30
46
|
RCR_PASS_RESPONSE = <<-EOS
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
1
|
+
$LOAD_PATH.unshift( File.dirname(__FILE__) )
|
2
|
+
$LOAD_PATH.unshift( File.join(File.dirname(__FILE__), '..', 'lib') )
|
3
3
|
|
4
4
|
require "rubygems"
|
5
5
|
require 'spec'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cruisestatus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Tripp
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-11 00:00:00 -06:00
|
13
13
|
default_executable: cruisestatus
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.2.0
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: highline
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.5.2
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: rspec
|
27
37
|
type: :development
|