oyencov 0.0.1.pre → 0.0.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
  SHA256:
3
- metadata.gz: 829c5d959c386d08c7d81c836251104461d0875fc4fb6e04d1963cd32301235b
4
- data.tar.gz: 4f14f7447a5278cc84b89d7c6bcd9d4fa97c6ea3f12f4d898e89b042a5de880d
3
+ metadata.gz: c102e275b55a04670f66472c988915b439ffff0bb1244bf030ced28a91f41d2f
4
+ data.tar.gz: 5eca0a2836563c253c2a4d6d632847f54e2947e146a927e53d2e9f87889ecc17
5
5
  SHA512:
6
- metadata.gz: 11a0471aae67aa816d1840f1882eaa206be0ad339ab40fae872567985579a8e84dbae85573b5466083450849b33c30e9ee7a136c48d7ad08d1976849ce46290f
7
- data.tar.gz: f896668dcbdf7deb0cb392da50f410fca1a0361f20181844fd99753df1ebd83ea3d5d870a9e3790cce60debe8fef09b88430a58149b40ac016c95c7244a3c23e
6
+ metadata.gz: d7096ed5ab32b52780d50003774e747fcd5790133e5f31060ab25081d3f620608690c58d9aa548e9cd8f2898c2124799e21277555ac2941205c0530ada877876
7
+ data.tar.gz: ce29ca45cdd0a10c8fa03fe31dfa3959ece15af843deb5962775094d93e3e58682ab7ca187980f3afdef191495264a7bc3c029a2f26d013cb282e7d34c8e20a4
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ���S����e)�Ȃ��!����v6P�B���Ϻ���<�g4�<��[�j�����K��u-+���~Y���]X5��q
@@ -1,5 +1,6 @@
1
1
  require "faraday"
2
2
  require "singleton"
3
+ require_relative "version"
3
4
 
4
5
  module OyenCov
5
6
  class APIConnection < Faraday::Connection
@@ -11,7 +12,7 @@ module OyenCov
11
12
  headers: {
12
13
  "Authorization" => "Bearer #{ENV["OYENCOV_API_KEY"]}",
13
14
  "Content-Type" => "application/json",
14
- "User-Agent" => "oyencov-ruby 0.0.1"
15
+ "User-Agent" => "oyencov-ruby #{OyenCov::VERSION}"
15
16
  }
16
17
  }) do |f|
17
18
  f.request :json
@@ -23,23 +23,31 @@ module OyenCov
23
23
  @config = OyenCov.config
24
24
 
25
25
  def self.start
26
- puts "Hello #{Rails.env}"
26
+ if ENV["OYENCOV_DEBUG"]
27
+ puts "[OyenCov] Env: #{Rails.env}"
28
+ puts "[OyenCov] $PROGRAM_NAME: #{$PROGRAM_NAME || "nil"}"
29
+ puts "[OyenCov] @process_type: #{@config.process_type}"
30
+ end
27
31
 
28
32
  # Start `Coverage` as soon as possible before other codes are loaded
29
33
  CoveragePeekDelta.start
30
34
 
35
+ # This thread is for production reporting only.
31
36
  @thread = Thread.new {
32
37
  # Check with backend to get parameters
33
38
  sleep(3)
34
- clearance = @api_conn.get_data_submission_clearance
35
39
 
36
- if clearance.nil?
37
- puts "Unable to obtain oyencov submission clearance. Stopping OyenCov background thread."
38
- Thread.stop
39
- end
40
+ if @config.mode == "production"
41
+ clearance = @api_conn.get_data_submission_clearance
40
42
 
41
- if ENV["OYENCOV_DEBUG"]
42
- puts(clearance.body)
43
+ if clearance.nil?
44
+ puts "[OyenCov] Unable to obtain oyencov submission clearance. Stopping OyenCov background thread."
45
+ Thread.stop
46
+ end
47
+
48
+ if ENV["OYENCOV_DEBUG"]
49
+ puts(clearance.body)
50
+ end
43
51
  end
44
52
 
45
53
  @config.mode == "production" && loop do
@@ -57,9 +65,9 @@ module OyenCov
57
65
  response = @api_conn.post_runtime_report(runtime_report)
58
66
 
59
67
  if response && response.body["status"] == "ok"
60
- puts "[OyenOnsen] POST runtime_report ok."
68
+ puts "[OyenCov] POST runtime_report ok."
61
69
  else
62
- warn "[OyenOnsen] POST runtime_report failed. Stopping background thread."
70
+ warn "[OyenCov] POST runtime_report failed. Stopping background thread."
63
71
  Thread.stop
64
72
  end
65
73
  end # loop
data/lib/oyencov/cli.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "thor"
2
- require_relative "./api_connection"
3
- require_relative "./test_report_merger"
4
- require_relative "./simplecov_resultset_translator"
2
+ require_relative "api_connection"
3
+ require_relative "test_report_merger"
4
+ require_relative "simplecov_resultset_translator"
5
5
 
6
6
  # Bootstrapped from `bin/oyencov`
7
7
  #
@@ -27,11 +27,12 @@ module OyenCov
27
27
  simplecov_json_path = Dir.pwd + "/" + options[:simplecov_json_path]
28
28
 
29
29
  # Find existing resultset files
30
+ # We can start with empty JSON instead of exiting with error
30
31
  if File.exist?(oyencov_json_path)
31
32
  oyencov_json = File.read(oyencov_json_path)
32
33
  else
33
- warn("Could not find existing oyencov-resultset.json at #{oyencov_json_path}")
34
- exit(1)
34
+ warn("Could not find existing oyencov-resultset.json at #{oyencov_json_path}.")
35
+ oyencov_json = "{}"
35
36
  end
36
37
 
37
38
  warn "Starting to translate simplecov"
@@ -43,7 +44,7 @@ module OyenCov
43
44
  exit(1)
44
45
  end
45
46
 
46
- warn "AFTER translate simplecov"
47
+ warn "Done translating simplecov"
47
48
 
48
49
  # Attempt merging
49
50
  oyencov_resultset = JSON.parse(oyencov_json)
@@ -56,11 +57,13 @@ module OyenCov
56
57
  else
57
58
  File.write(oyencov_json_path, new_oyencov_resultset_json)
58
59
  end
60
+
61
+ warn "Saved oyencov resultset to: #{oyencov_json_path}"
59
62
  end
60
63
 
61
64
  desc "submit tmp/coverage-jsons-*/oyencov-resultset.json",
62
65
  "submits the oyencov resultsets data"
63
- option :files, type: :array, required: true
66
+ option :files, type: :array, default: ["coverage/oyencov-resultset.json"]
64
67
  option :git_commit_sha, required: true
65
68
  option :token
66
69
  def submit
@@ -1,4 +1,4 @@
1
- # We encourage configuring OyenOnsen through environment variables.
1
+ # We encourage configuring OyenCov through environment variables.
2
2
  #
3
3
  # But some can be set through config/ if they are meant to be uniform across environments.
4
4
  module OyenCov
@@ -13,12 +13,12 @@ module OyenCov
13
13
  PROGRAM_NAME
14
14
  ]
15
15
 
16
- attr :api_key, :api_url, :mode, :including_file_paths, :excluding_file_paths, :release, :test_reporting_dir, :test_resultset_path, :program_name
16
+ attr :api_key, :api_url, :mode, :including_file_paths, :excluding_file_paths, :release, :test_reporting_dir, :test_resultset_path, :program_name, :process_type
17
17
 
18
18
  def initialize
19
19
  reset_to_defaults
20
20
  ENV_PARAMETERS.each do |key|
21
- if (envvar_value = ENV["OYENONSEN_#{key}"])
21
+ if (envvar_value = ENV["OYENCOV_#{key}"])
22
22
  instance_variable_set(
23
23
  :"@#{key.downcase}", envvar_value
24
24
  )
@@ -29,10 +29,11 @@ module OyenCov
29
29
  def reset_to_defaults
30
30
  @api_key = nil
31
31
  @api_url = "https://telemetry-api.oyencov.com"
32
- @mode = ENV["RAILS_ENV"]
32
+ @mode = ENV["OYENCOV_ENV"] || ENV["RAILS_ENV"]
33
33
  @including_file_paths = %w[app lib]
34
34
  @excluding_file_paths = []
35
35
  @release = suggest_release
36
+ @process_type = suggest_process_type
36
37
  @test_reporting_dir = "coverage/"
37
38
  @test_resultset_path = "coverage/oyencov-resultset.json"
38
39
  end
@@ -56,7 +57,26 @@ module OyenCov
56
57
  end
57
58
 
58
59
  # We need to know if this is rails, sidekiq, rake task etc
59
- def suggest_program_name
60
+ #
61
+ # Method 1: $PROGRAM_NAME.split("/")[-1]
62
+ def suggest_process_type
63
+ answer = nil
64
+ sliced_program_name = File.basename($PROGRAM_NAME)
65
+
66
+ if %w[sidekiq resque].include?(sliced_program_name)
67
+ return sliced_program_name
68
+ end
69
+
70
+ # Rails can be server or rake task
71
+ if sliced_program_name == "rails"
72
+ if defined?(Rails) && Rails.respond_to?(:server) && !!Rails.server
73
+ return "rails server"
74
+ else
75
+ return "rake"
76
+ end
77
+ end
78
+
79
+ "-"
60
80
  end
61
81
  end
62
82
  end
@@ -28,7 +28,7 @@ module OyenCov
28
28
  def self.snapshot_delta
29
29
  current_peek = Coverage.peek_result
30
30
 
31
- if ENV["OYENONSEN_DEBUG"]
31
+ if ENV["OYENCOV_DEBUG"]
32
32
  $stdout.puts "current_peek size = #{current_peek.size}, keys like: #{current_peek.keys[0, 3]}"
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ module OyenCov
39
39
  k.gsub(/#{PWD}\//o, "")
40
40
  end
41
41
 
42
- if ENV["OYENONSEN_DEBUG"]
42
+ if ENV["OYENCOV_DEBUG"]
43
43
  $stdout.puts "filtered size = #{filtered.size}, keys like: #{filtered.keys[0, 3]}"
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ module OyenCov
48
48
  /^(app|lib)/.match?(k)
49
49
  end
50
50
 
51
- if ENV["OYENONSEN_DEBUG"]
51
+ if ENV["OYENCOV_DEBUG"]
52
52
  $stdout.puts "filtered size = #{filtered.size}, keys like: #{filtered.keys[0, 3]}"
53
53
  end
54
54
 
@@ -65,7 +65,6 @@ module OyenCov
65
65
  # Compare and delta
66
66
  new_method_hits = {}
67
67
  current_method_hits.each_pair do |method_name, counter|
68
- if counter.nil?; puts method_name; end
69
68
  new_hits = counter - (@@previous_method_hits[method_name] || 0)
70
69
  if new_hits > 0
71
70
  new_method_hits[method_name] = new_hits
@@ -10,7 +10,7 @@ module OyenCov
10
10
  end
11
11
 
12
12
  config.after_initialize do
13
- # puts "lib/oyencov/railtie.rb config.after_initialize"
13
+ !!ENV["OYENCOV_DEBUG"] && puts("lib/oyencov/railtie.rb config.after_initialize")
14
14
  ActiveSupport::Notifications.subscribe("start_processing.action_controller") do |name, start, finish, id, payload|
15
15
  # puts(payload)
16
16
  ControllerTracking.bump("#{payload[:controller]}##{payload[:action]}")
@@ -18,6 +18,7 @@ module OyenCov
18
18
 
19
19
  if OyenCov.config.mode == "test"
20
20
  at_exit do
21
+ !!ENV["OYENCOV_DEBUG"] && puts("[OyenCov] Testing mode, persisting rails controller action data.")
21
22
  OyenCov::TestReporting.persist_controller_actions!
22
23
  end
23
24
  end
@@ -1,5 +1,5 @@
1
- require_relative "./method_range_parser"
2
- require_relative "./test_report_merger"
1
+ require_relative "method_range_parser"
2
+ require_relative "test_report_merger"
3
3
 
4
4
  # This is meant to be run at the end of the fan-out jobs, and the output
5
5
  # artefacts are meant to be persisted for the next job in the workflow.
@@ -0,0 +1,3 @@
1
+ module OyenCov
2
+ VERSION = "0.0.3".freeze
3
+ end
data/lib/oyencov.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  require_relative "oyencov/configuration"
2
2
  require_relative "oyencov/simplecov_resultset_translator"
3
+ require_relative "oyencov/version"
3
4
 
4
5
  # For now, support only Rails. We bootstrap from Railtie.
5
6
  module OyenCov
6
- VERSION = "0.0.1.pre"
7
-
8
7
  def self.config
9
8
  @config ||= OyenCov::Configuration.new
10
9
  end
11
10
 
12
- if defined?(Rails::Railtie) && ENV["OYENONSEN_API_KEY"]
11
+ !!ENV["OYENCOV_DEBUG"] && puts("[OyenCov] Checking Rails existence")
12
+ if defined?(Rails::Railtie) # && ENV["OYENCOV_API_KEY"]
13
+ puts "[OyenCov] Starting Railtie"
13
14
  require_relative "oyencov/railtie"
14
15
  end
15
16
  end
data.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �`�
metadata CHANGED
@@ -1,14 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oyencov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anonoz Chong
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2023-08-13 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ8wDQYDVQQDDAZhbm9u
14
+ b3oxFzAVBgoJkiaJk/IsZAEZFgdveWVuY292MRMwEQYKCZImiZPyLGQBGRYDY29t
15
+ MB4XDTIzMTExMDA3NDExNloXDTI0MTEwOTA3NDExNlowPzEPMA0GA1UEAwwGYW5v
16
+ bm96MRcwFQYKCZImiZPyLGQBGRYHb3llbmNvdjETMBEGCgmSJomT8ixkARkWA2Nv
17
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAY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SbULbcx7eELQ60JsY/Ep77JjMRh0MGfDYfUUbMKnhBCkniK5/Lq74wn
34
+ 08NdtmBccXON5C0Z39uERex72tqqW11W4tfX1k2K1k5Lli0HRBlXMQ1hWMHpx8nj
35
+ K18ySnv/ePkrL7AJhCgkP4tlJvrBvWnt30OuFfFf4K64ja+Hgqren8UabRQGIzn+
36
+ JcaIEQ0pXyjnNFwGBhHBjPXKHvRYuw/LNUPXBmP/k1a0WY6H
37
+ -----END CERTIFICATE-----
38
+ date: 2023-12-05 00:00:00.000000000 Z
12
39
  dependencies:
13
40
  - !ruby/object:Gem::Dependency
14
41
  name: rake
@@ -134,10 +161,12 @@ files:
134
161
  - lib/oyencov/simplecov_resultset_translator.rb
135
162
  - lib/oyencov/test_report_merger.rb
136
163
  - lib/oyencov/test_reporting.rb
164
+ - lib/oyencov/version.rb
137
165
  homepage: https://www.oyencov.com
138
166
  licenses:
139
167
  - MIT
140
- metadata: {}
168
+ metadata:
169
+ source_code_uri: https://github.com/oyencov/sdk-ruby
141
170
  post_install_message:
142
171
  rdoc_options: []
143
172
  require_paths:
@@ -149,12 +178,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
178
  version: 3.1.0
150
179
  required_rubygems_version: !ruby/object:Gem::Requirement
151
180
  requirements:
152
- - - ">"
181
+ - - ">="
153
182
  - !ruby/object:Gem::Version
154
- version: 1.3.1
183
+ version: '0'
155
184
  requirements: []
156
185
  rubygems_version: 3.3.7
157
186
  signing_key:
158
187
  specification_version: 4
159
- summary: Client-side telemetry
188
+ summary: Usage-weighted test coverage for Rails
160
189
  test_files: []
metadata.gz.sig ADDED
Binary file