buildkite-test_collector 2.3.1 → 2.4.0

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: '09f0da65683acfa44ac43a124494f3c9d5d8e3067abf0b28a3aa979a6413489d'
4
- data.tar.gz: e7791580735083001493204451c79eae2e58ad5d51250f9c6535ca26bd8b169f
3
+ metadata.gz: d1d5188350d19431be80e4d9680a9a561d4ae25f64549d5be488607d1882a5c1
4
+ data.tar.gz: aece9ddaddba6792fcf2fa91f8642e5be3712bf118f154f6e152f0cbad5aa9eb
5
5
  SHA512:
6
- metadata.gz: 3937ba2cfed151fb5c62af03b0a4925d6a4f36be0a95432c39a6f6e5974198e6e9c44fa5f7138086415ffac7b4907f082f067ee33b9bac7cb32a2ccfad50647d
7
- data.tar.gz: bd956bc8de0375dcc657a7ed5f9a4256f0ba7b81de62dbc61ecb80ec2392eb6e9c57b298122f649659d16010189809a19dc4eb1f62e3c04626eb24917d53090c
6
+ metadata.gz: 6eb7578e7cad14c2088b6bb522eb3548cccd6de33dd09952fc4d4fd8638a707f9abaa8b68060fefd3eab212ab7a23d114cba0f4155e9394b13277b1b67719652
7
+ data.tar.gz: 6d1f20581f34336eb39e22a753661d5cd9b9feaf05a7773ca6d3171ec50ef335a61ec6697f9baeab4526810e0ed400981fae1738a78637179fbadae452a1995d
data/CHANGELOG.md CHANGED
@@ -1,20 +1,35 @@
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
+
7
+ ## v2.3.2
8
+
9
+ - Add support for Codeship #198 - @swebb
10
+ - Restore compatibility with older Ruby versions #201 - @gchan
11
+ - Report Ruby version to Test Analytics #203 - @gchan
12
+
3
13
  ## v2.3.1
14
+
4
15
  - Log standard error raised during upload #195 - @nprizal
5
16
 
6
17
  ## v2.3.0
18
+
7
19
  - Stop sending execution id and safeguard SecureRandom.uuid #192 - @niceking
8
20
  - Rescue from StandardError when sending upload request #191 - @niceking
9
21
  - Fix nil pointer #188 - @ChrisBr
10
22
 
11
23
  ## v2.2.0
24
+
12
25
  - Gzip payload of request to Upload API #183 - @niceking
13
26
 
14
27
  ## v2.1.0
28
+
15
29
  - Major change: deprecates websocket connection in favour of sending HTTP requests to the Upload API. In future, websocket support will be completely removed from Buildkite and only version 2.1+ of this gem will continue to work.
16
30
 
17
31
  ## v2.1.0.pre
32
+
18
33
  - Minitest plugin to use HTTP Upload API instead of websocket connection to send test data #178 #179 - @niceking
19
34
 
20
35
  ## v2.0.0.pre
@@ -32,6 +47,7 @@
32
47
  - Update collector argument in the Analytics::API payload #170 - @KatieWright26
33
48
 
34
49
  ## v1.4.1
50
+
35
51
  - Add in support to create file with trace data #167
36
52
 
37
53
  ## v1.3.1
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.3.1)
4
+ buildkite-test_collector (2.4.0)
5
5
  activesupport (>= 4.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4.3)
10
+ activesupport (7.0.7.2)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  concurrent-ruby (1.2.2)
16
16
  diff-lcs (1.4.4)
17
- i18n (1.13.0)
17
+ i18n (1.14.1)
18
18
  concurrent-ruby (~> 1.0)
19
- minitest (5.18.0)
19
+ minitest (5.19.0)
20
20
  rake (13.0.6)
21
21
  rspec (3.10.0)
22
22
  rspec-core (~> 3.10.0)
data/README.md CHANGED
@@ -7,7 +7,7 @@ Official [Buildkite Test Analytics](https://buildkite.com/test-analytics) collec
7
7
 
8
8
  āš’ **Supported test frameworks:** RSpec, Minitest, and [more coming soon](https://github.com/buildkite/test-collector-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+frameworks%22).
9
9
 
10
- šŸ“¦ **Supported CI systems:** Buildkite, GitHub Actions, CircleCI, and others via the `BUILDKITE_ANALYTICS_*` environment variables.
10
+ šŸ“¦ **Supported CI systems:** Buildkite, GitHub Actions, CircleCI, Codeship, and others via the `BUILDKITE_ANALYTICS_*` environment variables.
11
11
 
12
12
  ## šŸ‘‰ Installing
13
13
 
data/buildkite.yaml CHANGED
@@ -1,8 +1,41 @@
1
1
  steps:
2
- - label: ":rspec: Tests"
2
+ - label: ":rspec: Tests :ruby: 3.3-rc"
3
3
  command:
4
4
  - "bundle"
5
5
  - "bundle exec rake"
6
6
  plugins:
7
7
  - docker#v3.7.0:
8
- image: 445615400570.dkr.ecr.us-east-1.amazonaws.com/ecr-public/docker/library/ruby:3.1.4
8
+ image: "445615400570.dkr.ecr.us-east-1.amazonaws.com/ecr-public/docker/library/ruby:3.3-rc"
9
+ soft_fail: true
10
+
11
+ - label: ":rspec: Tests :ruby: {{matrix}}"
12
+ command:
13
+ - "bundle"
14
+ - "bundle exec rake"
15
+ plugins:
16
+ - docker#v3.7.0:
17
+ image: "445615400570.dkr.ecr.us-east-1.amazonaws.com/ecr-public/docker/library/ruby:{{matrix}}"
18
+ matrix:
19
+ - "latest"
20
+ - "3.2"
21
+ - "3.1"
22
+ - "3.0"
23
+ - "2.7"
24
+
25
+ - group: ":rspec: Legacy Ruby :ruby:"
26
+ steps:
27
+ - label: ":rspec: Tests :ruby: {{matrix}}"
28
+ command:
29
+ - "gem install bundler:2.3.25"
30
+ - "bundle"
31
+ - "bundle exec rake"
32
+ plugins:
33
+ - docker#v3.7.0:
34
+ # Images for older Ruby versions aren't available on AWS ECR
35
+ # so fall back to Docker Hub
36
+ image: "ruby:{{matrix}}"
37
+ matrix:
38
+ - "2.6"
39
+ - "2.5"
40
+ - "2.4"
41
+ - "2.3"
@@ -17,6 +17,7 @@ class Buildkite::TestCollector::CI
17
17
  return buildkite if ENV["BUILDKITE_BUILD_ID"]
18
18
  return github_actions if ENV["GITHUB_RUN_NUMBER"]
19
19
  return circleci if ENV["CIRCLE_BUILD_NUM"]
20
+ return codeship if ENV["CI_NAME"] == "codeship"
20
21
  return generic if ENV["CI"]
21
22
 
22
23
  {
@@ -36,9 +37,10 @@ class Buildkite::TestCollector::CI
36
37
  "message" => ENV["BUILDKITE_ANALYTICS_MESSAGE"],
37
38
  "execution_name_prefix" => ENV["BUILDKITE_ANALYTICS_EXECUTION_NAME_PREFIX"],
38
39
  "execution_name_suffix" => ENV["BUILDKITE_ANALYTICS_EXECUTION_NAME_SUFFIX"],
40
+ "language_version" => RUBY_VERSION,
39
41
  "version" => Buildkite::TestCollector::VERSION,
40
42
  "collector" => "ruby-#{Buildkite::TestCollector::NAME}",
41
- }.compact
43
+ }.select { |_, value| !value.nil? }
42
44
  end
43
45
 
44
46
  def generic
@@ -82,4 +84,16 @@ class Buildkite::TestCollector::CI
82
84
  "number" => ENV["CIRCLE_BUILD_NUM"],
83
85
  }
84
86
  end
87
+
88
+ def codeship
89
+ {
90
+ "CI" => "codeship",
91
+ "key" => "#{ENV["CI_BUILD_ID"]}",
92
+ "url" => ENV["CI_PULL_REQUEST"],
93
+ "branch" => ENV["CI_BRANCH"],
94
+ "commit_sha" => ENV["CI_COMMIT_ID"],
95
+ "number" => nil,
96
+ "message" => ENV["CI_COMMIT_MESSAGE"],
97
+ }
98
+ end
85
99
  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.compact
41
+ ).with_indifferent_access.select { |_, value| !value.nil? }
42
42
  end
43
43
 
44
44
  private
@@ -50,7 +50,7 @@ module Buildkite::TestCollector::MinitestPlugin
50
50
  end
51
51
 
52
52
  def file_name
53
- @file_name ||= File.join('./', source_location[0].delete_prefix(project_dir))
53
+ @file_name ||= File.join('./', source_location[0].sub(/\A#{project_dir}/, ""))
54
54
  end
55
55
 
56
56
  def line_number
@@ -74,7 +74,7 @@ module Buildkite::TestCollector::MinitestPlugin
74
74
  # remove the first line of message from the first failure
75
75
  # to avoid duplicate line in Test Analytics UI
76
76
  messages = strip_invalid_utf8_chars(failure.message).split("\n")
77
- messages = messages[1..] if index.zero?
77
+ messages = messages[1..-1] if index.zero?
78
78
 
79
79
  {
80
80
  expanded: messages,
@@ -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.compact
35
+ ).with_indifferent_access.select { |_, value| !value.nil? }
36
36
  end
37
37
 
38
38
  private
@@ -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.1"
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.1
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-06-02 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