rspec-buildkite-analytics 0.3.2 → 0.3.6

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: 37d48ebe43bb1567f3ef7d837fd5148b7e8d712409e5f44aa2721dffa930063e
4
- data.tar.gz: 531c7bc7bce5cc4a3961e1aa8670f130c0e000a4a8ceda9eaba8cb9bfd0a88c8
3
+ metadata.gz: a81e9b877577590dbb59202d72db1ee309a25be50c69e45361a0515cbfed1e5a
4
+ data.tar.gz: 172a76b3343c2f460013c47b3893f7667aa3e965effde4b370fcf058ee0e3dbf
5
5
  SHA512:
6
- metadata.gz: ee10200839cdfa840fa4e6c980cda83593cecf91c0419f454f3d3e32047374888f03fc782b1caf0bfeded18421f2e4b989a648fb4a262748df484d647629b61d
7
- data.tar.gz: f5ed0798c9b89911cd81eab64ba600921b286693a01067676c8de86e14d01927340bcbef4635b3fb9882803710592491f6fd8075757a744f82fae73be7059d7d
6
+ metadata.gz: 471c20607b1dd61c55bfb1244ca8a5d95c3f30b4f3a26fbd9bf1912d11af3d3e7841762b077472dbc5b0fe3dc647771008a6e68cb5a4f85296a1f41b765ae4f2
7
+ data.tar.gz: 16145862ef9c26a3132eead4ea6bf11323effe8b6f5bc32140cce966544d508d8a4d83a64e809814d35c71add64102d8e23f7175f02d9f914839381efddc85b8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-buildkite-analytics (0.3.2)
4
+ rspec-buildkite-analytics (0.3.6)
5
5
  activesupport (>= 5.2, <= 7.0)
6
6
  rspec-core (~> 3.10)
7
7
  rspec-expectations (~> 3.10)
@@ -38,7 +38,7 @@ GEM
38
38
  tzinfo (2.0.4)
39
39
  concurrent-ruby (~> 1.0)
40
40
  websocket (1.2.9)
41
- zeitwerk (2.4.2)
41
+ zeitwerk (2.5.1)
42
42
 
43
43
  PLATFORMS
44
44
  ruby
@@ -49,4 +49,4 @@ DEPENDENCIES
49
49
  rspec-buildkite-analytics!
50
50
 
51
51
  BUNDLED WITH
52
- 2.2.20
52
+ 2.2.22
data/README.md CHANGED
@@ -15,10 +15,7 @@ end
15
15
 
16
16
  Configure your API key:
17
17
  ```ruby
18
- RSpec::Buildkite::Analytics.configure do |config|
19
- config.suite_key = "........"
20
- # other config
21
- end
18
+ RSpec::Buildkite::Analytics.configure(token: "........")
22
19
  ```
23
20
 
24
21
  Run bundler to install the gem and update your `Gemfile.lock`:
@@ -4,15 +4,22 @@ require "securerandom"
4
4
 
5
5
  module RSpec::Buildkite::Analytics::CI
6
6
  def self.env
7
- env = {
8
- "CI" => ENV["BUILDKITE"] ? "buildkite" : nil,
9
- "key" => ENV["BUILDKITE_BUILD_ID"] || SecureRandom.uuid,
10
- "url" => ENV["BUILDKITE_BUILD_URL"],
11
- "branch" => ENV["BUILDKITE_BRANCH"],
12
- "commit_sha" => ENV["BUILDKITE_COMMIT"],
13
- "number" => ENV["BUILDKITE_BUILD_NUMBER"],
14
- "job_id" => ENV["BUILDKITE_JOB_ID"],
15
- "message" => ENV["BUILDKITE_MESSAGE"]
16
- }
7
+ if ENV["BUILDKITE_BUILD_ID"]
8
+ {
9
+ "CI" => "buildkite",
10
+ "key" => ENV["BUILDKITE_BUILD_ID"],
11
+ "url" => ENV["BUILDKITE_BUILD_URL"],
12
+ "branch" => ENV["BUILDKITE_BRANCH"],
13
+ "commit_sha" => ENV["BUILDKITE_COMMIT"],
14
+ "number" => ENV["BUILDKITE_BUILD_NUMBER"],
15
+ "job_id" => ENV["BUILDKITE_JOB_ID"],
16
+ "message" => ENV["BUILDKITE_MESSAGE"]
17
+ }
18
+ else
19
+ {
20
+ "CI" => nil,
21
+ "key" => SecureRandom.uuid
22
+ }
23
+ end
17
24
  end
18
25
  end
@@ -2,6 +2,8 @@ module RSpec::Buildkite::Analytics
2
2
  class Reporter
3
3
  RSpec::Core::Formatters.register self, :example_passed, :example_failed, :example_pending
4
4
 
5
+ attr_reader :output
6
+
5
7
  def initialize(output)
6
8
  @output = output
7
9
  end
@@ -10,6 +10,7 @@ module RSpec::Buildkite::Analytics
10
10
  WAIT_BETWEEN_RECONNECTIONS = 5
11
11
 
12
12
  class RejectedSubscription < StandardError; end
13
+ class InitialConnectionFailure < StandardError; end
13
14
 
14
15
  def initialize(url, authorization_header, channel)
15
16
  @queue = Queue.new
@@ -25,8 +26,8 @@ module RSpec::Buildkite::Analytics
25
26
  @authorization_header = authorization_header
26
27
 
27
28
  connect
28
- rescue TimeoutError => e
29
- $stderr.puts "rspec-buildkite-analytics could not establish an initial connection with Buildkite. Please contact support."
29
+ rescue TimeoutError, InitialConnectionFailure => e
30
+ $stderr.puts "rspec-buildkite-analytics could not establish an initial connection with Buildkite due to #{e.message}. You may be missing some data for this test suite, please contact support."
30
31
  end
31
32
 
32
33
  def disconnected(connection)
@@ -138,25 +139,25 @@ module RSpec::Buildkite::Analytics
138
139
  wait_for_confirm
139
140
  end
140
141
 
141
- def pop_with_timeout
142
- Timeout.timeout(30, RSpec::Buildkite::Analytics::TimeoutError, "Waited 30 seconds") do
142
+ def pop_with_timeout(message_type)
143
+ Timeout.timeout(30, RSpec::Buildkite::Analytics::TimeoutError, "Timeout: Waited 30 seconds for #{message_type}") do
143
144
  @queue.pop
144
145
  end
145
146
  end
146
147
 
147
148
  def wait_for_welcome
148
- welcome = pop_with_timeout
149
+ welcome = pop_with_timeout("welcome")
149
150
 
150
151
  if welcome && welcome != { "type" => "welcome" }
151
- raise "Not a welcome: #{welcome.inspect}"
152
+ raise InitialConnectionFailure.new("Wrong message received, expected a welcome, but received: #{welcome.inspect}")
152
153
  end
153
154
  end
154
155
 
155
156
  def wait_for_confirm
156
- confirm = pop_with_timeout
157
+ confirm = pop_with_timeout("confirm")
157
158
 
158
159
  if confirm && confirm != { "type" => "confirm_subscription", "identifier" => @channel }
159
- raise "Not a confirm: #{confirm.inspect}"
160
+ raise InitialConnectionFailure.new("Wrong message received, expected a confirm, but received: #{confirm.inspect}")
160
161
  end
161
162
  end
162
163
 
@@ -75,13 +75,23 @@ module RSpec::Buildkite::Analytics
75
75
  @session.handle(self, data.data)
76
76
  end
77
77
  end
78
- rescue EOFError
78
+ rescue EOFError, Errno::ECONNRESET
79
79
  if @socket
80
80
  @session.disconnected(self)
81
81
  disconnect
82
82
  end
83
83
  rescue IOError
84
84
  # This is fine to ignore
85
+ rescue IndexError
86
+ # I don't like that we're doing this but I think it's the best of the options
87
+ #
88
+ # This relates to this issue https://github.com/ruby/openssl/issues/452
89
+ # A fix for it has been released but the repercussions of overriding
90
+ # the OpenSSL version in the stdlib seem worse than catching this error here.
91
+ if @socket
92
+ @session.disconnected(self)
93
+ disconnect
94
+ end
85
95
  end
86
96
  end
87
97
 
@@ -92,10 +102,20 @@ module RSpec::Buildkite::Analytics
92
102
  raw_data = data.to_json
93
103
  frame = WebSocket::Frame::Outgoing::Client.new(data: raw_data, type: :text, version: @version)
94
104
  @socket.write(frame.to_s)
95
- rescue Errno::EPIPE, OpenSSL::SSL::SSLError => e
105
+ rescue Errno::EPIPE, Errno::ECONNRESET, OpenSSL::SSL::SSLError => e
96
106
  return unless @socket
97
107
  @session.disconnected(self)
98
108
  disconnect
109
+ rescue IndexError
110
+ # I don't like that we're doing this but I think it's the best of the options
111
+ #
112
+ # This relates to this issue https://github.com/ruby/openssl/issues/452
113
+ # A fix for it has been released but the repercussions of overriding
114
+ # the OpenSSL version in the stdlib seem worse than catching this error here.
115
+ if @socket
116
+ @session.disconnected(self)
117
+ disconnect
118
+ end
99
119
  end
100
120
 
101
121
  def close
@@ -65,7 +65,7 @@ module RSpec::Buildkite::Analytics
65
65
  private
66
66
 
67
67
  def generate_file_name(example)
68
- file_path_regex = /^(.*?\.rb)/
68
+ file_path_regex = /^(.*?\.(rb|feature))/
69
69
  identifier_file_name = example.id[file_path_regex]
70
70
  location_file_name = example.location[file_path_regex]
71
71
 
@@ -127,12 +127,12 @@ module RSpec::Buildkite::Analytics
127
127
  response = begin
128
128
  http.request(contact)
129
129
  rescue *REQUEST_EXCEPTIONS => e
130
- puts "Error communicating with the server: #{e.message}"
130
+ puts "Buildkite Test Analytics: Error communicating with the server: #{e.message}"
131
131
  end
132
132
 
133
133
  case response.code
134
134
  when "401"
135
- puts "Invalid Suite API key. Please double check your Suite API key."
135
+ puts "Buildkite Test Analytics: Invalid Suite API key. Please double check your Suite API key."
136
136
  when "200"
137
137
  json = JSON.parse(response.body)
138
138
 
@@ -141,10 +141,10 @@ module RSpec::Buildkite::Analytics
141
141
  end
142
142
  else
143
143
  request_id = response.to_hash["x-request-id"]
144
- puts "Unknown error. If this error persists, please contact support+analytics@buildkite.com with this request ID `#{request_id}`."
144
+ puts "Buildkite Test Analytics: Unknown error. If this error persists, please contact support+analytics@buildkite.com with this request ID `#{request_id}`."
145
145
  end
146
146
  else
147
- puts "No Suite API key provided. You can get the API key from your Suite settings page."
147
+ puts "Buildkite Test Analytics: No Suite API key provided. You can get the API key from your Suite settings page."
148
148
  end
149
149
  end
150
150
 
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Buildkite
5
5
  module Analytics
6
- VERSION = "0.3.2"
6
+ VERSION = "0.3.6"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-buildkite-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-06 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.2.3
124
+ rubygems_version: 3.1.4
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Track execution of specs and report to Buildkite Analytics