buildkite-test_collector 2.3.2 ā†’ 2.4.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: d1d5188350d19431be80e4d9680a9a561d4ae25f64549d5be488607d1882a5c1
4
+ data.tar.gz: aece9ddaddba6792fcf2fa91f8642e5be3712bf118f154f6e152f0cbad5aa9eb
5
5
  SHA512:
6
- metadata.gz: feaa2ec084069d17991bf5fda126b6b6d01fee4a807e4295bd644a02ccf30a02e9f1c0e912e2441347aee48f36bdae7eaa46ea4fe86075ac60e0b88424199aee
7
- data.tar.gz: 7c31eafe74aa8cba48e74537940968c0b322b8939b33fa1cee2fdfb05600aa5ef9fc6192fb3b3c972bf4286edc3180cd375240eac2b6be8be08a4466bbed5567
6
+ metadata.gz: 6eb7578e7cad14c2088b6bb522eb3548cccd6de33dd09952fc4d4fd8638a707f9abaa8b68060fefd3eab212ab7a23d114cba0f4155e9394b13277b1b67719652
7
+ data.tar.gz: 6d1f20581f34336eb39e22a753661d5cd9b9feaf05a7773ca6d3171ec50ef335a61ec6697f9baeab4526810e0ed400981fae1738a78637179fbadae452a1995d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.4.0
4
+
5
+ - Feature release: Output links to Test Analytic tests within the rspec log @meghan-kradolfer
6
+
3
7
  ## v2.3.2
4
8
 
5
9
  - Add support for Codeship #198 - @swebb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.3.2)
4
+ buildkite-test_collector (2.4.0)
5
5
  activesupport (>= 4.2)
6
6
 
7
7
  GEM
@@ -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|
@@ -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 unless notification.failed_examples.present?
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Buildkite
4
4
  module TestCollector
5
- VERSION = "2.3.2"
5
+ VERSION = "2.4.0"
6
6
  NAME = "buildkite-test_collector"
7
7
  end
8
8
  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.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -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
@@ -114,7 +115,7 @@ 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
+ rubygems_version: 3.3.22
118
119
  signing_key:
119
120
  specification_version: 4
120
121
  summary: Track test executions and report to Buildkite Test Analytics