cider_ci-support 2.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93150cebbc3735e9a269a391e09791330222d136
4
- data.tar.gz: 5c266c6b80369755633d1ee542eb3dabc1589cfc
3
+ metadata.gz: 1bffbb16fb39c015e8d1b91203c1ce966dd5cfd9
4
+ data.tar.gz: 369b8553ea92f11d12b699cc03b4e3433ecb3c97
5
5
  SHA512:
6
- metadata.gz: d8c6dc82d64c084df248407775cb6950e96a136bc4a5aded6a7edcf1bb06370535e5a688623df71060a142a7ff03c0fb1500ff6adb38ff28e8e6c522951528d7
7
- data.tar.gz: eba540288c8116760dab86e1e3f9be1b297635bfe64fff6392f630bdb85273965260ea535dc60328565173235bcf0734c43f1ef7aa1c6e54411dcfd355aa3f85
6
+ metadata.gz: b8e4d554df03814384a77204d3f9855e91bf9fac7dce8e955c8d2950ebbbeb45d8ef3dd390cac384601c34cf88e693530b07d3aaa3c30280d99f5d4e8d99f632
7
+ data.tar.gz: 0dd73f1544193ba5bb2ef5eaeced57b22f11d34344d2d093526c97b805f8384ce4e5ebb8ce9e8ede4970b50beed4ad3ca5793d1c5b2b9b3aac2bf6b23bc7f2a5
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Cider-CI Support for Ruby and Ruby on Rails projects
1
+ # Cider-CI Support for Ruby and Ruby on Rails projects
2
2
 
3
- This gem provides convenience executables to work with Cider-CI.
3
+ This gem provides convenience executables to work with Cider-CI.
4
4
 
5
5
 
6
6
  ## Installation
@@ -8,67 +8,35 @@ This gem provides convenience executables to work with Cider-CI.
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'cider_ci-support', '~> 1.0.0'
11
+ gem 'cider_ci-support', '~> 3.0.0'
12
12
  ```
13
13
 
14
14
  ## Usage
15
15
 
16
- ### Aggregate Coverage with `cider-ci_coverage`
17
-
18
- 1. Add [Simplecov]() to your project and configure it.
19
-
20
- 2. Have the coverage output attached to the trials, e.g.
21
-
22
- ```yaml
23
- task_defaults:
24
- trial_attachments:
25
- coverage_resultset:
26
- glob: 'coverage/.resultset.json'
27
- content-type: application/json
28
- ```
29
-
30
- 3. Run the tests on Cider-CI.
31
-
32
- 4. Within the top level directory of you project, e.g.
33
-
34
- ~~~
35
- cider-ci_coverage
36
- ~~~
37
-
38
- which will create the coverage output in `./coverage/`. Alternatively
39
-
40
- ~~~
41
- cider-ci_coverage --upload
42
- ~~~
43
-
44
- will additionally upload the files `./coverage/**/*`
45
- as tree-attachments.
46
-
47
- 5. Set the desired `limit` (optionally). `cider-ci_coverage` will exit
48
- with value 0 if and only if the ration `covered / uncovered lines`
49
- in per cent is above the *limit* (default 95%). This limit can be
50
- set by the `--limit LIMIT` option where `LIMIT` is a integer.
51
-
52
- ~~~
53
- cider-ci_coverage --upload --limit 99
54
- ~~~
55
-
56
-
57
16
  ### Static complexity code analysis with `cider-ci_flog`
58
17
 
59
18
  `cider-ci_flog` uses [flog][] to perform a static code analysis. It exits with
60
19
  0 if and only if there are no offenders. The original `flog` always exits with
61
20
  0. Therefore `cider-ci_flog` lends itself to be used within a task of
62
- a Cider-CI execution suite.
21
+ a Cider-CI execution suite.
63
22
 
64
23
 
65
24
  ### Static similarity code analysis with `cider-ci_flay`
66
25
 
67
- `cider-ci_flay` uses [flay][] to perform a static code
68
- analysis. It exits with 0 if and only if there are no offenders. The
69
- original `flay` always exits with 0. Therefore
70
- `cider-ci_flay` lends itself to be used within a task of a
71
- Cider-CI execution suite.
26
+ `cider-ci_flay` uses [flay][] to perform a static code analysis. It exits with
27
+ 0 if and only if there are no offenders. The original `flay` always exits with
28
+ 0. Therefore `cider-ci_flay` lends itself to be used within a task of
29
+ a Cider-CI execution suite.
30
+
31
+
32
+ ## Notes
33
+
34
+ The Coverage analysis based on [SimpleCov]() has been removed with version 3.0.
35
+
36
+ We deemed the inflicted complexity to hight to maintain it. The problems are
37
+ not related to Cider-CI itself. If you want coverage support with Cider-CI we
38
+ recommend to extract the code from an older version to get started.
39
+
72
40
 
73
41
  [flay]: http://ruby.sadi.st/Flay.html
74
42
  [flog]: http://ruby.sadi.st/Flog.html
data/bin/cider-ci_flay CHANGED
@@ -23,12 +23,12 @@ def parse_options(options)
23
23
  OptionParser.new do |opts|
24
24
  opts.banner = 'Usage: cider-ci_flay FILE/DIR ...'
25
25
 
26
- opts.on('-d', '--print-details') do
26
+ opts.on('-d', '--print-details') do
27
27
  options.print_details = true
28
28
  end
29
29
 
30
30
  opts.on('-m', '--mass MASS', Integer,
31
- "See flay documentation, default #{options.mass}.") do |n|
31
+ "See flay documentation, default #{options.mass}.") do |n|
32
32
  options.mass = n
33
33
  end
34
34
  end.parse!
data/bin/cider-ci_flog CHANGED
@@ -24,11 +24,11 @@ def parse_options(options)
24
24
  OptionParser.new do |opts|
25
25
  opts.banner = 'Usage: cider-ci_flog FILE/DIR ...'
26
26
 
27
- opts.on('-l', '--limit N', Integer) do |l|
27
+ opts.on('-l', '--limit N', Integer) do |l|
28
28
  options.limit = l
29
29
  end
30
30
 
31
- opts.on('-d', '--print-details') do
31
+ opts.on('-d', '--print-details') do
32
32
  options.print_details = true
33
33
  end
34
34
  end.parse!
@@ -18,14 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(/^(test|spec|features)/)
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'bundler', '~> 1.11'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
- spec.add_development_dependency 'rubocop', '= 0.29.1'
23
+ spec.add_development_dependency 'rubocop', '= 0.35.1'
24
24
 
25
25
  spec.add_runtime_dependency 'flay', '~> 2.6.1'
26
26
  spec.add_runtime_dependency 'flog', '~> 4.3.2'
27
- spec.add_runtime_dependency 'json_roa-client', '>= 1.0.0'
28
27
  spec.add_runtime_dependency 'mime-types'
29
- spec.add_runtime_dependency 'simplecov', '~> 0.9'
30
- spec.add_runtime_dependency 'thread', '= 0.1.5'
31
28
  end
@@ -1,5 +1,5 @@
1
1
  module Cider_CI
2
2
  module Support
3
- VERSION = '2.0.0'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cider_ci-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Schank
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.11'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.29.1
47
+ version: 0.35.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.29.1
54
+ version: 0.35.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: flay
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.3.2
83
- - !ruby/object:Gem::Dependency
84
- name: json_roa-client
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 1.0.0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 1.0.0
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: mime-types
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,39 +94,10 @@ dependencies:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.9'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '0.9'
125
- - !ruby/object:Gem::Dependency
126
- name: thread
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '='
130
- - !ruby/object:Gem::Version
131
- version: 0.1.5
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - '='
137
- - !ruby/object:Gem::Version
138
- version: 0.1.5
139
97
  description: ''
140
98
  email:
141
99
  - DrTom@schank.ch
142
100
  executables:
143
- - cider-ci_coverage
144
101
  - cider-ci_flay
145
102
  - cider-ci_flog
146
103
  extensions: []
@@ -152,7 +109,6 @@ files:
152
109
  - LICENSE.txt
153
110
  - README.md
154
111
  - Rakefile
155
- - bin/cider-ci_coverage
156
112
  - bin/cider-ci_flay
157
113
  - bin/cider-ci_flog
158
114
  - cider_ci-support.gemspec
@@ -1,303 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ###############################################################################
3
- # This script gathers ruby coverage information from a cider-ci instance and
4
- # aggregates it via simplecov.
5
- #
6
- # Authors: Thomas Schank <DrTom@schank.ch>
7
- #
8
- ###############################################################################
9
-
10
- # Planned features for the future:
11
- #
12
- # * upload result to cider-ci (attachments to the tree_id)
13
-
14
- require 'fileutils'
15
- require 'json_roa/client'
16
- require 'logger'
17
- require 'mime/types'
18
- require 'open-uri'
19
- require 'optparse'
20
- require 'ostruct'
21
- require 'simplecov'
22
- require 'thread/future'
23
- require 'thread/pool'
24
-
25
- ###############################################################################
26
- # Globals (this is a script after all)
27
- ###############################################################################
28
-
29
- Thread.abort_on_exception = true
30
- @debug = false
31
- @pool = nil
32
-
33
- @logger = Logger.new(STDERR)
34
- @logger.level = Logger::WARN
35
-
36
- ###############################################################################
37
- # Download from Cider-CI
38
- ###############################################################################
39
-
40
- def connect(base_url, username, password)
41
- JSON_ROA::Client.connect base_url do |conn|
42
- conn.basic_auth(username, password)
43
- conn.ssl.verify = false
44
- end
45
- end
46
-
47
- def get_job_resource(root, job_id)
48
- root.relation('job').get('id' => job_id)
49
- end
50
-
51
- def print_progress_and_debug(separator = '.', msg = '')
52
- if @debug
53
- puts separator.to_s + " " + msg.to_s
54
- else
55
- print separator
56
- STDOUT.flush
57
- end
58
- end
59
-
60
- def get_and_convert_resultset_attachments(root, tree_id)
61
- print 'download_resultset_attachments'; STDOUT.flush
62
- root.relation('jobs').get('treeid' => tree_id).collection \
63
- .map(&:get).map do |job|
64
- job.relation('tasks').get('state' => 'passed').collection\
65
- .map do |task_relation|
66
- Thread.future @pool do
67
- begin
68
- print_progress_and_debug('', task_relation)
69
- task_relation.get.relation('trials') \
70
- .get('state' => 'passed').collection.map(&:get).map do |trial|
71
- print_progress_and_debug('.', trial)
72
- trial.relation('trial-attachments') \
73
- .get.collection.map do |tar|
74
- print_progress_and_debug('.', "getting #{tar}")
75
- trial_attachment_resource = tar.get
76
- if (working_dir = trial.data['scripts'] \
77
- .map { |_k, v| v['working_dir'] }.compact.first) \
78
- && (trial_attachment_resource.data['path'] =~ /resultset\.json/)
79
- result_data_relation = trial_attachment_resource \
80
- .relation('trial-attachment-data-stream')
81
- print_progress_and_debug('*', "getting #{result_data_relation}")
82
- resultset = result_data_relation.get.response.body
83
- print_progress_and_debug('*', "converting resultset")
84
- convert_resultset resultset, working_dir
85
- end
86
- end
87
- end
88
- rescue Exception => e
89
- @logger.error e
90
- end
91
- end
92
- end.map { |f| f.value!(3) }
93
- end.flatten.compact
94
- end
95
-
96
- ###############################################################################
97
- # Upload
98
- ###############################################################################
99
-
100
- def upload_as_tree_attachments(root, tree_id)
101
- print 'upload_as_tree_attachments'; STDOUT.flush
102
-
103
- Dir.glob('coverage/**/*').each do |filename|
104
- content_type = MIME::Types.of(filename).first.content_type rescue nil
105
- if content_type
106
- Faraday::UploadIO.new(filename, content_type)
107
- root.relation('tree-attachment-data-stream').put(
108
- { 'treeid' => tree_id, 'path' => filename },
109
- File.open(filename, 'rb').read, 'content-type' => content_type)
110
- print_progress_and_debug('*')
111
- end
112
- end
113
- puts ''
114
- end
115
-
116
- ###############################################################################
117
- # Simplev cov
118
- ###############################################################################
119
-
120
- def convert_resultset(resultset, working_dir)
121
- JSON.parse(resultset.to_json).map do |command_name, data|
122
- [command_name, data.map do |k, v|
123
- case k
124
- when 'coverage'
125
- [k, v.map do |filename, file_coverage|
126
- [(FileUtils.pwd + filename[working_dir.length, filename.length]) \
127
- , file_coverage]
128
- end.instance_eval { Hash[self] }]
129
- else
130
- [k, v]
131
- end
132
- end.instance_eval { Hash[self] }]
133
- end.instance_eval { Hash[self] }.instance_eval do
134
- SimpleCov::Result.from_hash(self)
135
- end
136
- end
137
-
138
- def reduce_resultsets(resultsets)
139
- puts 'reduce_resultsets'
140
- resultsets.reduce({}) do |agg, resultset|
141
- resultset.original_result.merge_resultset(agg)
142
- end
143
- end
144
-
145
- def init_simple_cov
146
- SimpleCov.add_group 'Models', 'app/models'
147
- SimpleCov.add_group 'Controllers', 'app/controllers'
148
- SimpleCov.add_group 'Views', 'app/views'
149
- SimpleCov.add_group 'Helpers', 'app/helpers'
150
- SimpleCov.add_group 'Factories', 'factories'
151
- SimpleCov.add_group 'Libraries', 'app/lib'
152
- end
153
-
154
- ###############################################################################
155
- # Run
156
- ###############################################################################
157
-
158
- def run_coverage(root, tree_id)
159
- get_and_convert_resultset_attachments(root, tree_id).instance_eval do
160
- reduce_resultsets self
161
- end.instance_eval do
162
- if self.empty?
163
- fail ScriptError, 'the collected and reduced coverage result is empty'
164
- end
165
- init_simple_cov
166
- SimpleCov::Result.new self
167
- end.instance_eval do
168
- SimpleCov::Formatter::HTMLFormatter.new.format self
169
- self
170
- end
171
- end
172
-
173
- ###############################################################################
174
- # Git
175
- ###############################################################################
176
-
177
- def assert_correct_tree_id(job)
178
- if job.data['tree_id'] != `git log -n 1 --pretty=%T`.strip
179
- fail ScriptError, 'you must be on the same tree_id as the job'
180
- end
181
- end
182
-
183
- def get_current_tree_id
184
- begin
185
- tree_id = `"git" "log" "-n" "1" "--pretty=%T"`.strip
186
- rescue _
187
- raise ScriptError, 'could not determine the current tree_id'
188
- end
189
-
190
- if $?.exitstatus != 0
191
- raise ScriptError, "could not determine the current tree_id"
192
- else
193
- tree_id
194
- end
195
- end
196
-
197
- ###############################################################################
198
- # Thread pool
199
- ###############################################################################
200
-
201
- def set_thread_pool(thread_pool_size)
202
- @pool = Thread.pool thread_pool_size
203
- end
204
-
205
- ###############################################################################
206
- # Options, main ....
207
- ###############################################################################
208
-
209
- def parse_options(options)
210
- OptionParser.new do |opts|
211
- opts.banner = 'Usage: cider-ci_coverage'
212
-
213
- opts.on('-a', '--api-url API-URL') do |url|
214
- options.api_url = url
215
- end
216
-
217
- opts.on('-e', '--job JOB_ID',
218
- 'Execution ID to retrieve coverage for') do |exid|
219
- options.job_id = exid
220
- end
221
-
222
- opts.on('-t', '--thread-pool-size N', Integer) do |t|
223
- options.thread_pool_size = t
224
- end
225
-
226
- opts.on('-u', '--username NAME', String) do |n|
227
- options.username = n
228
- end
229
-
230
- opts.on('-p', '--password PASSWORD', String) do |p|
231
- options.password = p
232
- end
233
-
234
- opts.on('-u', '--upload') do
235
- options.upload = true
236
- end
237
-
238
- opts.on('-d', '--debug') do
239
- @debug = true
240
- end
241
-
242
- opts.on('-l', '--limit N', Integer) do |l|
243
- options.limit = l
244
- end
245
- end.parse!
246
-
247
- options
248
- end
249
-
250
- def main
251
- options = OpenStruct.new
252
- options.thread_pool_size = 50
253
- options.username = ENV['CIDER_CI_USERNAME']
254
- options.password = ENV['CIDER_CI_PASSWORD']
255
- options.api_url = ENV['CIDER_CI_API_URL']
256
- options.upload = false
257
- options.limit = 95
258
- parse_options options
259
- options.api_url || fail(OptionParser::MissingArgument \
260
- , 'api_url is required, set CIDER_CI_API_URL \
261
- or provide -a option')
262
- options.username || fail(OptionParser::MissingArgument \
263
- , 'username is required, set CIDER_CI_USERNAME')
264
- options.password || fail(OptionParser::MissingArgument \
265
- , 'password is required, set CIDER_CI_PASSWORD')
266
-
267
- root = connect(options.api_url, options.username, options.password).get
268
- tree_id = get_current_tree_id
269
- set_thread_pool options.thread_pool_size
270
- FileUtils.rm_rf('coverage')
271
- result = run_coverage root, tree_id
272
- upload_as_tree_attachments root, tree_id if options.upload
273
-
274
- coverage = (result.covered_lines / result.total_lines.to_f)
275
-
276
- write_result_json coverage, options.limit
277
-
278
- if passed? coverage, options.limit
279
- exit
280
- else
281
- abort("FAILED coverage at #{per_cent(coverage)}% is \
282
- below limit of #{options.limit}% ")
283
- end
284
- end
285
-
286
- def write_result_json(coverage, limit)
287
- result_message = passed?(coverage, limit) ? 'passed' : 'failed'
288
- File.open('result.json', 'w') do |file|
289
- file.write({ value: coverage,
290
- summary: "#{result_message} with #{per_cent(coverage)}%"
291
- }.to_json)
292
- end
293
- end
294
-
295
- def passed?(coverage, limit)
296
- coverage > limit / 100.0
297
- end
298
-
299
- def per_cent(relative_value)
300
- (relative_value * 100.0).round(2)
301
- end
302
-
303
- main