build-buddy 1.14.3 → 1.14.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/build-buddy +0 -2
- data/lib/build_buddy.rb +1 -1
- data/lib/build_buddy/build_data.rb +2 -1
- data/lib/build_buddy/scheduler.rb +4 -0
- data/lib/build_buddy/server.rb +1 -0
- data/lib/build_buddy/slacker.rb +122 -114
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a586377dab8683cfbe1cb9d42db7087a463d08be
|
4
|
+
data.tar.gz: 42b507512d9bc9f47c4efad3e3bf8af6d82b44ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1608c1fa5a9cadacc27178691c179a1046aa2ecdc6414b342658afd68d7d2d821a546077a4bf339814800808f548d333c33bfd790f46692ee5b3f542960fc573
|
7
|
+
data.tar.gz: e85a33cfd8dc8b0ed97771f9d4f4a3c2a4e35c7a9ced76fdb76d0541aeab93f589855a3083570d2648a8b689743a870d7bf39cff3bb2e9802d94222d362e448e
|
data/bin/build-buddy
CHANGED
data/lib/build_buddy.rb
CHANGED
@@ -24,6 +24,7 @@ module BuildBuddy
|
|
24
24
|
attr_accessor :repo_full_name
|
25
25
|
attr_accessor :branch
|
26
26
|
attr_accessor :pull_request
|
27
|
+
attr_accessor :pull_request_title
|
27
28
|
attr_accessor :repo_sha
|
28
29
|
attr_accessor :termination_type # :killed or :exited
|
29
30
|
attr_accessor :started_by
|
@@ -53,7 +54,7 @@ module BuildBuddy
|
|
53
54
|
|
54
55
|
def to_h
|
55
56
|
hash = {}
|
56
|
-
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
57
|
+
instance_variables.each {|var| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) }
|
57
58
|
hash
|
58
59
|
end
|
59
60
|
|
@@ -77,6 +77,10 @@ module BuildBuddy
|
|
77
77
|
i = @build_queue.find_index { |build_data| build_data.bb_id == bb_id}
|
78
78
|
if i != nil
|
79
79
|
build_data = @build_queue[i]
|
80
|
+
if build_data.build_type == :pull_request
|
81
|
+
Celluloid::Actor[:gitter].async.set_status(
|
82
|
+
build_data.repo_full_name, build_data.repo_sha, :killed, "Build was dequeued", nil)
|
83
|
+
end
|
80
84
|
@build_queue.delete_at(i)
|
81
85
|
return :in_queue
|
82
86
|
end
|
data/lib/build_buddy/server.rb
CHANGED
@@ -36,6 +36,7 @@ module BuildBuddy
|
|
36
36
|
build_data = BuildData.new(
|
37
37
|
:type => :pull_request,
|
38
38
|
:pull_request => pull_request['number'],
|
39
|
+
:pull_request_title => pull_request['title'],
|
39
40
|
:flags => {},
|
40
41
|
:repo_sha => pull_request['head']['sha'],
|
41
42
|
:repo_full_name => pull_request['base']['repo']['full_name'],
|
data/lib/build_buddy/slacker.rb
CHANGED
@@ -28,8 +28,8 @@ module BuildBuddy
|
|
28
28
|
|
29
29
|
begin
|
30
30
|
@rt_client.start_async
|
31
|
-
rescue
|
32
|
-
info "Unable to connect to Slack"
|
31
|
+
rescue Exception => e
|
32
|
+
info "Unable to connect to Slack - #{e.message}"
|
33
33
|
self.terminate
|
34
34
|
end
|
35
35
|
|
@@ -91,11 +91,8 @@ module BuildBuddy
|
|
91
91
|
response
|
92
92
|
end
|
93
93
|
|
94
|
-
def do_stop(
|
95
|
-
message = message.strip
|
94
|
+
def do_stop(bb_id, is_from_slack_channel, slack_user_name)
|
96
95
|
response = ''
|
97
|
-
m = message.match(/^(?:build +)?(bb-\d+)$/i)
|
98
|
-
|
99
96
|
unless m.nil?
|
100
97
|
bb_id = m[1].upcase
|
101
98
|
result = Celluloid::Actor[:scheduler].stop_build(bb_id, slack_user_name)
|
@@ -113,7 +110,7 @@ module BuildBuddy
|
|
113
110
|
response
|
114
111
|
end
|
115
112
|
|
116
|
-
def do_help
|
113
|
+
def do_help(is_from_slack_channel)
|
117
114
|
%Q(Hello#{is_from_slack_channel ? " <@#{data['user']}>" : ""}, I'm the *@#{@rt_client.self['name']}* build bot version #{BuildBuddy::VERSION}!
|
118
115
|
|
119
116
|
I understand types of build - pull requests and branch. A pull request build happens when you make a pull request to the https://github.com/#{Config.github_webhook_repo_full_name} GitHub repository.
|
@@ -150,115 +147,116 @@ I have lots of `show` commands:
|
|
150
147
|
info "I relayed a message for #{slack_user_name} to #{Config.slack_build_channel}, \"#{message}\""
|
151
148
|
end
|
152
149
|
|
153
|
-
def
|
154
|
-
|
150
|
+
def do_show_builds(limit)
|
151
|
+
build_datas = Celluloid::Actor[:recorder].get_build_data_history(limit)
|
155
152
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
m = request.match(/last ([0-9]+)/)
|
160
|
-
limit = m[1].to_i unless m.nil?
|
161
|
-
build_datas = Celluloid::Actor[:recorder].get_build_data_history(limit)
|
162
|
-
|
163
|
-
if build_datas.count == 0
|
164
|
-
response = "No builds have performed yet"
|
165
|
-
else
|
166
|
-
response = ''
|
167
|
-
if build_datas.count < limit
|
168
|
-
response += "There have only been #{build_datas.count} builds:\n"
|
169
|
-
else
|
170
|
-
response += "Here are the last #{build_datas.count} builds:\n"
|
171
|
-
end
|
172
|
-
build_datas.each do |build_data|
|
173
|
-
response += "A "
|
174
|
-
response += case build_data.type
|
175
|
-
when :branch
|
176
|
-
"`#{build_data.branch}` branch build"
|
177
|
-
when :pull_request
|
178
|
-
"pull request build #{build_data.pull_request_uri}"
|
179
|
-
end
|
180
|
-
response += " at #{build_data.start_time.to_s}. #{BuildData.server_log_uri(build_data._id)}"
|
181
|
-
unless build_data.started_by.nil?
|
182
|
-
response += " started by #{build_data.started_by}"
|
183
|
-
end
|
184
|
-
response += " #{build_data.status_verb}"
|
185
|
-
unless build_data.stopped_by.nil?
|
186
|
-
response += " by #{build_data.stopped_by}"
|
187
|
-
end
|
188
|
-
response += ".\n"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
when /status/
|
192
|
-
scheduler = Celluloid::Actor[:scheduler]
|
193
|
-
build_data = scheduler.active_build
|
194
|
-
queue_length = scheduler.queue_length
|
153
|
+
if build_datas.count == 0
|
154
|
+
response = "No builds have performed yet"
|
155
|
+
else
|
195
156
|
response = ''
|
196
|
-
if
|
197
|
-
response
|
198
|
-
if queue_length == 0
|
199
|
-
response += " and no builds in the queue."
|
200
|
-
else
|
201
|
-
response += " and #{queue_length} in the queue."
|
202
|
-
end
|
157
|
+
if build_datas.count < limit
|
158
|
+
response += "There have only been #{build_datas.count} builds:\n"
|
203
159
|
else
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
160
|
+
response += "Here are the last #{build_datas.count} builds:\n"
|
161
|
+
end
|
162
|
+
build_datas.each do |build_data|
|
163
|
+
response += "A "
|
164
|
+
response += case build_data.type
|
165
|
+
when :branch
|
166
|
+
"`#{build_data.branch}` branch build"
|
167
|
+
when :pull_request
|
168
|
+
"pull request build #{build_data.pull_request_uri}"
|
169
|
+
end
|
170
|
+
response += " at #{build_data.start_time.to_s}. #{BuildData.server_log_uri(build_data._id)}"
|
210
171
|
unless build_data.started_by.nil?
|
211
|
-
response += " started by
|
172
|
+
response += " started by #{build_data.started_by}"
|
212
173
|
end
|
174
|
+
response += " #{build_data.status_verb}"
|
213
175
|
unless build_data.stopped_by.nil?
|
214
|
-
response += "
|
215
|
-
end
|
216
|
-
response += '.'
|
217
|
-
if queue_length == 1
|
218
|
-
response += " There is one build in the queue."
|
219
|
-
elsif queue_length > 1
|
220
|
-
response += " There are #{queue_length} builds in the queue."
|
176
|
+
response += " by #{build_data.stopped_by}"
|
221
177
|
end
|
178
|
+
response += ".\n"
|
222
179
|
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
180
|
+
end
|
181
|
+
response
|
182
|
+
end
|
183
|
+
|
184
|
+
def do_show_status
|
185
|
+
scheduler = Celluloid::Actor[:scheduler]
|
186
|
+
build_data = scheduler.active_build
|
187
|
+
queue_length = scheduler.queue_length
|
188
|
+
response = ''
|
189
|
+
if build_data.nil?
|
190
|
+
response = "There is currently no build running"
|
191
|
+
if queue_length == 0
|
192
|
+
response += " and no builds in the queue."
|
233
193
|
else
|
234
|
-
|
235
|
-
response += "A "
|
236
|
-
response += case build_data.type
|
237
|
-
when :branch
|
238
|
-
"`#{build_data.branch}` branch build"
|
239
|
-
when :pull_request
|
240
|
-
"pull request build #{build_data.pull_request_uri}"
|
241
|
-
end
|
242
|
-
response += " (#{build_data.bb_id})"
|
243
|
-
unless build_data.started_by.nil?
|
244
|
-
response += " started by #{build_data.started_by}"
|
245
|
-
end
|
246
|
-
unless build_data.stopped_by.nil?
|
247
|
-
response += " stopped by #{build_data.stopped_by}"
|
248
|
-
end
|
249
|
-
response += ".\n"
|
250
|
-
}
|
194
|
+
response += " and #{queue_length} in the queue."
|
251
195
|
end
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
196
|
+
else
|
197
|
+
case build_data.type
|
198
|
+
when :pull_request
|
199
|
+
response = "There is a pull request build in progress for https://github.com/#{build_data.repo_full_name}/pull/#{build_data.pull_request} (#{build_data.bb_id})"
|
200
|
+
when :branch
|
201
|
+
response = "There is a build of the `#{build_data.branch}` branch of https://github.com/#{build_data.repo_full_name} in progress (#{build_data.bb_id})"
|
202
|
+
end
|
203
|
+
unless build_data.started_by.nil?
|
204
|
+
response += " started by " + build_data.started_by
|
205
|
+
end
|
206
|
+
unless build_data.stopped_by.nil?
|
207
|
+
response += " stopped by #{build_data.stopped_by}"
|
208
|
+
end
|
209
|
+
response += '.'
|
210
|
+
if queue_length == 1
|
211
|
+
response += " There is one build in the queue."
|
212
|
+
elsif queue_length > 1
|
213
|
+
response += " There are #{queue_length} builds in the queue."
|
259
214
|
end
|
215
|
+
end
|
216
|
+
response
|
217
|
+
end
|
218
|
+
|
219
|
+
def do_show_options
|
220
|
+
%Q(You can add the following options to builds:
|
221
|
+
- *test channel* to have notifications go to the test channel
|
222
|
+
- *no upload* to not have the build upload
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
def do_show_queue
|
227
|
+
response = ''
|
228
|
+
build_datas = Celluloid::Actor[:scheduler].get_build_queue
|
229
|
+
if build_datas.count == 0
|
230
|
+
response = "There are no builds in the queue."
|
260
231
|
else
|
261
|
-
|
232
|
+
build_datas.each { |build_data|
|
233
|
+
response += "A "
|
234
|
+
response += case build_data.type
|
235
|
+
when :branch
|
236
|
+
"`#{build_data.branch}` branch build"
|
237
|
+
when :pull_request
|
238
|
+
"pull request build #{build_data.pull_request_uri}"
|
239
|
+
end
|
240
|
+
response += " (#{build_data.bb_id})"
|
241
|
+
unless build_data.started_by.nil?
|
242
|
+
response += " started by #{build_data.started_by}"
|
243
|
+
end
|
244
|
+
unless build_data.stopped_by.nil?
|
245
|
+
response += " stopped by #{build_data.stopped_by}"
|
246
|
+
end
|
247
|
+
response += ".\n"
|
248
|
+
}
|
249
|
+
end
|
250
|
+
response
|
251
|
+
end
|
252
|
+
|
253
|
+
def do_show_report
|
254
|
+
response = ''
|
255
|
+
report_uri = Celluloid::Actor[:recorder].find_report_uri
|
256
|
+
if report_uri.nil?
|
257
|
+
response = "There do not appear to be any reports generated yet"
|
258
|
+
else
|
259
|
+
response = "The last build report is at #{report_uri}"
|
262
260
|
end
|
263
261
|
response
|
264
262
|
end
|
@@ -339,17 +337,27 @@ I have lots of `show` commands:
|
|
339
337
|
message = message.strip
|
340
338
|
|
341
339
|
response = case message
|
342
|
-
when
|
340
|
+
when /build +([a-z0-9\.]+)/i
|
343
341
|
do_build $1, is_from_slack_channel, slack_user_name
|
344
|
-
when
|
345
|
-
|
346
|
-
when
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
342
|
+
when /(?:show +)status/
|
343
|
+
do_show_status
|
344
|
+
when /show +(last [0-9]+ +)?builds/
|
345
|
+
limit = $1.to_i unless $1.nil?
|
346
|
+
if limit.nil? or limit < 5
|
347
|
+
limit = 5
|
348
|
+
end
|
349
|
+
do_show_builds limit
|
350
|
+
when /show report/
|
351
|
+
do_show_report
|
352
|
+
when /show queue/
|
353
|
+
do_show_queue
|
354
|
+
when /show options/
|
355
|
+
do_show_options
|
356
|
+
when /help/i
|
357
|
+
do_show_help is_from_slack_channel
|
358
|
+
when /^relay(.*)/i # This must be sent directly to build-buddy
|
351
359
|
do_relay $1, slack_user_name
|
352
|
-
when
|
360
|
+
when /stop +(?:build +)?(bb-\d+)/i
|
353
361
|
do_stop $1, is_from_slack_channel, slack_user_name
|
354
362
|
else
|
355
363
|
"Sorry#{is_from_slack_channel ? ' ' + slack_user_name : ''}, I'm not sure how to respond."
|
@@ -366,7 +374,7 @@ I have lots of `show` commands:
|
|
366
374
|
short_message = message
|
367
375
|
info "Branch build #{status_verb}"
|
368
376
|
else
|
369
|
-
message = "
|
377
|
+
message = "Pull request <https://github.com/#{build_data.repo_full_name}/pull/#{build_data.pull_request}|#{build_data.pull_request_title}> build #{status_verb}"
|
370
378
|
short_message = "Pull request #{build_data.pull_request} #{status_verb}"
|
371
379
|
info "Pull request build #{status_verb}"
|
372
380
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-buddy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Lyon-smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timers
|