cider_ci-rails 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/bin/cider-ci_coverage +199 -0
- data/cider_ci-rails.gemspec +27 -0
- data/lib/cider_ci/rails.rb +7 -0
- data/lib/cider_ci/rails/version.rb +5 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 781707e9b857a5e8c0fd17058fc2362e380a8ca4
|
4
|
+
data.tar.gz: 514dd13a2185b05949ee9a526d9e4bbef48bb6e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81421d2e247790385702e7a062c2c1fd789e2f5549e6603843049d02586d8072d30d16236ef39ff42be28a33335afb38c7e838a9729a3838334a382bb38f1c93
|
7
|
+
data.tar.gz: 905c8a11250249e2d9a22743d14f9531eafa820b320dff958a38e8eaa929f758b402349752270deeef1a357d6340c9bff0bb0f77310620302fb3f6bcf84e17d8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Thomas Schank
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Cider-CI Support for Ruby and Ruby on Rails projects
|
2
|
+
|
3
|
+
This gem provides convenience executables to work with Cider-CI.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'cider_ci-rails'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install cider_ci-rails
|
21
|
+
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Aggregate Coverage with `cider-ci_coverage`
|
26
|
+
|
27
|
+
1. Add [Simplecov]() to your project and configure it.
|
28
|
+
|
29
|
+
2. Have the coverage output attached to the trials, e.g.
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
task_defaults:
|
33
|
+
trial_attachments:
|
34
|
+
coverage_resultset:
|
35
|
+
glob: 'coverage/.resultset.json'
|
36
|
+
content-type: application/json
|
37
|
+
```
|
38
|
+
|
39
|
+
3. Run the tests on Cider-CI.
|
40
|
+
|
41
|
+
4. Within the top level directory of you project, e.g.
|
42
|
+
|
43
|
+
cider-ci_coverage -e EXECUTION_ID
|
44
|
+
|
45
|
+
|
46
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
###############################################################################
|
4
|
+
# This script gathers ruby coverage information from a cider-ci instance and
|
5
|
+
# aggregates it via simplecov.
|
6
|
+
#
|
7
|
+
# Authors: Thomas Schank <DrTom@schank.ch>
|
8
|
+
#
|
9
|
+
###############################################################################
|
10
|
+
|
11
|
+
|
12
|
+
# Planned features for the future:
|
13
|
+
#
|
14
|
+
# * upload result to cider-ci (attachments to the tree_id)
|
15
|
+
|
16
|
+
require 'fileutils'
|
17
|
+
require 'json_roa/client'
|
18
|
+
require 'optparse'
|
19
|
+
require 'ostruct'
|
20
|
+
require 'simplecov'
|
21
|
+
require 'thread/future'
|
22
|
+
require 'thread/pool'
|
23
|
+
#require 'pry'
|
24
|
+
|
25
|
+
###############################################################################
|
26
|
+
# Download from Cider-CI
|
27
|
+
###############################################################################
|
28
|
+
|
29
|
+
def connect base_url, username, password
|
30
|
+
root_resource = JSON_ROA::Client.connect base_url do |conn|
|
31
|
+
conn.basic_auth(username,password)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_execution_resource root, execution_id
|
36
|
+
root.relation('execution').get('id' => execution_id )
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def get_and_convert_resultset_attachments execution, thread_pool_size
|
41
|
+
print "download_resultset_attachments"; STDOUT.flush
|
42
|
+
pool = Thread.pool thread_pool_size
|
43
|
+
|
44
|
+
execution.relation('tasks').get.collection.map do |task_relation|
|
45
|
+
Thread.future pool do
|
46
|
+
print "."; STDOUT.flush
|
47
|
+
task_relation.get().relation('trials') \
|
48
|
+
.get.collection.map(&:get).map do |trial|
|
49
|
+
print "."; STDOUT.flush
|
50
|
+
trial.relation('trial-attachments') \
|
51
|
+
.get.collection.map do |tar|
|
52
|
+
trial_attachment_resource= tar.get
|
53
|
+
print "."; STDOUT.flush
|
54
|
+
if (working_dir= trial.data['scripts'] \
|
55
|
+
.map{|k,v| v["working_dir"]}.compact.first) \
|
56
|
+
and (trial_attachment_resource.data['path'] =~ /resultset\.json/)
|
57
|
+
print "*"; STDOUT.flush
|
58
|
+
resultset= trial_attachment_resource \
|
59
|
+
.relation('data-stream').get.response.body
|
60
|
+
convert_resultset resultset, working_dir
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end.map(&:~).flatten.compact
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
###############################################################################
|
71
|
+
# Simplev cov
|
72
|
+
###############################################################################
|
73
|
+
|
74
|
+
|
75
|
+
def convert_resultset resultset, working_dir
|
76
|
+
SimpleCov::JSON.parse(resultset.to_json).map do |command_name, data|
|
77
|
+
[ command_name, data.map do |k,v|
|
78
|
+
case k
|
79
|
+
when "coverage"
|
80
|
+
[ k, v.map do |filename,file_coverage|
|
81
|
+
[(FileUtils.pwd + filename[working_dir.length,filename.length]) \
|
82
|
+
, file_coverage]
|
83
|
+
end.instance_eval{Hash[self]} ]
|
84
|
+
else
|
85
|
+
[k,v]
|
86
|
+
end
|
87
|
+
end.instance_eval {Hash[self]} ]
|
88
|
+
end.instance_eval{Hash[self]}.instance_eval{SimpleCov::Result.from_hash(self)}
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def reduce_resultsets resultsets
|
93
|
+
puts "reduce_resultsets"
|
94
|
+
resultsets.reduce({}) do |agg,resultset|
|
95
|
+
resultset.original_result.merge_resultset(agg)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def init_simple_cov
|
101
|
+
SimpleCov.add_group "Models", "app/models"
|
102
|
+
SimpleCov.add_group "Controllers", "app/controllers"
|
103
|
+
SimpleCov.add_group "Views", "app/views"
|
104
|
+
SimpleCov.add_group "Helpers", "app/helpers"
|
105
|
+
SimpleCov.add_group "Factories", "factories"
|
106
|
+
SimpleCov.add_group "Libraries", "app/lib"
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
###############################################################################
|
111
|
+
# Run
|
112
|
+
###############################################################################
|
113
|
+
|
114
|
+
def run_coverage execution, thrad_pool_size
|
115
|
+
get_and_convert_resultset_attachments(execution,thrad_pool_size) \
|
116
|
+
.instance_eval do
|
117
|
+
reduce_resultsets self
|
118
|
+
end.instance_eval do
|
119
|
+
init_simple_cov
|
120
|
+
SimpleCov::Result.new self
|
121
|
+
end.instance_eval do
|
122
|
+
SimpleCov::Formatter::HTMLFormatter.new.format self
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
###############################################################################
|
128
|
+
# Options, main ....
|
129
|
+
###############################################################################
|
130
|
+
|
131
|
+
|
132
|
+
def parse_options options
|
133
|
+
|
134
|
+
|
135
|
+
optparse = OptionParser.new do |opts|
|
136
|
+
opts.banner = "Usage: retrieve_cider_coverage.rb -e EXECUTION_ID"
|
137
|
+
|
138
|
+
opts.on('-a', '--api-url API-URL') do |url|
|
139
|
+
options.api_url= url
|
140
|
+
end
|
141
|
+
|
142
|
+
opts.on('-e', '--execution EXECUTION_ID',
|
143
|
+
'Execution ID to retrieve coverage for') do |exid|
|
144
|
+
options.execution_id = exid
|
145
|
+
end
|
146
|
+
|
147
|
+
opts.on('-t', '--thread-pool-size N', Integer) do |t|
|
148
|
+
options.thread_pool_size = t
|
149
|
+
end
|
150
|
+
|
151
|
+
opts.on('-u', '--username NAME', String) do |n|
|
152
|
+
options.username = n
|
153
|
+
end
|
154
|
+
|
155
|
+
opts.on('-p', '--password PASSWORD', String) do |p|
|
156
|
+
options.password= p
|
157
|
+
end
|
158
|
+
|
159
|
+
end.parse!
|
160
|
+
|
161
|
+
options
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
def assert_correct_tree_id execution
|
166
|
+
if execution.data['tree_id'] != `git log -n 1 --pretty=%T`.strip
|
167
|
+
raise ScriptError, "you must be on the same tree_id as the execution"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
def main
|
173
|
+
options = OpenStruct.new
|
174
|
+
options.thread_pool_size= 50
|
175
|
+
options.execution_id= nil
|
176
|
+
options.username= ENV['CIDER_CI_USERNAME']
|
177
|
+
options.password= ENV['CIDER_CI_PASSWORD']
|
178
|
+
options.api_url= ENV['CIDER_CI_API_URL']
|
179
|
+
parse_options options
|
180
|
+
options.execution_id || raise(OptionParser::MissingArgument \
|
181
|
+
, "execution_id is required")
|
182
|
+
options.api_url || raise(OptionParser::MissingArgument \
|
183
|
+
, "api_url is required, set CIDER_CI_API_URL or provide -a option")
|
184
|
+
options.username || raise(OptionParser::MissingArgument \
|
185
|
+
, "username is required, set CIDER_CI_USERNAME")
|
186
|
+
options.password || raise(OptionParser::MissingArgument \
|
187
|
+
, "password is required, set CIDER_CI_PASSWORD")
|
188
|
+
|
189
|
+
|
190
|
+
root = connect options.api_url, options.username, options.password
|
191
|
+
execution= get_execution_resource root, options.execution_id
|
192
|
+
assert_correct_tree_id execution
|
193
|
+
FileUtils.rm_rf('coverage')
|
194
|
+
run_coverage execution, options.thread_pool_size
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
main
|
199
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cider_ci/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cider_ci-rails"
|
8
|
+
spec.version = Cider_CI::Rails::VERSION
|
9
|
+
spec.authors = ["Thomas Schank"]
|
10
|
+
spec.email = ["DrTom@schank.ch"]
|
11
|
+
spec.summary = "Cider-CI support for Ruby and Ruby on Rails projects"
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_dependency "thread", '~> 0.1.4'
|
25
|
+
spec.add_dependency "simplecov", '~> 0.9.1'
|
26
|
+
spec.add_dependency "json_roa-client", '~> 0.0.1'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cider_ci-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Schank
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thread
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_roa-client
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- DrTom@schank.ch
|
86
|
+
executables:
|
87
|
+
- cider-ci_coverage
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/cider-ci_coverage
|
97
|
+
- cider_ci-rails.gemspec
|
98
|
+
- lib/cider_ci/rails.rb
|
99
|
+
- lib/cider_ci/rails/version.rb
|
100
|
+
homepage: ''
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.2.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Cider-CI support for Ruby and Ruby on Rails projects
|
124
|
+
test_files: []
|