buildkite-test_collector 2.3.2 ā†’ 2.5.0

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: 0b48c795c760f5a77634bc30024c344925036c3b4f935848caf6dcaf861b1692
4
- data.tar.gz: 263e4faa13017fa5f8e1465dc76f245e05b3f26f703e933c87cb547b17e5dfbd
3
+ metadata.gz: '096d9a186b77909ac11460179d43bb4e57fd76ebea603f0d35d105264ae65793'
4
+ data.tar.gz: cc16f83917301ec0e20640545a985a800064777e549f434dfb56f9152efd2482
5
5
  SHA512:
6
- metadata.gz: feaa2ec084069d17991bf5fda126b6b6d01fee4a807e4295bd644a02ccf30a02e9f1c0e912e2441347aee48f36bdae7eaa46ea4fe86075ac60e0b88424199aee
7
- data.tar.gz: 7c31eafe74aa8cba48e74537940968c0b322b8939b33fa1cee2fdfb05600aa5ef9fc6192fb3b3c972bf4286edc3180cd375240eac2b6be8be08a4466bbed5567
6
+ metadata.gz: 58375f6b3c26113dc18d5af87b785a891b70045c657621450baaa959120ae36923732cb8992942148c0cfe2eaf199ae9e5e675e7199000f8e39aa6ed4717ab3e
7
+ data.tar.gz: b4bd0aa37da33506ae7bfe297497230a9d87e36aea074ad3e456d32aa2f13eaf76000dc4070fd6ab6ae6dfae00faeb39680c0945b1ffc1c1d9344d93cd82de1a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.5.0
4
+
5
+ - Remove ActiveSupport as a primary dependancy #212 - @pat
6
+
7
+ ## v2.4.0
8
+
9
+ - Feature release: Output links to Test Analytic tests within the rspec log #209 - @meghan-kradolfer
10
+
3
11
  ## v2.3.2
4
12
 
5
13
  - Add support for Codeship #198 - @swebb
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.3.2)
5
- activesupport (>= 4.2)
4
+ buildkite-test_collector (2.5.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
@@ -38,6 +37,7 @@ PLATFORMS
38
37
  ruby
39
38
 
40
39
  DEPENDENCIES
40
+ activesupport (>= 4.2)
41
41
  buildkite-test_collector!
42
42
  rake (~> 13.0)
43
43
  rspec (~> 3.0)
@@ -24,8 +24,7 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
26
26
 
27
- spec.add_dependency "activesupport", ">= 4.2"
28
-
27
+ spec.add_development_dependency "activesupport", ">= 4.2"
29
28
  spec.add_development_dependency "rspec-core", '~> 3.10'
30
29
  spec.add_development_dependency "rspec-expectations", '~> 3.10'
31
30
  end
@@ -41,6 +41,20 @@ module Buildkite::TestCollector
41
41
  http.request(contact)
42
42
  end
43
43
 
44
+ def metadata
45
+ contact_uri = URI.parse("#{url}/metadata")
46
+
47
+ http = Net::HTTP.new(contact_uri.host, contact_uri.port)
48
+ http.use_ssl = contact_uri.scheme == "https"
49
+
50
+ contact = Net::HTTP::Get.new(contact_uri.path, {
51
+ "Authorization" => authorization_header,
52
+ "Content-Type" => "application/json"
53
+ })
54
+
55
+ http.request(contact)
56
+ end
57
+
44
58
  private
45
59
 
46
60
  attr :url
@@ -5,12 +5,14 @@ require "rspec/expectations"
5
5
 
6
6
  require_relative "../rspec_plugin/reporter"
7
7
  require_relative "../rspec_plugin/trace"
8
+ require_relative "../test_links_plugin/formatter"
8
9
 
9
10
  Buildkite::TestCollector.uploader = Buildkite::TestCollector::Uploader
10
11
 
11
12
  RSpec.configure do |config|
12
13
  config.before(:suite) do
13
14
  config.add_formatter Buildkite::TestCollector::RSpecPlugin::Reporter
15
+ config.add_formatter Buildkite::TestCollector::TestLinksPlugin::Formatter
14
16
  end
15
17
 
16
18
  config.around(:each) do |example|
@@ -38,7 +38,7 @@ module Buildkite::TestCollector::MinitestPlugin
38
38
  failure_reason: failure_reason,
39
39
  failure_expanded: failure_expanded,
40
40
  history: history,
41
- ).with_indifferent_access.select { |_, value| !value.nil? }
41
+ ).select { |_, value| !value.nil? }
42
42
  end
43
43
 
44
44
  private
@@ -40,6 +40,10 @@ module Buildkite::TestCollector::RSpecPlugin
40
40
  RSpec::Core::MultipleExceptionError
41
41
  ]
42
42
 
43
+ def blank?(string)
44
+ string.nil? || string.strip.empty?
45
+ end
46
+
43
47
  def failure_info(notification)
44
48
  failure_expanded = []
45
49
 
@@ -73,9 +77,9 @@ module Buildkite::TestCollector::RSpecPlugin
73
77
  def format_message_lines(message_lines)
74
78
  message_lines.map! { |l| strip_diff_colors(l) }
75
79
  # the first line is sometimes blank, depending on the error reported
76
- message_lines.shift if message_lines.first.blank?
80
+ message_lines.shift if blank?(message_lines.first)
77
81
  # the last line is sometimes blank, depending on the error reported
78
- message_lines.pop if message_lines.last.blank?
82
+ message_lines.pop if blank?(message_lines.last)
79
83
  message_lines
80
84
  end
81
85
 
@@ -32,7 +32,7 @@ module Buildkite::TestCollector::RSpecPlugin
32
32
  failure_reason: failure_reason,
33
33
  failure_expanded: failure_expanded,
34
34
  history: history,
35
- ).with_indifferent_access.select { |_, value| !value.nil? }
35
+ ).select { |_, value| !value.nil? }
36
36
  end
37
37
 
38
38
  private
@@ -60,7 +60,7 @@ module Buildkite::TestCollector::RSpecPlugin
60
60
  end
61
61
 
62
62
  def shared_example?
63
- example.metadata[:shared_group_inclusion_backtrace].any?
63
+ !example.metadata[:shared_group_inclusion_backtrace].empty?
64
64
  end
65
65
 
66
66
  def shared_example_call_location
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Buildkite::TestCollector::TestLinksPlugin
4
+ class Formatter
5
+ RSpec::Core::Formatters.register self, :dump_failures
6
+
7
+ def initialize(output)
8
+ @output = output
9
+ end
10
+
11
+ def dump_failures(notification)
12
+ # Do not display summary if no failed examples
13
+ return if notification.failed_examples.empty?
14
+
15
+ # Check if a Test Analytics token is set
16
+ return unless Buildkite::TestCollector.api_token
17
+
18
+ metadata = fetch_metadata
19
+
20
+ # return if metadata was not fetched successfully
21
+ return if metadata.nil?
22
+
23
+ # return if suite url is nil
24
+ return if metadata['suite_url'].nil?
25
+
26
+ @output << "\n\nšŸ”„ \x1b[31mTest Analytics failures šŸ”„\n"
27
+ @output << '_____________________________'
28
+ @output << "\n\n"
29
+
30
+ @output << notification.failed_examples.map do |example|
31
+ failed_example_output(example, metadata['suite_url'])
32
+ end.join("\n")
33
+
34
+ @output << "\n\n"
35
+ end
36
+
37
+ private
38
+
39
+ def generate_scope_name_digest(scope, name)
40
+ Digest::SHA256.hexdigest(scope + name)
41
+ end
42
+
43
+ def failed_example_output(example, url)
44
+ scope = example.example_group.metadata[:full_description]
45
+ name = example.description
46
+ scope_name_digest = generate_scope_name_digest(scope, name)
47
+ test_url = "#{url}/tests/#{scope_name_digest}"
48
+ "šŸ”— \x1b[4m\x1b[37m#{%(\x1b]1339;url=#{test_url};content="#{scope} #{name}"\x07)}\x1b[m"
49
+ end
50
+
51
+ def fetch_metadata
52
+ return unless Buildkite::TestCollector.api_token
53
+
54
+ http = Buildkite::TestCollector::HTTPClient.new(Buildkite::TestCollector.url)
55
+ response = http.metadata
56
+
57
+ JSON.parse(response.body) if response.code == '200'
58
+ rescue StandardError => e
59
+ # We don't need to output anything here
60
+ end
61
+ end
62
+ end
@@ -43,7 +43,7 @@ module Buildkite::TestCollector
43
43
  duration: end_at - start_at,
44
44
  detail: detail,
45
45
  children: children.map(&:as_hash),
46
- }.with_indifferent_access
46
+ }
47
47
  end
48
48
  end
49
49
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Buildkite
4
4
  module TestCollector
5
- VERSION = "2.3.2"
5
+ VERSION = "2.5.0"
6
6
  NAME = "buildkite-test_collector"
7
7
  end
8
8
  end
@@ -8,14 +8,11 @@ end
8
8
  require "json"
9
9
  require "logger"
10
10
  require "net/http"
11
+ require "openssl"
11
12
  require "time"
12
13
  require "timeout"
13
14
  require "tmpdir"
14
15
 
15
- require "active_support/core_ext/object/blank"
16
- require "active_support/core_ext/hash/indifferent_access"
17
- require "active_support/notifications"
18
-
19
16
  require_relative "test_collector/version"
20
17
  require_relative "test_collector/error"
21
18
  require_relative "test_collector/ci"
@@ -72,6 +69,10 @@ module Buildkite
72
69
  Buildkite::TestCollector::Network.configure
73
70
  Buildkite::TestCollector::Object.configure
74
71
 
72
+ return unless defined?(ActiveSupport)
73
+
74
+ require "active_support/notifications"
75
+
75
76
  ActiveSupport::Notifications.subscribe("sql.active_record") do |name, start, finish, id, payload|
76
77
  Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
77
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-test_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,7 +17,7 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.2'
20
- type: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.10'
55
- description:
55
+ description:
56
56
  email:
57
57
  - support+analytics@buildkite.com
58
58
  executables: []
@@ -88,6 +88,7 @@ files:
88
88
  - lib/buildkite/test_collector/rspec_plugin/reporter.rb
89
89
  - lib/buildkite/test_collector/rspec_plugin/trace.rb
90
90
  - lib/buildkite/test_collector/session.rb
91
+ - lib/buildkite/test_collector/test_links_plugin/formatter.rb
91
92
  - lib/buildkite/test_collector/tracer.rb
92
93
  - lib/buildkite/test_collector/uploader.rb
93
94
  - lib/buildkite/test_collector/uuid.rb
@@ -99,7 +100,7 @@ licenses:
99
100
  metadata:
100
101
  homepage_uri: https://github.com/buildkite/test-collector-ruby
101
102
  source_code_uri: https://github.com/buildkite/test-collector-ruby
102
- post_install_message:
103
+ post_install_message:
103
104
  rdoc_options: []
104
105
  require_paths:
105
106
  - lib
@@ -114,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 3.3.26
118
- signing_key:
118
+ rubygems_version: 3.1.6
119
+ signing_key:
119
120
  specification_version: 4
120
121
  summary: Track test executions and report to Buildkite Test Analytics
121
122
  test_files: []