build-buddy 1.7.1 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build_buddy.rb +1 -1
- data/lib/build_buddy/builder.rb +1 -1
- data/lib/build_buddy/gitter.rb +9 -3
- data/lib/build_buddy/server.rb +16 -9
- data/lib/build_buddy/slacker.rb +63 -40
- 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: bc533f6854862178451a21df0a4d84ae2061990b
|
4
|
+
data.tar.gz: be19e66a1a5dee3caf7dc857cf8960582331775a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 462ec0136b74bafc5a3a93f8c1914ad1f6b39a2a7a90b34fdea196ee180e57e3a7c63a3e4b42762881cc791fea3c773da9f72e5e43600afd247abdd3199b5883
|
7
|
+
data.tar.gz: 8ba1d443cc60f29858b6dc5fa27b358c7d4b74a119ea46b1939a31afff428bc446d5c7345ff25cba07416974619c843ab84a3a165efe5c5e886f27741904df54
|
data/lib/build_buddy.rb
CHANGED
data/lib/build_buddy/builder.rb
CHANGED
@@ -79,7 +79,7 @@ module BuildBuddy
|
|
79
79
|
|
80
80
|
# Collect any data written to the build metrics YAML file
|
81
81
|
begin
|
82
|
-
metrics = Psych.
|
82
|
+
metrics = Psych.load_stream(File.read(@metrics_tempfile.path)).reduce({}, :merge)
|
83
83
|
rescue Psych::SyntaxError => ex
|
84
84
|
error "There was a problem collecting bulid metrics: #{ex.message}"
|
85
85
|
end
|
data/lib/build_buddy/gitter.rb
CHANGED
@@ -14,9 +14,15 @@ module BuildBuddy
|
|
14
14
|
info "Connected to Github"
|
15
15
|
end
|
16
16
|
|
17
|
-
def set_status(repo_full_name, repo_sha, status, description)
|
18
|
-
|
19
|
-
|
17
|
+
def set_status(repo_full_name, repo_sha, status, description, target_url)
|
18
|
+
options = {
|
19
|
+
:description => description.length > 140 ? "#{description[0..136]}..." : description,
|
20
|
+
:context => 'build-buddy'
|
21
|
+
}
|
22
|
+
unless target_url.nil?
|
23
|
+
options[:target_url] = target_url
|
24
|
+
end
|
25
|
+
@gh_client.create_status(repo_full_name, repo_sha, status.to_s, options)
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/build_buddy/server.rb
CHANGED
@@ -28,15 +28,22 @@ module BuildBuddy
|
|
28
28
|
else
|
29
29
|
payload = JSON.parse(payload_text)
|
30
30
|
pull_request = payload['pull_request']
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
pull_request_action = pull_request['action']
|
32
|
+
|
33
|
+
case action
|
34
|
+
when 'opened', 'reopened', 'synchronize'
|
35
|
+
build_data = BuildData.new(
|
36
|
+
:type => :pull_request,
|
37
|
+
:pull_request => pull_request['number'],
|
38
|
+
:flags => [],
|
39
|
+
:repo_sha => pull_request['head']['sha'],
|
40
|
+
:repo_full_name => pull_request['base']['repo']['full_name'])
|
41
|
+
info "Got #{action} pull request #{build_data.pull_request} from GitHub"
|
42
|
+
Celluloid::Actor[:scheduler].queue_a_build(build_data)
|
43
|
+
request.respond 200, "Building"
|
44
|
+
else
|
45
|
+
request.respond 200, "Ignoring"
|
46
|
+
end
|
40
47
|
end
|
41
48
|
when 'ping'
|
42
49
|
request.respond 200, "Running"
|
data/lib/build_buddy/slacker.rb
CHANGED
@@ -31,8 +31,10 @@ module BuildBuddy
|
|
31
31
|
|
32
32
|
def self.get_build_flags message
|
33
33
|
flags = []
|
34
|
-
message.
|
35
|
-
|
34
|
+
unless message.nil?
|
35
|
+
message.split(',').each do |s|
|
36
|
+
flags.push(s.lstrip.rstrip.gsub(' ', '_').to_sym)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
flags
|
38
40
|
end
|
@@ -70,19 +72,25 @@ module BuildBuddy
|
|
70
72
|
else
|
71
73
|
response = "I'm sorry, I am not allowed to build the `#{version}` release branch"
|
72
74
|
end
|
73
|
-
when /stop/i
|
74
|
-
if scheduler.stop_build
|
75
|
-
response = "OK, I stopped the currently running build."
|
76
|
-
else
|
77
|
-
response = "There is no build running to stop."
|
78
|
-
end
|
79
75
|
else
|
80
|
-
response = "Sorry#{from_slack_channel ? " <@#{data['user']}>" : ""}, I'm not sure if you want do a `master` or release branch build
|
76
|
+
response = "Sorry#{from_slack_channel ? " <@#{data['user']}>" : ""}, I'm not sure if you want do a `master` or release branch build"
|
81
77
|
end
|
82
78
|
end
|
83
79
|
response
|
84
80
|
end
|
85
81
|
|
82
|
+
def do_stop
|
83
|
+
scheduler = Celluloid::Actor[:scheduler]
|
84
|
+
|
85
|
+
if scheduler.stop_build
|
86
|
+
response = "OK, I stopped the currently running build."
|
87
|
+
else
|
88
|
+
response = "There is no build running to stop."
|
89
|
+
end
|
90
|
+
|
91
|
+
response
|
92
|
+
end
|
93
|
+
|
86
94
|
def do_status
|
87
95
|
scheduler = Celluloid::Actor[:scheduler]
|
88
96
|
build_data = scheduler.active_build
|
@@ -123,37 +131,51 @@ I can run builds of the master branch if you say `build master`. I can do builds
|
|
123
131
|
|
124
132
|
I can stop any running build if you ask me to `stop build`, even pull request builds. I am configured to let the *#{Config.slack_build_channel}* channel know if master or release builds are stopped.
|
125
133
|
|
126
|
-
You can also ask me for `status` and I'll tell you what's being built
|
134
|
+
You can also ask me for `status` and I'll tell you what's being built.
|
135
|
+
|
136
|
+
Ask me `what happened` to get a list of recent builds and log files and `what options` to see the list of options for running builds.
|
127
137
|
)
|
128
138
|
end
|
129
139
|
|
130
|
-
def
|
131
|
-
|
132
|
-
when /([0-9]+)/
|
133
|
-
limit = $1.to_i
|
134
|
-
else
|
135
|
-
limit = 5
|
136
|
-
end
|
140
|
+
def do_what(question)
|
141
|
+
question = question.lstrip.rstrip
|
137
142
|
|
138
|
-
|
139
|
-
|
143
|
+
case question
|
144
|
+
when /happened/
|
145
|
+
case question
|
146
|
+
when /([0-9]+)/
|
147
|
+
limit = $1.to_i
|
148
|
+
else
|
149
|
+
limit = 5
|
150
|
+
end
|
140
151
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
response
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
recorder = Celluloid::Actor[:recorder]
|
153
|
+
build_datas = recorder.get_build_data_history(limit)
|
154
|
+
|
155
|
+
if build_datas.count == 0
|
156
|
+
response = "No builds have performed yet"
|
157
|
+
else
|
158
|
+
response = "Here are the last #{build_datas.count} builds:\n"
|
159
|
+
build_datas.each do |build_data|
|
160
|
+
response += "A "
|
161
|
+
response += case build_data.type
|
162
|
+
when :master
|
163
|
+
"`master` branch build"
|
164
|
+
when :release
|
165
|
+
"`#{build_data.branch}` release branch build"
|
166
|
+
when :pull_request
|
167
|
+
"pull request `#{build_data.pull_request}` build"
|
168
|
+
end
|
169
|
+
response += " at #{build_data.start_time.to_s}. #{Config.server_base_uri + '/log/' + build_data._id.to_s}\n"
|
170
|
+
end
|
156
171
|
end
|
172
|
+
when /options/
|
173
|
+
response = %Q(You can add the following options to builds:
|
174
|
+
- *test channel* to have notifications go to the test channel
|
175
|
+
- *no upload* to not have the build upload
|
176
|
+
)
|
177
|
+
else
|
178
|
+
response = "I'm not sure what to say..."
|
157
179
|
end
|
158
180
|
response
|
159
181
|
end
|
@@ -231,10 +253,12 @@ You can also ask me for `status` and I'll tell you what's being built and what's
|
|
231
253
|
do_build $1, from_slack_channel, slack_user_name
|
232
254
|
when /status/i
|
233
255
|
do_status
|
234
|
-
when /
|
235
|
-
|
256
|
+
when /what(.*)/
|
257
|
+
do_what $1
|
236
258
|
when /help/i, /what can/i
|
237
259
|
do_help from_slack_channel
|
260
|
+
when /stop/i
|
261
|
+
do_stop
|
238
262
|
else
|
239
263
|
"Sorry#{from_slack_channel ? " <@#{data['user']}>" : ""}, I'm not sure how to respond."
|
240
264
|
end
|
@@ -248,10 +272,9 @@ You can also ask me for `status` and I'll tell you what's being built and what's
|
|
248
272
|
|
249
273
|
if build_data.type == :pull_request
|
250
274
|
message = "The buddy build #{status_message}"
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
message)
|
275
|
+
git_status = (build_data.termination_type == :killed ? :failure : build_data.exit_code != 0 ? :error : :success)
|
276
|
+
git_url = (git_status == :error ? "#{Config.server_base_uri + '/log/' + build_data._id.to_s}" : nil)
|
277
|
+
Celluloid::Actor[:gitter].async.set_status(build_data.repo_full_name, build_data.repo_sha, git_status, git_message, git_url)
|
255
278
|
info "Pull request build #{status_message}"
|
256
279
|
else
|
257
280
|
status_message += "Log file at #{Config.server_base_uri + '/log/' + build_data._id.to_s}."
|
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.
|
4
|
+
version: 1.8.0
|
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-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timers
|