datadog-ci 0.8.0 → 0.8.2

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: ae9b964bc83f82487cc72d99641bcd08a575c104ec311327d49715d88852d02d
4
- data.tar.gz: 7f787507a51166a49e95c9b55049fc68f3b1d0952fa49d7974f857b37b10e56f
3
+ metadata.gz: e852419d3e1634964bbe3e707ccd71822976fa868d8c8f6323c365c6af7fdb4b
4
+ data.tar.gz: 4e2e801de46ebd2590fd38ff694e4f7d911ec4364e776be498959d6b19faf4f8
5
5
  SHA512:
6
- metadata.gz: 5947c6dd42ab0d629d1e7eecd2f116ea2c28e89b657e47e80eb0b127caf21e25b68e182ba5f3039671491f9335b0dda917091cbd43f18f64c9136e3e38ef1239
7
- data.tar.gz: 7790297ed83c4bfedc4cfb9c2b9116a540c8f7c3cdc78ccd9b5ece5ecb506be427765851834f8abca4594ff5908ca99c4e7f4cd8ab601fe5c0228cf2c62f8971
6
+ metadata.gz: ac8d1b295053fa3323173ea7c1bca27cacdd364757ae59652eb33a216caf978d7a142833239d6fc69da2c68e1ad06853f4f9aadd268c2e8586d64e866e457cc6
7
+ data.tar.gz: ab09537b0971146e592499f2cf2ab57eb0e84f9116838d322c3708e57b6c3c38c3a875c2aa247c367c95e14c17df2a388aa4b113cedca6a732f4fe6fa8160803
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.8.2] - 2024-03-19
4
+
5
+ ### Fixed
6
+
7
+ * assign the single running test suite for a test if none found by test suite name ([#139][])
8
+
9
+ ## [0.8.1] - 2024-03-12
10
+
11
+ ### Fixed
12
+
13
+ * fix minitest instrumentation with mixins ([#134][])
14
+
3
15
  ## [0.8.0] - 2024-03-08
4
16
 
5
17
  ### Added
@@ -164,7 +176,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
164
176
 
165
177
  * Ruby versions < 2.7 no longer supported ([#8][])
166
178
 
167
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.0...main
179
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.2...main
180
+ [0.8.2]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.1...v0.8.2
181
+ [0.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.0...v0.8.1
168
182
  [0.8.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.7.0...v0.8.0
169
183
  [0.7.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.6.0...v0.7.0
170
184
  [0.6.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.1...v0.6.0
@@ -231,3 +245,5 @@ Currently test suite level visibility is not used by our instrumentation: it wil
231
245
  [#122]: https://github.com/DataDog/datadog-ci-rb/issues/122
232
246
  [#123]: https://github.com/DataDog/datadog-ci-rb/issues/123
233
247
  [#131]: https://github.com/DataDog/datadog-ci-rb/issues/131
248
+ [#134]: https://github.com/DataDog/datadog-ci-rb/issues/134
249
+ [#139]: https://github.com/DataDog/datadog-ci-rb/issues/139
@@ -6,7 +6,12 @@ module Datadog
6
6
  module Minitest
7
7
  module Helpers
8
8
  def self.test_suite_name(klass, method_name)
9
- source_location, = klass.instance_method(method_name).source_location
9
+ source_location = extract_source_location_from_class(klass)
10
+ # if we are in anonymous class, fallback to the method source location
11
+ if source_location.nil?
12
+ source_location, = klass.instance_method(method_name).source_location
13
+ end
14
+
10
15
  source_file_path = Pathname.new(source_location.to_s).relative_path_from(Pathname.pwd).to_s
11
16
 
12
17
  "#{klass.name} at #{source_file_path}"
@@ -16,6 +21,15 @@ module Datadog
16
21
  klass.ancestors.include?(::Minitest::Parallel::Test) ||
17
22
  (defined?(::Minitest::Queue) && ::Minitest.singleton_class.ancestors.include?(::Minitest::Queue))
18
23
  end
24
+
25
+ def self.extract_source_location_from_class(klass)
26
+ return nil if klass.nil? || klass.name.nil?
27
+
28
+ source_location = klass.const_source_location(klass.name)
29
+ source_location.first unless source_location.nil?
30
+ rescue
31
+ nil
32
+ end
19
33
  end
20
34
  end
21
35
  end
@@ -21,6 +21,14 @@ module Datadog
21
21
  end
22
22
  end
23
23
 
24
+ def fetch_single_test_suite
25
+ @mutex.synchronize do
26
+ return nil if @test_suites.empty? || @test_suites.size > 1
27
+
28
+ @test_suites.values.first
29
+ end
30
+ end
31
+
24
32
  def fetch_or_activate_test_module(&block)
25
33
  @mutex.synchronize do
26
34
  @test_module ||= block.call
@@ -227,6 +227,11 @@ module Datadog
227
227
  def build_test(tracer_span, tags)
228
228
  test = Test.new(tracer_span)
229
229
  set_initial_tags(test, tags)
230
+
231
+ # sometimes test suite is not being assigned correctly
232
+ # fix it by fetching the one single running test suite from the global context
233
+ fix_test_suite!(test) if test.test_suite_id.nil?
234
+
230
235
  validate_test_suite_level_visibility_correctness(test)
231
236
  set_codeowners(test)
232
237
 
@@ -294,6 +299,24 @@ module Datadog
294
299
  end
295
300
  end
296
301
 
302
+ def fix_test_suite!(test)
303
+ test_suite = @global_context.fetch_single_test_suite
304
+ unless test_suite
305
+ Datadog.logger.debug do
306
+ "Trying to fix test suite for test [#{test.name}] but no single test suite is running."
307
+ end
308
+ return
309
+ end
310
+
311
+ Datadog.logger.debug do
312
+ "For test [#{test.name}]: expected test suite [#{test.test_suite_name}] to be running, " \
313
+ "but it was not found. Fixing it by assigning test suite [#{test_suite.name}] to the test."
314
+ end
315
+
316
+ test.set_tag(Ext::Test::TAG_TEST_SUITE_ID, test_suite.id.to_s)
317
+ test.set_tag(Ext::Test::TAG_SUITE, test_suite.name)
318
+ end
319
+
297
320
  def start_datadog_tracer_span(span_name, span_options, &block)
298
321
  if block
299
322
  Datadog::Tracing.trace(span_name, **span_options) do |tracer_span, trace|
@@ -5,7 +5,7 @@ module Datadog
5
5
  module VERSION
6
6
  MAJOR = "0"
7
7
  MINOR = "8"
8
- PATCH = "0"
8
+ PATCH = "2"
9
9
  PRE = nil
10
10
  BUILD = nil
11
11
  # PRE and BUILD above are modified for dev gems during gem build GHA workflow
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-08 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: 2.0.0
159
159
  requirements: []
160
- rubygems_version: 3.5.3
160
+ rubygems_version: 3.5.6
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Datadog CI visibility for your ruby application