build-buddy 1.14.3 → 1.14.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96abcbb3d97494bf58764afb274d6ca984bb733e
4
- data.tar.gz: bad604376666183553e37a5ae3dc2255c8f59272
3
+ metadata.gz: a586377dab8683cfbe1cb9d42db7087a463d08be
4
+ data.tar.gz: 42b507512d9bc9f47c4efad3e3bf8af6d82b44ba
5
5
  SHA512:
6
- metadata.gz: b897835e9014316508518e51a48c12a11b836961589559573959db82704b106a7f05658f46111f7afa3d22867e2950dc29650c9278f571aa8d6cf2667a10d5d7
7
- data.tar.gz: b5d0e85f7a661cf6fc8ccbcaad1dd422117289915dc9fa0a94a0c94f588338b6fb2d60e0c628afaf09f34c12766cf18082991744f36b9d651a4ced110b95a211
6
+ metadata.gz: 1608c1fa5a9cadacc27178691c179a1046aa2ecdc6414b342658afd68d7d2d821a546077a4bf339814800808f548d333c33bfd790f46692ee5b3f542960fc573
7
+ data.tar.gz: e85a33cfd8dc8b0ed97771f9d4f4a3c2a4e35c7a9ced76fdb76d0541aeab93f589855a3083570d2648a8b689743a870d7bf39cff3bb2e9802d94222d362e448e
data/bin/build-buddy CHANGED
@@ -34,8 +34,6 @@ module BuildBuddy
34
34
  Celluloid::Actor[:server] = Server.new
35
35
  Celluloid::Actor[:recorder] = Recorder.new
36
36
 
37
- Celluloid::Actor[:recorder].async.gen_charts
38
-
39
37
  begin
40
38
  loop {
41
39
  sleep(5)
data/lib/build_buddy.rb CHANGED
@@ -9,5 +9,5 @@ require 'build_buddy/recorder'
9
9
  require 'build_buddy/build_data'
10
10
 
11
11
  module BuildBuddy
12
- VERSION = "1.14.3"
12
+ VERSION = "1.14.4"
13
13
  end
@@ -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
@@ -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'],
@@ -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(message, is_from_slack_channel, slack_user_name)
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 is_from_slack_channel
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 do_show(request)
154
- request = request.lstrip.rstrip
150
+ def do_show_builds(limit)
151
+ build_datas = Celluloid::Actor[:recorder].get_build_data_history(limit)
155
152
 
156
- case request
157
- when /builds/
158
- limit = 5
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 build_data.nil?
197
- response = "There is currently no build running"
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
- case build_data.type
205
- when :pull_request
206
- 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})"
207
- when :branch
208
- 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})"
209
- end
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 " + build_data.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 += " stopped by #{build_data.stopped_by}"
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
- when /options/
224
- response = %Q(You can add the following options to builds:
225
- - *test channel* to have notifications go to the test channel
226
- - *no upload* to not have the build upload
227
- )
228
- when /queue/
229
- response = ''
230
- build_datas = Celluloid::Actor[:scheduler].get_build_queue
231
- if build_datas.count == 0
232
- response = "There are no builds in the queue."
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
- build_datas.each { |build_data|
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
- when /report/
253
- response = ''
254
- report_uri = Celluloid::Actor[:recorder].find_report_uri
255
- if report_uri.nil?
256
- response = "There do not appear to be any reports generated yet"
257
- else
258
- response = "The last build report is at #{report_uri}"
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
- response = "I'm not sure what to say..."
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 /^build(.*)/i
340
+ when /build +([a-z0-9\.]+)/i
343
341
  do_build $1, is_from_slack_channel, slack_user_name
344
- when /^status/ # Legacy support
345
- do_show 'status'
346
- when /^show(.*)/
347
- do_show $1
348
- when /^help/i
349
- do_help is_from_slack_channel
350
- when /^relay(.*)/i
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 /^stop(.*)/i
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 = "A pull request https://github.com/#{build_data.repo_full_name}/pull/#{build_data.pull_request} build #{status_verb}"
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.3
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-05 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timers