buildkite-test_collector 2.8.0 → 2.9.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: a06be6db9195629f49724e87ac755466db10f8e8ae5289ca7f3a1803a335ff66
4
- data.tar.gz: 8b0110c802047ac6f169156f8f07e0808a2d23e8cc3f47156a5208a92167e0a4
3
+ metadata.gz: 468ad8ce641432cc7a1112d1f80396a4f54e9d63a566aa7f240d485969855686
4
+ data.tar.gz: 8348dc3fac0a7e57b0543da3870fbc89cdef8b0e1662c439eaea8c7d2a685210
5
5
  SHA512:
6
- metadata.gz: caad67348cde90de584225d0c64e1c1cc3ab50aa222879679ab1399063ea2e9ff97ce3c19f3c85725560d288a034d0ee25e1d0e5e6eb79bcf89d9ee0e51e9f38
7
- data.tar.gz: 550c9d2ba8120b5fc2464f47094223f28c5103a836123179fb43f8b6399ce45490a20c67454921a7f192cda575e6b19c3296654af28a9a3b7fc2a90cbcf03fe0
6
+ metadata.gz: 70baa9565cb411b56888f1e72048d554e87dc6d8ee76c7dd1cc3d67e943801f9133e27d883a5d7da74677b61d73c2c8258385a02aa4c997f98471d3d1157af06
7
+ data.tar.gz: c8a34a8fd8c6554c59a66812d41cc747cc5ffae27b4f651c4ca58c6cb44c81ec9f747eeb82ac061897e11c555053404be500414055c0881adafb33272ba1c511
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.9.0
4
+
5
+ * `Buildkite::TestCollector.tag_execution(key, value)` by @pda in https://github.com/buildkite/test-collector-ruby/pull/240
6
+
7
+ **Full Changelog**: https://github.com/buildkite/test-collector-ruby/compare/v2.8.0...v2.9.0
8
+
3
9
  ## v2.8.0
4
10
 
5
11
  * Buildkite::TestCollector.tags: specify tags for all executions by @pda in https://github.com/buildkite/test-collector-ruby/pull/235
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.8.0)
4
+ buildkite-test_collector (2.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -18,21 +18,27 @@ RSpec.configure do |config|
18
18
  min_duration: Buildkite::TestCollector.trace_min_duration,
19
19
  )
20
20
 
21
- # The _buildkite prefix here is added as a safeguard against name collisions
22
- # as we are in the main thread
21
+ tags = {}
22
+
23
+ # _buildkite prefix reduces chance of collisions in this almost-global (per-fiber) namespace.
23
24
  Thread.current[:_buildkite_tracer] = tracer
24
- # It's important to use begin/ensure here, because otherwise if other hooks fail,
25
- # the cleanup code won't run, meaning we will miss some data.
26
- #
27
- # Having said that, this behavior isn't documented by RSpec.
25
+ Thread.current[:_buildkite_tags] = tags
26
+
27
+ # example.run can raise errors (including from other middleware/hooks) so clean up in `ensure`.
28
28
  begin
29
29
  example.run
30
30
  ensure
31
31
  Thread.current[:_buildkite_tracer] = nil
32
+ Thread.current[:_buildkite_tags] = nil
32
33
 
33
34
  tracer.finalize
34
35
 
35
- trace = Buildkite::TestCollector::RSpecPlugin::Trace.new(example, history: tracer.history)
36
+ trace = Buildkite::TestCollector::RSpecPlugin::Trace.new(
37
+ example,
38
+ history: tracer.history,
39
+ tags: tags,
40
+ )
41
+
36
42
  Buildkite::TestCollector.uploader.traces[example.id] = trace
37
43
  end
38
44
  end
@@ -5,6 +5,7 @@ module Buildkite::TestCollector::MinitestPlugin
5
5
  attr_accessor :example
6
6
  attr_writer :failure_reason, :failure_expanded
7
7
  attr_reader :history
8
+ attr_reader :tags
8
9
 
9
10
  RESULT_CODES = {
10
11
  '.' => 'passed',
@@ -15,9 +16,10 @@ module Buildkite::TestCollector::MinitestPlugin
15
16
 
16
17
  FILE_PATH_REGEX = /^(.*?\.(rb|feature))/
17
18
 
18
- def initialize(example, history:)
19
+ def initialize(example, history:, tags: nil)
19
20
  @example = example
20
21
  @history = history
22
+ @tags = tags
21
23
  end
22
24
 
23
25
  def result
@@ -38,6 +40,7 @@ module Buildkite::TestCollector::MinitestPlugin
38
40
  failure_reason: failure_reason,
39
41
  failure_expanded: failure_expanded,
40
42
  history: history,
43
+ tags: tags,
41
44
  ).select { |_, value| !value.nil? }
42
45
  end
43
46
 
@@ -14,18 +14,29 @@ module Buildkite::TestCollector::MinitestPlugin
14
14
  min_duration: Buildkite::TestCollector.trace_min_duration,
15
15
  )
16
16
 
17
- # The _buildkite prefix here is added as a safeguard against name collisions
18
- # as we are in the main thread
17
+ tags = {}
18
+
19
+ # _buildkite prefix reduces chance of collisions in this almost-global (per-fiber) namespace.
19
20
  Thread.current[:_buildkite_tracer] = tracer
21
+ Thread.current[:_buildkite_tags] = tags
20
22
  end
21
23
 
22
24
  def after_teardown
23
25
  tracer = Thread.current[:_buildkite_tracer]
26
+ tags = Thread.current[:_buildkite_tags]
27
+
28
+ Thread.current[:_buildkite_tracer] = nil
29
+ Thread.current[:_buildkite_tags] = nil
30
+
24
31
  if !tracer.nil?
25
- Thread.current[:_buildkite_tracer] = nil
26
32
  tracer.finalize
27
33
 
28
- trace = Buildkite::TestCollector::MinitestPlugin::Trace.new(self, history: tracer.history)
34
+ trace = Buildkite::TestCollector::MinitestPlugin::Trace.new(
35
+ self,
36
+ history: tracer.history,
37
+ tags: tags,
38
+ )
39
+
29
40
  Buildkite::TestCollector.uploader.traces[trace.source_location] = trace
30
41
  end
31
42
 
@@ -4,14 +4,16 @@ module Buildkite::TestCollector::RSpecPlugin
4
4
  class Trace
5
5
  attr_accessor :example, :failure_reason, :failure_expanded
6
6
  attr_reader :history
7
+ attr_reader :tags
7
8
 
8
9
  FILE_PATH_REGEX = /^(.*?\.(rb|feature))/
9
10
 
10
- def initialize(example, history:, failure_reason: nil, failure_expanded: [])
11
+ def initialize(example, history:, failure_reason: nil, failure_expanded: [], tags: nil)
11
12
  @example = example
12
13
  @history = history
13
14
  @failure_reason = failure_reason
14
15
  @failure_expanded = failure_expanded
16
+ @tags = tags
15
17
  end
16
18
 
17
19
  def result
@@ -32,6 +34,7 @@ module Buildkite::TestCollector::RSpecPlugin
32
34
  failure_reason: failure_reason,
33
35
  failure_expanded: failure_expanded,
34
36
  history: history,
37
+ tags: tags,
35
38
  ).select { |_, value| !value.nil? }
36
39
  end
37
40
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Buildkite
4
4
  module TestCollector
5
- VERSION = "2.8.0"
5
+ VERSION = "2.9.0"
6
6
  NAME = "buildkite-test_collector"
7
7
  end
8
8
  end
@@ -77,6 +77,18 @@ module Buildkite
77
77
  tracer&.leave
78
78
  end
79
79
 
80
+ # Set a key=value tag on the current test execution.
81
+ def self.tag_execution(key, value)
82
+ tags = Thread.current[:_buildkite_tags]
83
+ raise "_buildkite_tags not available" unless tags
84
+
85
+ unless key.is_a?(String) && value.is_a?(String)
86
+ raise ArgumentError, "tag key and value expected string"
87
+ end
88
+
89
+ tags[key] = value
90
+ end
91
+
80
92
  def self.enable_tracing!
81
93
  return unless self.tracing_enabled
82
94
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildkite-test_collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buildkite
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-04 00:00:00.000000000 Z
10
+ date: 2025-02-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport