datadog-ci 1.9.0 → 1.11.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: 7641cbd9b01a787badb9bab7d3aa74933c99b750b46609c9a625ed3f7daaa11c
4
- data.tar.gz: 5489c728c4b6c91ff68b515796533801b02dfb623f506da23849e60e343063a3
3
+ metadata.gz: da95176899cf1e2427fadba7e177e85a5906c8c8131026e4b6e7fd3ec7ffae91
4
+ data.tar.gz: 1e948e2a734e658b9cbff55c9e1d0a57164d422a921124d17e73879a8da96361
5
5
  SHA512:
6
- metadata.gz: 3d2f41e5eb8f58c3eecb72200658add1799109c7778fad032c6d58ec2fd462a37df7e1a47edfb6cf7390e037c4e30ada85dc95c71983c30629de38b2bf62fd35
7
- data.tar.gz: 408151cc04150bcc8ec2a0933c0f6d38cd1362b5842e8b145960ba276431681893988cfd0c49ce47f519ae9e7451549b45503a6ea79f123cfd4cc3750cb2a8ea
6
+ metadata.gz: 4bbc47cd1af4024c4822f3c3686f728d50a87b729c8316b3e80648e370fc3c274bcd551644aad0a17203927d2ca08957af400447000ee25485a6f17f1cbaec62
7
+ data.tar.gz: f8b0fb90d93076341c88a44d4e08f867318996b350c10a498101d5893de32b70811110b78c093a8ba13b88ea6d53ba011013995fd0a11e5ba61b035d84950063
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.11.0] - 2025-01-02
4
+
5
+ ### Changed
6
+
7
+ * bump maximum Ruby version to 3.4 ([#275][])
8
+ * Use logical test session name as part of test session span's resource instead of test command ([#271][])
9
+
10
+ ### Fixed
11
+
12
+ * set the max payload size for events to 4.5MB ([#272][])
13
+ * Fix inline comments handling when parsing CODEOWNERS files ([#267][])
14
+
15
+ ## [1.10.0] - 2024-12-05
16
+
17
+ ### Added
18
+
19
+ * Skip before(:all) context hooks when all examples are skipped ([#262][])
20
+
3
21
  ## [1.9.0] - 2024-11-26
4
22
 
5
23
  ### Added
@@ -362,7 +380,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
362
380
 
363
381
  - Ruby versions < 2.7 no longer supported ([#8][])
364
382
 
365
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.9.0...main
383
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.11.0...main
384
+ [1.11.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.10.0...v1.11.0
385
+ [1.10.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.9.0...v1.10.0
366
386
  [1.9.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.1...v1.9.0
367
387
  [1.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.0...v1.8.1
368
388
  [1.8.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.7.0...v1.8.0
@@ -521,4 +541,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
521
541
  [#244]: https://github.com/DataDog/datadog-ci-rb/issues/244
522
542
  [#248]: https://github.com/DataDog/datadog-ci-rb/issues/248
523
543
  [#250]: https://github.com/DataDog/datadog-ci-rb/issues/250
524
- [#259]: https://github.com/DataDog/datadog-ci-rb/issues/259
544
+ [#259]: https://github.com/DataDog/datadog-ci-rb/issues/259
545
+ [#262]: https://github.com/DataDog/datadog-ci-rb/issues/262
546
+ [#267]: https://github.com/DataDog/datadog-ci-rb/issues/267
547
+ [#271]: https://github.com/DataDog/datadog-ci-rb/issues/271
548
+ [#272]: https://github.com/DataDog/datadog-ci-rb/issues/272
549
+ [#275]: https://github.com/DataDog/datadog-ci-rb/issues/275
@@ -42,7 +42,7 @@ module Datadog
42
42
 
43
43
  File.open(codeowners_file_path, "r") do |f|
44
44
  f.each_line do |line|
45
- line.strip!
45
+ line.strip!&.sub!(/#.*$/, "")
46
46
 
47
47
  next if line.empty?
48
48
  next if comment?(line)
@@ -21,42 +21,25 @@ module Datadog
21
21
  return super if ::RSpec.configuration.dry_run? && !datadog_configuration[:dry_run_enabled]
22
22
  return super unless datadog_configuration[:enabled]
23
23
 
24
- test_name = full_description.strip
25
- if metadata[:description].empty?
26
- # for unnamed it blocks this appends something like "example at ./spec/some_spec.rb:10"
27
- test_name << " #{description}"
28
- end
29
-
30
- test_suite_description = fetch_top_level_example_group[:description]
31
- suite_name = "#{test_suite_description} at #{metadata[:example_group][:rerun_file_path]}"
32
-
33
- # remove example group description from test name to avoid duplication
34
- test_name = test_name.sub(test_suite_description, "").strip
35
-
36
- if ci_queue?
37
- suite_name = "#{suite_name} (ci-queue running example [#{test_name}])"
38
- ci_queue_test_span = test_visibility_component.start_test_suite(suite_name)
39
- end
24
+ test_suite_span = test_visibility_component.start_test_suite(datadog_test_suite_name) if ci_queue?
40
25
 
41
26
  # don't report test to RSpec::Core::Reporter until retries are done
42
27
  @skip_reporting = true
43
28
 
44
29
  test_retries_component.with_retries do
45
30
  test_visibility_component.trace_test(
46
- test_name,
47
- suite_name,
31
+ datadog_test_name,
32
+ datadog_test_suite_name,
48
33
  tags: {
49
34
  CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
50
35
  CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_integration.version.to_s,
51
36
  CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(metadata[:file_path]),
52
37
  CI::Ext::Test::TAG_SOURCE_START => metadata[:line_number].to_s,
53
- CI::Ext::Test::TAG_PARAMETERS => Utils::TestRun.test_parameters(
54
- metadata: {"scoped_id" => metadata[:scoped_id]}
55
- )
38
+ CI::Ext::Test::TAG_PARAMETERS => datadog_test_parameters
56
39
  },
57
40
  service: datadog_configuration[:service_name]
58
41
  ) do |test_span|
59
- test_span&.itr_unskippable! if metadata[CI::Ext::Test::ITR_UNSKIPPABLE_OPTION]
42
+ test_span&.itr_unskippable! if datadog_unskippable?
60
43
 
61
44
  metadata[:skip] = CI::Ext::Test::ITR_TEST_SKIP_REASON if test_span&.skipped_by_itr?
62
45
 
@@ -87,8 +70,8 @@ module Datadog
87
70
  end
88
71
  end
89
72
 
90
- # this is a special case for ci-queue, we need to finish the test suite span
91
- ci_queue_test_span&.finish
73
+ # this is a special case for ci-queue, we need to finish the test suite span created for a single test
74
+ test_suite_span&.finish
92
75
 
93
76
  # after retries are done, we can finally report the test to RSpec
94
77
  @skip_reporting = false
@@ -106,6 +89,18 @@ module Datadog
106
89
  super(::RSpec::Core::NullReporter)
107
90
  end
108
91
 
92
+ def datadog_test_id
93
+ @datadog_test_id ||= Utils::TestRun.datadog_test_id(
94
+ datadog_test_name,
95
+ datadog_test_suite_name,
96
+ datadog_test_parameters
97
+ )
98
+ end
99
+
100
+ def datadog_unskippable?
101
+ !!metadata[CI::Ext::Test::ITR_UNSKIPPABLE_OPTION]
102
+ end
103
+
109
104
  private
110
105
 
111
106
  def fetch_top_level_example_group
@@ -129,6 +124,45 @@ module Datadog
129
124
  Datadog.configuration.ci[:rspec]
130
125
  end
131
126
 
127
+ def datadog_test_suite_description
128
+ @datadog_test_suite_description ||= fetch_top_level_example_group[:description]
129
+ end
130
+
131
+ def datadog_test_name
132
+ return @datadog_test_name if defined?(@datadog_test_name)
133
+
134
+ test_name = full_description.strip
135
+ if metadata[:description].empty?
136
+ # for unnamed it blocks this appends something like "example at ./spec/some_spec.rb:10"
137
+ test_name << " #{description}"
138
+ end
139
+
140
+ # remove example group description from test name to avoid duplication
141
+ test_name = test_name.sub(datadog_test_suite_description, "").strip
142
+
143
+ @datadog_test_name = test_name
144
+ end
145
+
146
+ def datadog_test_suite_name
147
+ return @datadog_test_suite_name if defined?(@datadog_test_suite_name)
148
+
149
+ suite_name = "#{datadog_test_suite_description} at #{metadata[:example_group][:rerun_file_path]}"
150
+
151
+ if ci_queue?
152
+ suite_name = "#{suite_name} (ci-queue running example [#{datadog_test_name}])"
153
+ end
154
+
155
+ @datadog_test_suite_name = suite_name
156
+ end
157
+
158
+ def datadog_test_parameters
159
+ return @datadog_test_parameters if defined?(@datadog_test_parameters)
160
+
161
+ @datadog_test_parameters = Utils::TestRun.test_parameters(
162
+ metadata: {"scoped_id" => metadata[:scoped_id]}
163
+ )
164
+ end
165
+
132
166
  def test_visibility_component
133
167
  Datadog.send(:components).test_visibility
134
168
  end
@@ -18,10 +18,17 @@ module Datadog
18
18
  def run(reporter = ::RSpec::Core::NullReporter)
19
19
  return super if ::RSpec.configuration.dry_run? && !datadog_configuration[:dry_run_enabled]
20
20
  return super unless datadog_configuration[:enabled]
21
+
22
+ # skip the context hooks if all descendant example are going to be skipped
23
+ # IMPORTANT: must happen before top_level? check because skipping hooks must happen
24
+ # even if it is a nested context
25
+ metadata[:skip] = true if all_examples_skipped_by_datadog?
26
+
27
+ # return early because we create Datadog::CI::TestSuite only for top-level example groups
21
28
  return super unless top_level?
22
29
 
23
30
  suite_name = "#{description} at #{file_path}"
24
- test_suite = test_visibility_component.start_test_suite(
31
+ test_suite = test_visibility_component&.start_test_suite(
25
32
  suite_name,
26
33
  tags: {
27
34
  CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(metadata[:file_path]),
@@ -47,6 +54,12 @@ module Datadog
47
54
 
48
55
  private
49
56
 
57
+ def all_examples_skipped_by_datadog?
58
+ descendant_filtered_examples.all? do |example|
59
+ !example.datadog_unskippable? && test_optimisation_component&.skippable?(example)
60
+ end
61
+ end
62
+
50
63
  def datadog_configuration
51
64
  Datadog.configuration.ci[:rspec]
52
65
  end
@@ -54,6 +67,10 @@ module Datadog
54
67
  def test_visibility_component
55
68
  Datadog.send(:components).test_visibility
56
69
  end
70
+
71
+ def test_optimisation_component
72
+ Datadog.send(:components).test_optimisation
73
+ end
57
74
  end
58
75
  end
59
76
  end
@@ -69,6 +69,7 @@ module Datadog
69
69
  TAG_BROWSER_DRIVER = "browser_driver"
70
70
  TAG_IS_RUM = "is_rum"
71
71
  TAG_IS_RETRY = "is_retry"
72
+ TAG_EARLY_FLAKE_DETECTION_ABORT_REASON = "early_flake_detection_abort_reason"
72
73
  TAG_IS_NEW = "is_new"
73
74
  TAG_LIBRARY = "library"
74
75
  TAG_ENDPOINT = "endpoint"
@@ -78,12 +79,18 @@ module Datadog
78
79
  TAG_REQUEST_COMPRESSED = "rq_compressed"
79
80
  TAG_RESPONSE_COMPRESSED = "rs_compressed"
80
81
  TAG_COMMAND = "command"
82
+ # tags for git_requests.settings_response metric
81
83
  TAG_COVERAGE_ENABLED = "coverage_enabled"
84
+ TAG_ITR_ENABLED = "itr_enabled"
82
85
  TAG_ITR_SKIP_ENABLED = "itrskip_enabled"
86
+ TAG_REQUIRE_GIT = "require_git"
83
87
  TAG_EARLY_FLAKE_DETECTION_ENABLED = "early_flake_detection_enabled"
84
- TAG_EARLY_FLAKE_DETECTION_ABORT_REASON = "early_flake_detection_abort_reason"
88
+ TAG_FLAKY_TEST_RETRIES_ENABLED = "flaky_test_retries_enabled"
89
+ # tags for test_session metric
85
90
  TAG_PROVIDER = "provider"
86
91
  TAG_AUTO_INJECTED = "auto_injected"
92
+ TAG_AGENTLESS_LOG_SUBMISSION_ENABLED = "agentless_log_submission_enabled"
93
+ TAG_FAIL_FAST_TEST_ORDER_ENABLED = "fail_fast_test_order_enabled"
87
94
 
88
95
  module EventType
89
96
  TEST = "test"
@@ -74,6 +74,9 @@ module Datadog
74
74
  # common tags that are serialized directly in msgpack header in metadata field
75
75
  METADATA_TAG_TEST_SESSION_NAME = "test_session.name"
76
76
 
77
+ # internal tag indicating if datadog service was configured by the user
78
+ TAG_USER_PROVIDED_TEST_SERVICE = "_dd.test.is_user_provided_service"
79
+
77
80
  # internal metric with the number of virtual CPUs
78
81
  METRIC_CPU_COUNT = "_dd.host.vcpu_count"
79
82
 
@@ -59,7 +59,10 @@ module Datadog
59
59
  {
60
60
  Ext::Telemetry::TAG_COVERAGE_ENABLED => library_settings.code_coverage_enabled?.to_s,
61
61
  Ext::Telemetry::TAG_ITR_SKIP_ENABLED => library_settings.tests_skipping_enabled?.to_s,
62
- Ext::Telemetry::TAG_EARLY_FLAKE_DETECTION_ENABLED => library_settings.early_flake_detection_enabled?.to_s
62
+ Ext::Telemetry::TAG_EARLY_FLAKE_DETECTION_ENABLED => library_settings.early_flake_detection_enabled?.to_s,
63
+ Ext::Telemetry::TAG_FLAKY_TEST_RETRIES_ENABLED => library_settings.flaky_test_retries_enabled?.to_s,
64
+ Ext::Telemetry::TAG_ITR_ENABLED => library_settings.itr_enabled?.to_s,
65
+ Ext::Telemetry::TAG_REQUIRE_GIT => library_settings.require_git?.to_s
63
66
  }
64
67
  )
65
68
 
@@ -17,6 +17,11 @@ module Datadog
17
17
  get_tag(Ext::Test::TAG_NAME)
18
18
  end
19
19
 
20
+ # @return [String] the test id according to Datadog's test impact analysis.
21
+ def datadog_test_id
22
+ @datadog_test_id ||= Utils::TestRun.datadog_test_id(name, test_suite_name, parameters)
23
+ end
24
+
20
25
  # Finishes the current test.
21
26
  # @return [void]
22
27
  def finish
@@ -140,22 +145,18 @@ module Datadog
140
145
 
141
146
  # @internal
142
147
  def any_retry_passed?
143
- !!test_suite&.any_test_retry_passed?(test_id)
148
+ !!test_suite&.any_test_retry_passed?(datadog_test_id)
144
149
  end
145
150
 
146
151
  private
147
152
 
148
- def test_id
149
- @test_id ||= Utils::TestRun.datadog_test_id(name, test_suite_name, parameters)
150
- end
151
-
152
153
  def record_test_result(datadog_status)
153
154
  # if this test was already executed in this test suite, mark it as retried
154
- if test_suite&.test_executed?(test_id)
155
+ if test_suite&.test_executed?(datadog_test_id)
155
156
  set_tag(Ext::Test::TAG_IS_RETRY, "true")
156
157
  end
157
158
 
158
- test_suite&.record_test_result(test_id, datadog_status)
159
+ test_suite&.record_test_result(datadog_test_id, datadog_status)
159
160
  end
160
161
  end
161
162
  end
@@ -144,11 +144,16 @@ module Datadog
144
144
  event
145
145
  end
146
146
 
147
+ def skippable?(test)
148
+ return false if !enabled? || !skipping_tests?
149
+
150
+ @skippable_tests.include?(test.datadog_test_id)
151
+ end
152
+
147
153
  def mark_if_skippable(test)
148
154
  return if !enabled? || !skipping_tests?
149
155
 
150
- datadog_test_id = Utils::TestRun.datadog_test_id(test.name, test.test_suite_name, test.parameters)
151
- if @skippable_tests.include?(datadog_test_id)
156
+ if skippable?(test)
152
157
  if forked?
153
158
  Datadog.logger.warn { "Intelligent test runner is not supported for forking test runners yet" }
154
159
  return
@@ -156,9 +161,9 @@ module Datadog
156
161
 
157
162
  test.set_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")
158
163
 
159
- Datadog.logger.debug { "Marked test as skippable: #{datadog_test_id}" }
164
+ Datadog.logger.debug { "Marked test as skippable: #{test.datadog_test_id}" }
160
165
  else
161
- Datadog.logger.debug { "Test is not skippable: #{datadog_test_id}" }
166
+ Datadog.logger.debug { "Test is not skippable: #{test.datadog_test_id}" }
162
167
  end
163
168
  end
164
169
 
@@ -66,7 +66,7 @@ module Datadog
66
66
  cli_options_array = @rspec_cli_options + ["--dry-run", @spec_path]
67
67
 
68
68
  rspec_config_options = ::RSpec::Core::ConfigurationOptions.new(cli_options_array)
69
- devnull = File.new("/dev/null", "w")
69
+ devnull = File.new(File::NULL, "w")
70
70
  out = @verbose ? $stdout : devnull
71
71
  err = @verbose ? $stderr : devnull
72
72
 
@@ -25,7 +25,7 @@ module Datadog
25
25
  # Return the test session's name which is equal to test command used
26
26
  # @return [String] the command for this test session.
27
27
  def name
28
- get_tag(Ext::Test::TAG_COMMAND)
28
+ test_visibility.logical_test_session_name || "test_session"
29
29
  end
30
30
 
31
31
  # Return the test session's command used to run the tests
@@ -11,6 +11,7 @@ require_relative "../ext/app_types"
11
11
  require_relative "../ext/environment"
12
12
  require_relative "../ext/test"
13
13
 
14
+ require_relative "../utils/configuration"
14
15
  require_relative "../utils/test_run"
15
16
 
16
17
  require_relative "../span"
@@ -207,6 +208,10 @@ module Datadog
207
208
  ci_span.set_tags(@environment_tags)
208
209
 
209
210
  ci_span.set_metric(Ext::Test::METRIC_CPU_COUNT, Utils::TestRun.virtual_cpu_count)
211
+ ci_span.set_tag(
212
+ Ext::Test::TAG_USER_PROVIDED_TEST_SERVICE,
213
+ Utils::Configuration.service_name_provided_by_user?.to_s
214
+ )
210
215
  end
211
216
 
212
217
  # PROPAGATING CONTEXT FROM TOP-LEVEL TO THE LOWER LEVELS
@@ -238,6 +238,10 @@ module Datadog
238
238
  def to_integer(value)
239
239
  value&.to_i
240
240
  end
241
+
242
+ def test_visibility
243
+ @test_visibility ||= Datadog::CI.send(:test_visibility)
244
+ end
241
245
  end
242
246
  end
243
247
  end
@@ -31,7 +31,7 @@ module Datadog
31
31
  end
32
32
 
33
33
  def resource
34
- "#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session.#{@span.get_tag(Ext::Test::TAG_COMMAND)}"
34
+ "#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session.#{test_visibility.logical_test_session_name}"
35
35
  end
36
36
 
37
37
  private
@@ -11,7 +11,7 @@ module Datadog
11
11
  module CI
12
12
  module Transport
13
13
  class EventPlatformTransport
14
- DEFAULT_MAX_PAYLOAD_SIZE = 5 * 1024 * 1024
14
+ DEFAULT_MAX_PAYLOAD_SIZE = 4.5 * 1024 * 1024
15
15
 
16
16
  attr_reader :api,
17
17
  :max_payload_size
@@ -9,6 +9,10 @@ module Datadog
9
9
  def self.fetch_service_name(default)
10
10
  Datadog.configuration.service_without_fallback || CI::Git::LocalRepository.repository_name || default
11
11
  end
12
+
13
+ def self.service_name_provided_by_user?
14
+ !!Datadog.configuration.service_without_fallback
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -4,7 +4,7 @@ module Datadog
4
4
  module CI
5
5
  module VERSION
6
6
  MAJOR = 1
7
- MINOR = 9
7
+ MINOR = 11
8
8
  PATCH = 0
9
9
  PRE = nil
10
10
  BUILD = nil
@@ -22,7 +22,7 @@ module Datadog
22
22
  # To allow testing with the next unreleased version of Ruby, the version check is performed
23
23
  # as `< #{MAXIMUM_RUBY_VERSION}`, meaning prereleases of MAXIMUM_RUBY_VERSION are allowed
24
24
  # but not stable MAXIMUM_RUBY_VERSION releases.
25
- MAXIMUM_RUBY_VERSION = "3.4"
25
+ MAXIMUM_RUBY_VERSION = "3.5"
26
26
  end
27
27
  end
28
28
  end
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: 1.9.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-26 00:00:00.000000000 Z
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: datadog
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  version: 2.7.0
241
241
  - - "<"
242
242
  - !ruby/object:Gem::Version
243
- version: '3.4'
243
+ version: '3.5'
244
244
  required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
246
  - - ">="