cider_ci-support 1.0.0.pre.beta.2 → 1.0.0.pre.beta.3

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: 4a34b6f0b4b99b7a5e12f2e6b48a71ebfdb8bd58
4
- data.tar.gz: 2afc2fa2fc2edd6a45c4f05da5654bf313641921
3
+ metadata.gz: 641dd67b2153a83498378c4be26221537b512584
4
+ data.tar.gz: e4a14b1eb982f3f29107cd1c8672d78fbd3668f6
5
5
  SHA512:
6
- metadata.gz: bc29eca73106ae5335c2496cb32b2620c1f0778197545478466cd79f71a37125b9cf2f1f180183d4c167b59d18cb538bf70a88e44c8b2abfcba73975fe8e6621
7
- data.tar.gz: b4935d76a6db7f7b69c5ed8fd6017ec61fa8aaab041a20a34ba3b739240a7feac4d3044d816ee82954883156e8c36e00168f63229387dad9984d757b2d569e93
6
+ metadata.gz: 07acab8d1d9d399c3236c8d6efc5407c0d34df5ebf749775ead6012f280150b25acf4f15ed821637cfeb34204ee709ca860bc61eb6a78f99a4cfd2c4db285c0c
7
+ data.tar.gz: faf94688042a57f38438b5ebea929d6c628f9ef5fb7f16fe753010f7761a0f4224b645817152bdd461782b14a0cd53398b6b1d85ac798e88bfe59b2b5956e1b6
data/README.md CHANGED
@@ -8,17 +8,13 @@ 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'
11
+ gem 'cider_ci-support', '= 1.0.0.pre.beta.3'
12
12
  ```
13
13
 
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install cider_ci-rails
14
+ Read [this][] if you want to know why the version looks strange and why
15
+ you should use `=`.
21
16
 
17
+ [this]: https://github.com/json-roa/json-roa_ruby-client#semantic-versioning-and-rubygems-versioning
22
18
 
23
19
  ## Usage
24
20
 
@@ -40,7 +36,16 @@ Or install it yourself as:
40
36
 
41
37
  4. Within the top level directory of you project, e.g.
42
38
 
43
- cider-ci_coverage -e EXECUTION_ID
39
+ ~~~
40
+ cider-ci_coverage
41
+ ~~~
42
+
43
+ which will create the coverage output in `./coverage/`. Alternatively
44
44
 
45
+ ~~~
46
+ cider-ci_coverage --upload
47
+ ~~~
45
48
 
49
+ will additionally upload the files `./coverage/**/*`
50
+ as tree-attachments.
46
51
 
@@ -23,7 +23,7 @@ require 'thread/pool'
23
23
  require 'mime/types'
24
24
  require 'open-uri'
25
25
 
26
- #require 'pry'
26
+ require 'pry'
27
27
 
28
28
  ###############################################################################
29
29
  # Download from Cider-CI
@@ -40,33 +40,35 @@ def get_execution_resource root, execution_id
40
40
  root.relation('execution').get('id' => execution_id )
41
41
  end
42
42
 
43
-
44
- def get_and_convert_resultset_attachments execution, thread_pool_size
43
+ def get_and_convert_resultset_attachments root, tree_id, thread_pool_size
45
44
  print "download_resultset_attachments"; STDOUT.flush
46
45
  pool = Thread.pool thread_pool_size
47
- execution.relation('tasks').get("state" => "passed").collection\
48
- .map do |task_relation|
49
- Thread.future pool do
50
- print "."; STDOUT.flush
51
- task_relation.get().relation('trials') \
52
- .get("state" => "passed").collection.map(&:get).map do |trial|
46
+ root.relation("executions").get('treeid' => tree_id).collection \
47
+ .map(&:get).map do |execution|
48
+ execution.relation('tasks').get("state" => "passed").collection\
49
+ .map do |task_relation|
50
+ Thread.future pool do
53
51
  print "."; STDOUT.flush
54
- trial.relation('trial-attachments') \
55
- .get.collection.map do |tar|
56
- trial_attachment_resource= tar.get
52
+ task_relation.get().relation('trials') \
53
+ .get("state" => "passed").collection.map(&:get).map do |trial|
57
54
  print "."; STDOUT.flush
58
- if (working_dir= trial.data['scripts'] \
59
- .map{|k,v| v["working_dir"]}.compact.first) \
60
- and (trial_attachment_resource.data['path'] =~ /resultset\.json/)
61
- print "*"; STDOUT.flush
62
- resultset= trial_attachment_resource \
63
- .relation('data-stream').get.response.body
64
- convert_resultset resultset, working_dir
55
+ trial.relation('trial-attachments') \
56
+ .get.collection.map do |tar|
57
+ trial_attachment_resource= tar.get
58
+ print "."; STDOUT.flush
59
+ if (working_dir= trial.data['scripts'] \
60
+ .map{|k,v| v["working_dir"]}.compact.first) \
61
+ and (trial_attachment_resource.data['path'] =~ /resultset\.json/)
62
+ print "*"; STDOUT.flush
63
+ resultset= trial_attachment_resource \
64
+ .relation('trial-attachment-data-stream').get.response.body
65
+ convert_resultset resultset, working_dir
66
+ end
65
67
  end
66
68
  end
67
69
  end
68
- end
69
- end.map(&:~).flatten.compact
70
+ end.map(&:~)
71
+ end.flatten.compact
70
72
  end
71
73
 
72
74
 
@@ -74,14 +76,15 @@ end
74
76
  # Upload
75
77
  ###############################################################################
76
78
 
77
- def upload_as_tree_attachments execution
79
+ # TODO add tree-attachments relation at cider root
80
+ def upload_as_tree_attachments root, tree_id
78
81
  print "upload_as_tree_attachments"; STDOUT.flush
79
- upload_relation= execution.relation("tree-attachments").get() \
80
- .relation("data-stream")
82
+
81
83
  Dir.glob("coverage/**/*").each do |filename|
82
84
  if content_type= MIME::Types.of(filename).first.content_type rescue nil
83
85
  payload= Faraday::UploadIO.new(filename, content_type)
84
- upload_relation.put({"path" => filename},
86
+ root.relation("tree-attachment-data-stream").put({"treeid" => tree_id,
87
+ "path" => filename},
85
88
  File.open(filename, "rb").read,
86
89
  {"content-type" => content_type})
87
90
  print "*"; STDOUT.flush
@@ -135,11 +138,12 @@ end
135
138
  # Run
136
139
  ###############################################################################
137
140
 
138
- def run_coverage execution, thrad_pool_size
139
- get_and_convert_resultset_attachments(execution,thrad_pool_size) \
141
+ def run_coverage root, tree_id, thrad_pool_size
142
+ get_and_convert_resultset_attachments(root,tree_id,thrad_pool_size) \
140
143
  .instance_eval do
141
144
  reduce_resultsets self
142
145
  end.instance_eval do
146
+ raise ScriptError, "the collected and reduced coverage result is empty" if self.empty?
143
147
  init_simple_cov
144
148
  SimpleCov::Result.new self
145
149
  end.instance_eval do
@@ -180,6 +184,10 @@ def parse_options options
180
184
  options.password= p
181
185
  end
182
186
 
187
+ opts.on('-u', '--upload') do
188
+ options.upload= true
189
+ end
190
+
183
191
  end.parse!
184
192
 
185
193
  options
@@ -192,16 +200,28 @@ def assert_correct_tree_id execution
192
200
  end
193
201
  end
194
202
 
203
+ def get_current_tree_id
204
+ begin
205
+ tree_id= `"git" "log" "-n" "1" "--pretty=%T"`.strip
206
+ rescue _
207
+ raise ScriptError, "could not determine the current tree_id"
208
+ end
209
+
210
+ if $?.exitstatus != 0
211
+ raise ScriptError, "could not determine the current tree_id"
212
+ else
213
+ tree_id
214
+ end
215
+ end
216
+
195
217
  def main
196
218
  options = OpenStruct.new
197
219
  options.thread_pool_size= 50
198
- options.execution_id= nil
199
220
  options.username= ENV['CIDER_CI_USERNAME']
200
221
  options.password= ENV['CIDER_CI_PASSWORD']
201
222
  options.api_url= ENV['CIDER_CI_API_URL']
223
+ options.upload= false
202
224
  parse_options options
203
- options.execution_id || raise(OptionParser::MissingArgument \
204
- , "execution_id is required")
205
225
  options.api_url || raise(OptionParser::MissingArgument \
206
226
  , "api_url is required, set CIDER_CI_API_URL or provide -a option")
207
227
  options.username || raise(OptionParser::MissingArgument \
@@ -209,13 +229,13 @@ def main
209
229
  options.password || raise(OptionParser::MissingArgument \
210
230
  , "password is required, set CIDER_CI_PASSWORD")
211
231
 
212
-
213
232
  root = connect(options.api_url, options.username, options.password).get()
214
- execution= get_execution_resource root, options.execution_id
215
- assert_correct_tree_id execution
233
+ tree_id = get_current_tree_id
216
234
  FileUtils.rm_rf('coverage')
217
- run_coverage execution, options.thread_pool_size
218
- upload_as_tree_attachments execution
235
+ run_coverage root, tree_id, options.thread_pool_size
236
+ if options.upload
237
+ upload_as_tree_attachments root, tree_id
238
+ end
219
239
  end
220
240
 
221
241
  main
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'mime-types'
25
25
  spec.add_runtime_dependency 'thread', '= 0.1.4'
26
26
  spec.add_runtime_dependency 'simplecov', '~> 0.9'
27
- spec.add_runtime_dependency 'json_roa-client', "= 1.0.0.pre.beta.1"
27
+ spec.add_runtime_dependency 'json_roa-client', ">= 1.0.0.pre.beta.2"
28
28
  end
@@ -1,5 +1,5 @@
1
1
  module Cider_CI
2
2
  module Support
3
- VERSION = "1.0.0-beta.2"
3
+ VERSION = "1.0.0-beta.3"
4
4
  end
5
5
  end
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.0.0.pre.beta.2
4
+ version: 1.0.0.pre.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Schank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: json_roa-client
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.0.0.pre.beta.1
89
+ version: 1.0.0.pre.beta.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.0.0.pre.beta.1
96
+ version: 1.0.0.pre.beta.2
97
97
  description: ''
98
98
  email:
99
99
  - DrTom@schank.ch