build-buddy 1.8.4 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 656443f17239c6954ec716ef56dce64a6ad0a33b
4
- data.tar.gz: bf937f8268594356e0bfc79bcbb6163a4134e386
3
+ metadata.gz: 76cc3ddfbee154ee1432443968a760f9e17e79e8
4
+ data.tar.gz: 575d15f41abb55fcbc7e0e8174144f3926e5c568
5
5
  SHA512:
6
- metadata.gz: a04a74c2e86297a87a5f0ec98ede406e05456073479d661edd298c90df868ffc896b5b1aa4078f7e8858a2df6d5d3286434c8e60f9eacfcb3ab80db5af269994
7
- data.tar.gz: 0f45e9e4bb55b51107369dad1555f3074dd6b04273c24721f72cf8b12b7c4b55cc089bb0174f85c7cf8b0f098c26dbc8e364d1fb9a676dff23eca3702820b1a8
6
+ metadata.gz: cc093742b96214e7f4f5a2e1c58bb1fe39efe77fadacec41d75a86672da153d6098bc90b48dbc11c7571bb83c490fad7b19a7cba2dc04e536c110a72763c88c2
7
+ data.tar.gz: 456bcf537cd820466616367118a23fdef23c67c08842c9d6ead7ed35cf3ed86fa38809f303be637ab81f67dd91b423d4ba89a295ae1e247cd034cd9a3841dfc4
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.8.4"
12
+ VERSION = "1.9.2"
13
13
  end
@@ -81,7 +81,7 @@ module BuildBuddy
81
81
  begin
82
82
  metrics = Psych.load_stream(File.read(@metrics_tempfile.path)).reduce({}, :merge)
83
83
  rescue Psych::SyntaxError => ex
84
- error "There was a problem collecting bulid metrics: #{ex.message}"
84
+ error "There was a problem collecting build metrics: #{ex.message}"
85
85
  end
86
86
  if !metrics
87
87
  metrics = {}
@@ -19,12 +19,14 @@ module BuildBuddy
19
19
  attr_accessor :valid_release_versions
20
20
  attr_accessor :kill_build_after_mins
21
21
  attr_accessor :server_base_uri
22
+ attr_accessor :mongo_uri
22
23
  end
23
24
 
24
25
  class << self
25
26
  def configure
26
27
  Config.github_webhook_port = 4567
27
28
  Config.kill_build_after_mins = 30
29
+ Config.mongo_uri = 'mongodb://localhost:27017/build-buddy'
28
30
  block_given? ? yield(Config) : Config
29
31
  end
30
32
 
@@ -11,8 +11,9 @@ module BuildBuddy
11
11
 
12
12
  def initialize()
13
13
  Mongo::Logger.logger.level = ::Logger::FATAL
14
- @mongo ||= Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'build-buddy')
15
- info "Connected to MongoDB"
14
+ mongo_uri = BuildBuddy::Config.mongo_uri
15
+ @mongo ||= Mongo::Client.new(mongo_uri)
16
+ info "Connected to MongoDB at '#{mongo_uri}'"
16
17
  @mongo[:builds].indexes.create_one({:start_time => -1}, :name => "reverse_build_order")
17
18
  end
18
19
 
@@ -53,7 +53,12 @@ module BuildBuddy
53
53
 
54
54
  def on_build_interval
55
55
  if @active_build.nil?
56
- if @build_queue.length > 0
56
+ # No active build so...
57
+ if @done_queue.length > 0 # First, send any completed build statuses
58
+ build_data = @done_queue.pop
59
+ Celluloid::Actor[:slacker].async.notify_channel(build_data)
60
+ Celluloid::Actor[:recorder].async.update_build_data(build_data)
61
+ elsif @build_queue.length > 0 # Then, check if there are any builds waiting to go
57
62
  build_data = @build_queue.pop()
58
63
  @active_build = build_data
59
64
  Celluloid::Actor[:recorder].async.record_build_data(build_data)
@@ -62,14 +67,11 @@ module BuildBuddy
62
67
  build_data.repo_full_name, build_data.repo_sha, :pending, "This build has started")
63
68
  end
64
69
  Celluloid::Actor[:builder].async.start_build(build_data)
65
- elsif @done_queue.length > 0
66
- build_data = @done_queue.pop
67
- Celluloid::Actor[:slacker].async.notify_channel(build_data)
68
- Celluloid::Actor[:recorder].async.update_build_data(build_data)
69
- else
70
+ else # Otherwise, stop the timer until we get a build queued.
70
71
  @build_timer.cancel
71
72
  @build_timer = nil
72
73
  info "Build timer stopped"
74
+ # Now we won't get any more build intervals
73
75
  end
74
76
  else
75
77
  # Make sure that the build has not run too long and kill if necessary
@@ -11,7 +11,7 @@ module BuildBuddy
11
11
 
12
12
  def initialize()
13
13
  super("127.0.0.1", Config.github_webhook_port, &method(:on_connection))
14
- info "Listening on port #{Config.github_webhook_port}"
14
+ info "Web server listening on port #{Config.github_webhook_port}"
15
15
  end
16
16
 
17
17
  def on_connection(connection)
@@ -286,13 +286,20 @@ Ask me `what happened` to get a list of recent builds and log files and `what op
286
286
  info "Release branch build #{status_message}"
287
287
  end
288
288
 
289
+ # See https://api.slack.com/docs/attachments for more information about formatting Slack attachments
290
+ attach = [
291
+ :title => build_data.type == :pull_request ? "Pull Request" : "Branch Build",
292
+ :text => message,
293
+ :color => build_data.termination_type == :killed ? :warning : build_data.exit_code != 0 ? :danger : :good,
294
+ ]
295
+
289
296
  if build_data.flags.include?(:test_channel)
290
297
  unless @test_slack_channel.nil?
291
- @rt_client.message(channel: @test_slack_channel, text: message)
298
+ @rt_client.message(channel: @test_slack_channel, text: message, attachments: attach)
292
299
  end
293
300
  else
294
301
  unless @build_slack_channel.nil?
295
- @rt_client.message(channel: @build_slack_channel, text: message)
302
+ @rt_client.message(channel: @build_slack_channel, text: message, attachments: attach)
296
303
  end
297
304
  end
298
305
  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.8.4
4
+ version: 1.9.2
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-04-09 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timers