cider_ci-support 1.1.0 → 1.2.0
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 +4 -4
- data/bin/cider-ci_coverage +80 -47
- data/cider_ci-support.gemspec +1 -1
- data/lib/cider_ci/support/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7755a6b5d8929021636901148df35366204deb27
|
4
|
+
data.tar.gz: daf12d66d62f38c7960b2671d5c60d9603879c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd647c0ece84d7ff851c4e5749127aada7e877d396819ddea350a698e4023c6628329899502e6cd2a3216063669fb46e44d672c730301211740721224f4c7c0
|
7
|
+
data.tar.gz: 0946eefb9b67795fe011b585968a477fc26539a9aeb0a3a3dc77427a4a090f7ed81bf33560029a44a38a63874cc718674811d35c30255e5fd7bc7e85defff501
|
data/bin/cider-ci_coverage
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
2
|
###############################################################################
|
4
3
|
# This script gathers ruby coverage information from a cider-ci instance and
|
5
4
|
# aggregates it via simplecov.
|
@@ -22,6 +21,14 @@ require 'thread/pool'
|
|
22
21
|
require 'mime/types'
|
23
22
|
require 'open-uri'
|
24
23
|
|
24
|
+
###############################################################################
|
25
|
+
# Globals (this is a script after all)
|
26
|
+
###############################################################################
|
27
|
+
|
28
|
+
Thread.abort_on_exception = true
|
29
|
+
@debug = false
|
30
|
+
@pool = nil
|
31
|
+
|
25
32
|
###############################################################################
|
26
33
|
# Download from Cider-CI
|
27
34
|
###############################################################################
|
@@ -37,35 +44,45 @@ def get_execution_resource(root, execution_id)
|
|
37
44
|
root.relation('execution').get('id' => execution_id)
|
38
45
|
end
|
39
46
|
|
40
|
-
def
|
47
|
+
def print_progress_and_debug(separator = '.', msg = '')
|
48
|
+
if @debug
|
49
|
+
puts separator.to_s + " " + msg.to_s
|
50
|
+
else
|
51
|
+
print separator
|
52
|
+
STDOUT.flush
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_and_convert_resultset_attachments(root, tree_id)
|
41
57
|
print 'download_resultset_attachments'; STDOUT.flush
|
42
|
-
|
58
|
+
|
43
59
|
root.relation('executions').get('treeid' => tree_id).collection \
|
44
60
|
.map(&:get).map do |execution|
|
45
61
|
execution.relation('tasks').get('state' => 'passed').collection\
|
46
62
|
.map do |task_relation|
|
47
|
-
Thread.future pool do
|
48
|
-
|
63
|
+
Thread.future @pool do
|
64
|
+
print_progress_and_debug('', task_relation)
|
49
65
|
task_relation.get.relation('trials') \
|
50
66
|
.get('state' => 'passed').collection.map(&:get).map do |trial|
|
51
|
-
|
67
|
+
print_progress_and_debug('.', trial)
|
52
68
|
trial.relation('trial-attachments') \
|
53
69
|
.get.collection.map do |tar|
|
70
|
+
print_progress_and_debug('.', "getting #{tar}")
|
54
71
|
trial_attachment_resource = tar.get
|
55
|
-
print '.'; STDOUT.flush
|
56
72
|
if (working_dir = trial.data['scripts'] \
|
57
73
|
.map { |_k, v| v['working_dir'] }.compact.first) \
|
58
74
|
&& (trial_attachment_resource.data['path'] =~ /resultset\.json/)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
75
|
+
result_data_relation = trial_attachment_resource \
|
76
|
+
.relation('trial-attachment-data-stream')
|
77
|
+
print_progress_and_debug('*', "getting #{result_data_relation}")
|
78
|
+
resultset = result_data_relation.get.response.body
|
79
|
+
print_progress_and_debug('*', "converting resultset")
|
63
80
|
convert_resultset resultset, working_dir
|
64
81
|
end
|
65
82
|
end
|
66
83
|
end
|
67
84
|
end
|
68
|
-
end.map(
|
85
|
+
end.map { |f| f.value!(3) }
|
69
86
|
end.flatten.compact
|
70
87
|
end
|
71
88
|
|
@@ -83,7 +100,7 @@ def upload_as_tree_attachments(root, tree_id)
|
|
83
100
|
root.relation('tree-attachment-data-stream').put(
|
84
101
|
{ 'treeid' => tree_id, 'path' => filename },
|
85
102
|
File.open(filename, 'rb').read, 'content-type' => content_type)
|
86
|
-
|
103
|
+
print_progress_and_debug('*')
|
87
104
|
end
|
88
105
|
end
|
89
106
|
puts ''
|
@@ -131,20 +148,51 @@ end
|
|
131
148
|
# Run
|
132
149
|
###############################################################################
|
133
150
|
|
134
|
-
def run_coverage(root, tree_id
|
135
|
-
get_and_convert_resultset_attachments(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
fail ScriptError, 'the collected and reduced coverage result is empty'
|
141
|
-
end
|
142
|
-
init_simple_cov
|
143
|
-
SimpleCov::Result.new self
|
144
|
-
end.instance_eval do
|
145
|
-
SimpleCov::Formatter::HTMLFormatter.new.format self
|
146
|
-
self
|
151
|
+
def run_coverage(root, tree_id)
|
152
|
+
get_and_convert_resultset_attachments(root, tree_id).instance_eval do
|
153
|
+
reduce_resultsets self
|
154
|
+
end.instance_eval do
|
155
|
+
if self.empty?
|
156
|
+
fail ScriptError, 'the collected and reduced coverage result is empty'
|
147
157
|
end
|
158
|
+
init_simple_cov
|
159
|
+
SimpleCov::Result.new self
|
160
|
+
end.instance_eval do
|
161
|
+
SimpleCov::Formatter::HTMLFormatter.new.format self
|
162
|
+
self
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
###############################################################################
|
167
|
+
# Git
|
168
|
+
###############################################################################
|
169
|
+
|
170
|
+
def assert_correct_tree_id(execution)
|
171
|
+
if execution.data['tree_id'] != `git log -n 1 --pretty=%T`.strip
|
172
|
+
fail ScriptError, 'you must be on the same tree_id as the execution'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def get_current_tree_id
|
177
|
+
begin
|
178
|
+
tree_id = `"git" "log" "-n" "1" "--pretty=%T"`.strip
|
179
|
+
rescue _
|
180
|
+
raise ScriptError, 'could not determine the current tree_id'
|
181
|
+
end
|
182
|
+
|
183
|
+
if $?.exitstatus != 0
|
184
|
+
raise ScriptError, "could not determine the current tree_id"
|
185
|
+
else
|
186
|
+
tree_id
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
###############################################################################
|
191
|
+
# Thread pool
|
192
|
+
###############################################################################
|
193
|
+
|
194
|
+
def set_thread_pool(thread_pool_size)
|
195
|
+
@pool = Thread.pool thread_pool_size
|
148
196
|
end
|
149
197
|
|
150
198
|
###############################################################################
|
@@ -180,6 +228,10 @@ def parse_options(options)
|
|
180
228
|
options.upload = true
|
181
229
|
end
|
182
230
|
|
231
|
+
opts.on('-d', '--debug') do
|
232
|
+
@debug = true
|
233
|
+
end
|
234
|
+
|
183
235
|
opts.on('-l', '--limit N', Integer) do |l|
|
184
236
|
options.limit = l
|
185
237
|
end
|
@@ -188,26 +240,6 @@ def parse_options(options)
|
|
188
240
|
options
|
189
241
|
end
|
190
242
|
|
191
|
-
def assert_correct_tree_id(execution)
|
192
|
-
if execution.data['tree_id'] != `git log -n 1 --pretty=%T`.strip
|
193
|
-
fail ScriptError, 'you must be on the same tree_id as the execution'
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
def get_current_tree_id
|
198
|
-
begin
|
199
|
-
tree_id = `"git" "log" "-n" "1" "--pretty=%T"`.strip
|
200
|
-
rescue _
|
201
|
-
raise ScriptError, 'could not determine the current tree_id'
|
202
|
-
end
|
203
|
-
|
204
|
-
if $?.exitstatus != 0
|
205
|
-
raise ScriptError, "could not determine the current tree_id"
|
206
|
-
else
|
207
|
-
tree_id
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
243
|
def main
|
212
244
|
options = OpenStruct.new
|
213
245
|
options.thread_pool_size = 50
|
@@ -227,8 +259,9 @@ def main
|
|
227
259
|
|
228
260
|
root = connect(options.api_url, options.username, options.password).get
|
229
261
|
tree_id = get_current_tree_id
|
262
|
+
set_thread_pool options.thread_pool_size
|
230
263
|
FileUtils.rm_rf('coverage')
|
231
|
-
result = run_coverage root, tree_id
|
264
|
+
result = run_coverage root, tree_id
|
232
265
|
upload_as_tree_attachments root, tree_id if options.upload
|
233
266
|
|
234
267
|
coverage = (result.covered_lines / result.total_lines.to_f)
|
data/cider_ci-support.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_runtime_dependency 'flay', '~> 2.5.0'
|
25
25
|
spec.add_runtime_dependency 'flog', '~> 4.3.0'
|
26
|
-
spec.add_runtime_dependency 'json_roa-client', '>= 1.0.0
|
26
|
+
spec.add_runtime_dependency 'json_roa-client', '>= 1.0.0'
|
27
27
|
spec.add_runtime_dependency 'mime-types'
|
28
28
|
spec.add_runtime_dependency 'simplecov', '~> 0.9'
|
29
29
|
spec.add_runtime_dependency 'thread', '= 0.1.4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cider_ci-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Schank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0
|
75
|
+
version: 1.0.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.0
|
82
|
+
version: 1.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mime-types
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|