optimal-ci 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 2318277197a7ce20da7a7258789259644f06023b02710fff36f3b88729fde7f3
4
- data.tar.gz: 4b33a271f965c9f5a11129eddc5c9949c1cb59d6f43e931a3b901bbbac084b25
3
+ metadata.gz: a2d9c62c321e5a3702d218bcc515a884830e0506fa3a980bdc1745f726018e20
4
+ data.tar.gz: 267d5d310754eed8ec65edc7870f32d95ad5e7a7a1d41c286a0019a62120de72
5
5
  SHA512:
6
- metadata.gz: 796b3d64090a9d1dde4565098fe4b506e8d1e847f0d12d6ffba51c808aabb7db5a9eaf4712b785042f13d63adfd8aaac4691cb6c0a91fb90521c6cd516a0dcc6
7
- data.tar.gz: 10be10ba8eb411613e861502f23f60579460316962201d5e5e15a72f41667bfc477893c339d4518c65aace42d76b0b4a0f6d1dec05a0abc364fbd546038aff28
6
+ metadata.gz: f920b896f204af232e1e729793482e0e72d0bc029b792d817a9f8c682a89467cb5eb91a009e743b72ef5ffa0268546264bbcc4c43f6d282cba714be66b663796
7
+ data.tar.gz: 11dc14235e42661d408607c16d9bf06b8dbdfc03547442714093a3245f03af9e389bbb687c8e03293cb68f8432722b02d1e6b0ab36eac11aea02331de9f6ef6e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optimal-ci (0.0.3)
4
+ optimal-ci (0.0.4)
5
5
  rest-client (~> 2.1.0)
6
6
 
7
7
  GEM
@@ -1,5 +1,6 @@
1
1
  require 'rest_client'
2
2
  require 'json'
3
+ require 'rspec/core'
3
4
  require "optimal/ci/version"
4
5
  require "optimal/ci/runner"
5
6
  require "optimal/ci/queue"
@@ -4,6 +4,8 @@ module Optimal
4
4
  def initialize(provider, command_arguments_string = "")
5
5
  @provider = provider
6
6
  @command_arguments_string = command_arguments_string
7
+ @http_calls_count = 0
8
+ @http_calls_time = 0.0
7
9
 
8
10
  raise "OPTIMAL_CI_URL is not valid ENV" if ENV['OPTIMAL_CI_URL'].nil?
9
11
  raise "OPTIMAL_CI_TOKEN is not valid ENV" if ENV['OPTIMAL_CI_TOKEN'].nil?
@@ -26,8 +28,12 @@ module Optimal
26
28
  end
27
29
 
28
30
  def pop
31
+ start = Time.now
29
32
  response = ::RestClient.get(ENV['OPTIMAL_CI_URL'] + "/builds/#{@provider.build_number}/get_one_file", { Authorization: ENV['OPTIMAL_CI_TOKEN'] })
30
33
 
34
+ @http_calls_count += 1
35
+ @http_calls_time += (Time.now - start).to_f
36
+
31
37
  return if response.code != 200
32
38
 
33
39
  JSON.parse(response.body)
@@ -44,6 +50,16 @@ module Optimal
44
50
 
45
51
  ::RestClient.patch(ENV['OPTIMAL_CI_URL'] + "/builds/#{@provider.build_number}/report_duration", params, { Authorization: ENV['OPTIMAL_CI_TOKEN'] })
46
52
  end
53
+
54
+ def report_http_calls
55
+ params = {
56
+ http_calls_count: @http_calls_count,
57
+ http_calls_time: @http_calls_time,
58
+ node_index: @provider.node_index
59
+ }
60
+
61
+ ::RestClient.patch(ENV['OPTIMAL_CI_URL'] + "/builds/#{@provider.build_number}/report_http_calls", params, { Authorization: ENV['OPTIMAL_CI_TOKEN'] })
62
+ end
47
63
  end
48
64
  end
49
65
  end
@@ -22,12 +22,13 @@ module Optimal
22
22
  start_time = Time.now.to_i
23
23
 
24
24
  while files = queue.pop
25
- system("#{command} #{files.join(' ')}")
25
+ run_examples(files)
26
26
  end
27
27
 
28
28
  duration = Time.now.to_i - start_time
29
29
 
30
30
  queue.report_duration(duration)
31
+ queue.report_http_calls
31
32
 
32
33
  Optimal::CI::Logger.info("reporting duration : #{duration}")
33
34
  else
@@ -36,6 +37,10 @@ module Optimal
36
37
  end
37
38
  end
38
39
 
40
+ def run_examples(examples)
41
+ raise "Not Implemented"
42
+ end
43
+
39
44
  def total_files
40
45
  return @total_files if @total_files
41
46
 
@@ -1,5 +1,5 @@
1
1
  module Optimal
2
2
  module CI
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -12,6 +12,11 @@ module RSpec
12
12
  def files_end_with
13
13
  "_spec.rb"
14
14
  end
15
+
16
+ def run_examples(examples)
17
+ RSpec::Core::Runner.run(examples)
18
+ RSpec.clear_examples
19
+ end
15
20
  end
16
21
  end
17
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optimal-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohsen Alizadeh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-03 00:00:00.000000000 Z
11
+ date: 2020-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client