optimal-ci 0.0.2 → 0.0.3

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: 2dc80539a7e54f44e4f76945a1a82d7068cdf6168a8473ab88ebac94c2a083b3
4
- data.tar.gz: 21fd500ce95f28861002a915fd91c26253745ed5511ca332cc296077b0b60c88
3
+ metadata.gz: 2318277197a7ce20da7a7258789259644f06023b02710fff36f3b88729fde7f3
4
+ data.tar.gz: 4b33a271f965c9f5a11129eddc5c9949c1cb59d6f43e931a3b901bbbac084b25
5
5
  SHA512:
6
- metadata.gz: 71b745d20d0e4bbd8253a04927964d464a3f3819053d25565fef73ce3fbcd8a48162e2aff99ef01abe7de355bc3ecc383250082db14463e607210d5688e96d63
7
- data.tar.gz: d2310f3801cb6e0272a3ded4888e52edea3b177944b2460452b2bf39678bfbc54c03a0606078e7774a5c79c7e8de2f9988b5e7be4aac31dfa0b263abad1c8b6b
6
+ metadata.gz: 796b3d64090a9d1dde4565098fe4b506e8d1e847f0d12d6ffba51c808aabb7db5a9eaf4712b785042f13d63adfd8aaac4691cb6c0a91fb90521c6cd516a0dcc6
7
+ data.tar.gz: 10be10ba8eb411613e861502f23f60579460316962201d5e5e15a72f41667bfc477893c339d4518c65aace42d76b0b4a0f6d1dec05a0abc364fbd546038aff28
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optimal-ci (0.0.2)
4
+ optimal-ci (0.0.3)
5
5
  rest-client (~> 2.1.0)
6
6
 
7
7
  GEM
@@ -5,6 +5,7 @@ require "optimal/ci/runner"
5
5
  require "optimal/ci/queue"
6
6
  require "rspec/optimal/runner"
7
7
  require "optimal/ci/provider"
8
+ require "optimal/ci/logger"
8
9
  require "optimal/ci/provider/base"
9
10
  require "optimal/ci/provider/travis"
10
11
  require "optimal/ci/provider/circle"
@@ -0,0 +1,11 @@
1
+ module Optimal
2
+ module CI
3
+ class Logger
4
+ class << self
5
+ def info(string)
6
+ puts "OPTIMAL-CI ->>> #{string}"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -14,7 +14,8 @@ module Optimal
14
14
  build_number: @provider.build_number,
15
15
  total_files: files,
16
16
  ci: @provider.name,
17
- command_arguments_string: @command_arguments_string
17
+ command_arguments_string: @command_arguments_string,
18
+ total_nodes: @provider.total_nodes
18
19
  }
19
20
 
20
21
  response = ::RestClient.post(ENV['OPTIMAL_CI_URL'] + '/builds', params, { Authorization: ENV['OPTIMAL_CI_TOKEN'] })
@@ -34,6 +35,15 @@ module Optimal
34
35
  rescue RestClient::NotFound
35
36
  return nil
36
37
  end
38
+
39
+ def report_duration(duration)
40
+ params = {
41
+ duration: duration,
42
+ node_index: @provider.node_index
43
+ }
44
+
45
+ ::RestClient.patch(ENV['OPTIMAL_CI_URL'] + "/builds/#{@provider.build_number}/report_duration", params, { Authorization: ENV['OPTIMAL_CI_TOKEN'] })
46
+ end
37
47
  end
38
48
  end
39
49
  end
@@ -14,12 +14,25 @@ module Optimal
14
14
 
15
15
  def run
16
16
  provider = Optimal::CI::Provider.detect
17
- queue = Optimal::CI::Queue.new(provider, @command_arguments_string)
18
17
 
19
- queue.push(total_files)
18
+ if provider
19
+ queue = Optimal::CI::Queue.new(provider, @command_arguments_string)
20
+ queue.push(total_files)
20
21
 
21
- while files = queue.pop
22
- system("#{command} #{files.join(' ')}")
22
+ start_time = Time.now.to_i
23
+
24
+ while files = queue.pop
25
+ system("#{command} #{files.join(' ')}")
26
+ end
27
+
28
+ duration = Time.now.to_i - start_time
29
+
30
+ queue.report_duration(duration)
31
+
32
+ Optimal::CI::Logger.info("reporting duration : #{duration}")
33
+ else
34
+ Optimal::CI::Logger.info("provider not found")
35
+ system("#{command} #{@args.join(' ')}")
23
36
  end
24
37
  end
25
38
 
@@ -32,7 +45,7 @@ module Optimal
32
45
  if path.end_with?(files_end_with)
33
46
  @total_files << path
34
47
  else
35
- @total_files << Dir.glob("#{path}/**/*#{files_end_with}")
48
+ @total_files << Dir.glob("#{path.chomp("/")}/**/*#{files_end_with}")
36
49
  end
37
50
  end
38
51
 
@@ -1,5 +1,5 @@
1
1
  module Optimal
2
2
  module CI
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  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.2
4
+ version: 0.0.3
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-08-31 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -57,6 +57,7 @@ files:
57
57
  - bin/setup
58
58
  - exe/optimal-rspec
59
59
  - lib/optimal/ci.rb
60
+ - lib/optimal/ci/logger.rb
60
61
  - lib/optimal/ci/provider.rb
61
62
  - lib/optimal/ci/provider/base.rb
62
63
  - lib/optimal/ci/provider/circle.rb