propel 0.0.3 → 0.0.4
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/Gemfile.lock +1 -1
- data/lib/propel/runner.rb +41 -17
- data/lib/propel/version.rb +1 -1
- data/spec/propel/runner_spec.rb +13 -6
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/propel/runner.rb
CHANGED
@@ -8,7 +8,13 @@ module Propel
|
|
8
8
|
git_repository = GitRepository.new
|
9
9
|
|
10
10
|
if git_repository.changed?
|
11
|
-
|
11
|
+
if remote_build_configured?
|
12
|
+
check_remote_build! unless ignore_remote_build?
|
13
|
+
|
14
|
+
else
|
15
|
+
puts "Remote build is not configured, skipping check." if @options[:verbose]
|
16
|
+
end
|
17
|
+
|
12
18
|
propel!
|
13
19
|
else
|
14
20
|
puts "There is nothing to propel - your HEAD is identical to #{git_repository.remote_config} #{git_repository.merge_config}."
|
@@ -18,17 +24,42 @@ module Propel
|
|
18
24
|
private
|
19
25
|
|
20
26
|
def check_remote_build!
|
21
|
-
if
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
if @options[:wait]
|
28
|
+
unless remote_build_green?
|
29
|
+
wait_with_notice do
|
30
|
+
log_wait_notice
|
31
|
+
wait until remote_build_green?
|
32
|
+
puts "\nThe build has been fixed."
|
33
|
+
end
|
25
34
|
end
|
26
35
|
|
27
36
|
else
|
28
|
-
|
37
|
+
|
38
|
+
alert_broken_build_and_exit unless remote_build_green?
|
29
39
|
end
|
30
40
|
end
|
31
41
|
|
42
|
+
def wait_with_notice
|
43
|
+
start_time = Time.now
|
44
|
+
yield
|
45
|
+
end_time = Time.now
|
46
|
+
puts "We waited for #{(end_time - start_time).round} seconds while the build was failing."
|
47
|
+
end
|
48
|
+
|
49
|
+
def log_wait_notice
|
50
|
+
puts "The remote build is failing, waiting until it is green to proceed."
|
51
|
+
end
|
52
|
+
|
53
|
+
def alert_broken_build_and_exit
|
54
|
+
msg = <<-EOS
|
55
|
+
The remote build is broken. If your commit fixes the build, run propel with the --force (-f) option.
|
56
|
+
If you're waiting for someone else to fix the build, use propel with --wait (-w).
|
57
|
+
EOS
|
58
|
+
|
59
|
+
$stderr.puts msg.split("\n").map(&:strip)
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
|
32
63
|
def ignore_remote_build?
|
33
64
|
@options[:force]
|
34
65
|
end
|
@@ -37,17 +68,10 @@ module Propel
|
|
37
68
|
!@options[:status_url].nil?
|
38
69
|
end
|
39
70
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
sleep 10
|
45
|
-
end
|
46
|
-
|
47
|
-
true
|
48
|
-
else
|
49
|
-
remote_build_green?
|
50
|
-
end
|
71
|
+
def wait
|
72
|
+
print "."
|
73
|
+
STDOUT.flush
|
74
|
+
sleep 5
|
51
75
|
end
|
52
76
|
|
53
77
|
def remote_build_green?
|
data/lib/propel/version.rb
CHANGED
data/spec/propel/runner_spec.rb
CHANGED
@@ -29,8 +29,8 @@ describe Propel::Runner do
|
|
29
29
|
|
30
30
|
it "should call propel! if the remote build is configured and passing" do
|
31
31
|
runner = Propel::Runner.new(%w[ --status-url http://ci.example.com/status ])
|
32
|
-
runner.stub!(:remote_build_passing?).and_return(true)
|
33
32
|
runner.stub!(:remote_build_configured?).and_return(true)
|
33
|
+
runner.stub!(:remote_build_green?).and_return(true)
|
34
34
|
|
35
35
|
runner.should_receive(:propel!)
|
36
36
|
|
@@ -45,16 +45,18 @@ describe Propel::Runner do
|
|
45
45
|
runner.start
|
46
46
|
end
|
47
47
|
|
48
|
-
|
48
|
+
class TestError < StandardError ; end
|
49
|
+
it "should send an alert about the broken build if the remote build is configured but not passing" do
|
49
50
|
runner = Propel::Runner.new
|
50
51
|
runner.stub!(:remote_build_configured?).and_return true
|
51
|
-
runner.stub!(:
|
52
|
-
|
52
|
+
runner.stub!(:remote_build_green?).and_return false
|
53
|
+
|
54
|
+
runner.should_receive(:alert_broken_build_and_exit).and_raise(TestError.new("Execution should be aborted here"))
|
53
55
|
runner.should_not_receive(:propel!)
|
54
56
|
|
55
57
|
lambda {
|
56
58
|
runner.start
|
57
|
-
}.should raise_error(
|
59
|
+
}.should raise_error(TestError)
|
58
60
|
end
|
59
61
|
|
60
62
|
it "should call propel! when the remote build is failing if --force is specified" do
|
@@ -94,8 +96,13 @@ describe Propel::Runner do
|
|
94
96
|
|
95
97
|
runner.should_receive(:remote_build_green?).twice.and_return(false, true)
|
96
98
|
|
99
|
+
runner.should_receive(:log_wait_notice)
|
100
|
+
|
101
|
+
runner.should_receive(:wait_with_notice).and_yield
|
102
|
+
|
103
|
+
runner.stub!(:puts)
|
97
104
|
runner.stub!(:print).with('.')
|
98
|
-
runner.stub!(:sleep).with(
|
105
|
+
runner.stub!(:sleep).with(5)
|
99
106
|
|
100
107
|
runner.should_receive(:propel!)
|
101
108
|
runner.start
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Leitgeb
|