cijoe 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -8
- data/Rakefile +0 -2
- data/lib/cijoe.rb +8 -11
- data/lib/cijoe/campfire.rb +14 -9
- data/lib/cijoe/config.rb +1 -1
- data/lib/cijoe/server.rb +9 -3
- data/lib/cijoe/version.rb +1 -1
- data/test/helper.rb +2 -0
- data/test/test_cijoe_server.rb +5 -0
- metadata +15 -4
data/README.md
CHANGED
@@ -7,7 +7,9 @@ server that'll run your tests on demand and report their pass/fail status.
|
|
7
7
|
|
8
8
|
Because knowing is half the battle.
|
9
9
|
|
10
|
-
![The Battle](http://img.skitch.com/20090805-g4a2qhttwij8n2jr9t552efn3k.png)
|
10
|
+
[![The Battle](http://img.skitch.com/20090805-g4a2qhttwij8n2jr9t552efn3k.png)](http://nerduo.com/thebattle/)
|
11
|
+
|
12
|
+
([Buy the shirt](http://nerduo.com/thebattle/))
|
11
13
|
|
12
14
|
Quickstart
|
13
15
|
----------
|
@@ -75,17 +77,16 @@ Campfire notification is included, because it's what we use. Want Joe
|
|
75
77
|
notify your Campfire? Put this in your repo's `.git/config`:
|
76
78
|
|
77
79
|
[campfire]
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
Note: your API token may differ between subdomains!
|
80
|
+
user = your@campfire.email
|
81
|
+
pass = passw0rd
|
82
|
+
subdomain = whatever
|
83
|
+
room = Awesomeness
|
84
|
+
ssl = false
|
84
85
|
|
85
86
|
Or do it the old fashion way:
|
86
87
|
|
87
88
|
$ cd yourrepo
|
88
|
-
$ git config --add campfire.
|
89
|
+
$ git config --add campfire.user chris@ozmm.org
|
89
90
|
$ git config --add campfire.subdomain github
|
90
91
|
etc.
|
91
92
|
|
data/Rakefile
CHANGED
data/lib/cijoe.rb
CHANGED
@@ -89,7 +89,7 @@ class CIJoe
|
|
89
89
|
|
90
90
|
# run the build but make sure only one is running
|
91
91
|
# at a time (if new one comes in we will park it)
|
92
|
-
def build
|
92
|
+
def build(branch=nil)
|
93
93
|
if building?
|
94
94
|
# only if switched on to build all incoming requests
|
95
95
|
if !repo_config.buildallfile.to_s.empty?
|
@@ -103,7 +103,7 @@ class CIJoe
|
|
103
103
|
end
|
104
104
|
@current_build = Build.new(@project_path, @user, @project)
|
105
105
|
write_build 'current', @current_build
|
106
|
-
Thread.new { build! }
|
106
|
+
Thread.new { build!(branch) }
|
107
107
|
end
|
108
108
|
|
109
109
|
def open_pipe(cmd)
|
@@ -121,7 +121,8 @@ class CIJoe
|
|
121
121
|
end
|
122
122
|
|
123
123
|
# update git then run the build
|
124
|
-
def build!
|
124
|
+
def build!(branch=nil)
|
125
|
+
@git_branch = branch
|
125
126
|
build = @current_build
|
126
127
|
output = ''
|
127
128
|
git_update
|
@@ -166,8 +167,9 @@ class CIJoe
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def git_branch
|
170
|
+
return @git_branch if @git_branch
|
169
171
|
branch = repo_config.branch.to_s
|
170
|
-
branch == '' ? "master" : branch
|
172
|
+
@git_branch = branch == '' ? "master" : branch
|
171
173
|
end
|
172
174
|
|
173
175
|
# massage our repo
|
@@ -194,13 +196,8 @@ class CIJoe
|
|
194
196
|
|
195
197
|
# restore current / last build state from disk.
|
196
198
|
def restore
|
197
|
-
|
198
|
-
|
199
|
-
end
|
200
|
-
|
201
|
-
unless @current_build
|
202
|
-
@current_build = read_build('current')
|
203
|
-
end
|
199
|
+
@last_build = read_build('last')
|
200
|
+
@current_build = read_build('current')
|
204
201
|
|
205
202
|
Process.kill(0, @current_build.pid) if @current_build && @current_build.pid
|
206
203
|
rescue Errno::ESRCH
|
data/lib/cijoe/campfire.rb
CHANGED
@@ -11,11 +11,12 @@ class CIJoe
|
|
11
11
|
end
|
12
12
|
|
13
13
|
puts "Loaded Campfire notifier"
|
14
|
-
|
14
|
+
elsif ENV['RACK_ENV'] != 'test'
|
15
15
|
puts "Can't load Campfire notifier."
|
16
16
|
puts "Please add the following to your project's .git/config:"
|
17
17
|
puts "[campfire]"
|
18
|
-
puts "\
|
18
|
+
puts "\tuser = your@campfire.email"
|
19
|
+
puts "\tpass = passw0rd"
|
19
20
|
puts "\tsubdomain = whatever"
|
20
21
|
puts "\troom = Awesomeness"
|
21
22
|
puts "\tssl = false"
|
@@ -25,15 +26,16 @@ class CIJoe
|
|
25
26
|
def self.config
|
26
27
|
campfire_config = Config.new('campfire', @project_path)
|
27
28
|
@config ||= {
|
28
|
-
:subdomain =>
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
29
|
+
:subdomain => campfire_config.subdomain.to_s,
|
30
|
+
:user => campfire_config.user.to_s,
|
31
|
+
:pass => campfire_config.pass.to_s,
|
32
|
+
:room => campfire_config.room.to_s,
|
33
|
+
:ssl => campfire_config.ssl.to_s.strip == 'true'
|
32
34
|
}
|
33
35
|
end
|
34
36
|
|
35
37
|
def self.valid_config?
|
36
|
-
%w( subdomain
|
38
|
+
%w( subdomain user pass room ).all? do |key|
|
37
39
|
!config[key.intern].empty?
|
38
40
|
end
|
39
41
|
end
|
@@ -49,14 +51,17 @@ class CIJoe
|
|
49
51
|
@room ||= begin
|
50
52
|
config = Campfire.config
|
51
53
|
campfire = Tinder::Campfire.new(config[:subdomain],
|
52
|
-
:
|
54
|
+
:username => config[:user],
|
55
|
+
:password => config[:pass],
|
53
56
|
:ssl => config[:ssl] || false)
|
54
57
|
campfire.find_room_by_name(config[:room])
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
61
|
def short_message
|
59
|
-
"Build #{short_sha} of #{project}
|
62
|
+
"Build #{short_sha} of #{project} " +
|
63
|
+
(worked? ? "was successful" : "failed") +
|
64
|
+
" (#{duration.to_i}s)"
|
60
65
|
end
|
61
66
|
|
62
67
|
def full_message
|
data/lib/cijoe/config.rb
CHANGED
data/lib/cijoe/server.rb
CHANGED
@@ -27,10 +27,16 @@ class CIJoe
|
|
27
27
|
end
|
28
28
|
|
29
29
|
post '/?' do
|
30
|
-
payload = params[:payload].to_s
|
31
|
-
|
32
|
-
|
30
|
+
payload = YAML.load(params[:payload].to_s) || {}
|
31
|
+
pushed_branch = payload[:ref].to_s.split('/').last
|
32
|
+
|
33
|
+
# Only build if we were given an explicit branch via `?branch=blah`,
|
34
|
+
# no payload exists (we're probably testing), or the payload exists and
|
35
|
+
# the "ref" property matches our specified build branch.
|
36
|
+
if params[:branch] || payload.empty? || pushed_branch == joe.git_branch
|
37
|
+
joe.build(params[:branch])
|
33
38
|
end
|
39
|
+
|
34
40
|
redirect request.path
|
35
41
|
end
|
36
42
|
|
data/lib/cijoe/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_cijoe_server.rb
CHANGED
@@ -13,6 +13,11 @@ class TestCIJoeServer < Test::Unit::TestCase
|
|
13
13
|
|
14
14
|
def setup
|
15
15
|
@app = CIJoe::Server.new
|
16
|
+
# make Build#restore a no-op so we don't overwrite our current/last
|
17
|
+
# build attributes set from tests.
|
18
|
+
joe = @app.joe
|
19
|
+
def joe.restore
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def test_ping
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cijoe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 63
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 8
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Chris Wanstrath
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
+
date: 2011-02-04 00:00:00 -08:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: choice
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: sinatra
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -45,9 +50,11 @@ dependencies:
|
|
45
50
|
name: rack-test
|
46
51
|
prerelease: false
|
47
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
55
|
- - ">="
|
50
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
51
58
|
segments:
|
52
59
|
- 0
|
53
60
|
version: "0"
|
@@ -90,23 +97,27 @@ rdoc_options: []
|
|
90
97
|
require_paths:
|
91
98
|
- lib
|
92
99
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
93
101
|
requirements:
|
94
102
|
- - ">="
|
95
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
96
105
|
segments:
|
97
106
|
- 0
|
98
107
|
version: "0"
|
99
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
100
110
|
requirements:
|
101
111
|
- - ">="
|
102
112
|
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
103
114
|
segments:
|
104
115
|
- 0
|
105
116
|
version: "0"
|
106
117
|
requirements: []
|
107
118
|
|
108
119
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.3.
|
120
|
+
rubygems_version: 1.3.7
|
110
121
|
signing_key:
|
111
122
|
specification_version: 3
|
112
123
|
summary: cijoe builds your builds.
|