datadog-ci 1.13.0 → 1.15.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -2
  3. data/lib/datadog/ci/configuration/components.rb +2 -1
  4. data/lib/datadog/ci/configuration/settings.rb +6 -0
  5. data/lib/datadog/ci/contrib/minitest/helpers.rb +26 -0
  6. data/lib/datadog/ci/contrib/minitest/runnable.rb +1 -19
  7. data/lib/datadog/ci/contrib/minitest/runner.rb +12 -5
  8. data/lib/datadog/ci/contrib/minitest/test.rb +2 -9
  9. data/lib/datadog/ci/contrib/parallel_tests/cli.rb +84 -0
  10. data/lib/datadog/ci/contrib/parallel_tests/configuration/settings.rb +32 -0
  11. data/lib/datadog/ci/contrib/parallel_tests/ext.rb +16 -0
  12. data/lib/datadog/ci/contrib/parallel_tests/integration.rb +42 -0
  13. data/lib/datadog/ci/contrib/parallel_tests/patcher.rb +24 -0
  14. data/lib/datadog/ci/contrib/rspec/example.rb +7 -0
  15. data/lib/datadog/ci/contrib/rspec/example_group.rb +18 -8
  16. data/lib/datadog/ci/contrib/rspec/helpers.rb +18 -0
  17. data/lib/datadog/ci/contrib/rspec/runner.rb +3 -1
  18. data/lib/datadog/ci/ext/settings.rb +1 -0
  19. data/lib/datadog/ci/ext/test.rb +20 -0
  20. data/lib/datadog/ci/git/local_repository.rb +1 -1
  21. data/lib/datadog/ci/git/tree_uploader.rb +9 -0
  22. data/lib/datadog/ci/readonly_test_module.rb +28 -0
  23. data/lib/datadog/ci/readonly_test_session.rb +31 -0
  24. data/lib/datadog/ci/remote/component.rb +43 -16
  25. data/lib/datadog/ci/span.rb +4 -0
  26. data/lib/datadog/ci/test_management/component.rb +34 -1
  27. data/lib/datadog/ci/test_management/tests_properties.rb +2 -1
  28. data/lib/datadog/ci/test_optimisation/component.rb +38 -33
  29. data/lib/datadog/ci/test_optimisation/skippable_percentage/base.rb +4 -0
  30. data/lib/datadog/ci/test_optimisation/skippable_percentage/calculator.rb +3 -3
  31. data/lib/datadog/ci/test_retries/strategy/retry_new.rb +1 -1
  32. data/lib/datadog/ci/test_session.rb +7 -1
  33. data/lib/datadog/ci/test_suite.rb +18 -0
  34. data/lib/datadog/ci/test_visibility/component.rb +130 -30
  35. data/lib/datadog/ci/test_visibility/context.rb +102 -41
  36. data/lib/datadog/ci/test_visibility/null_component.rb +5 -1
  37. data/lib/datadog/ci/test_visibility/store/{local.rb → fiber_local.rb} +1 -1
  38. data/lib/datadog/ci/test_visibility/store/{global.rb → process.rb} +26 -14
  39. data/lib/datadog/ci/test_visibility/transport.rb +1 -2
  40. data/lib/datadog/ci/transport/http.rb +1 -1
  41. data/lib/datadog/ci/utils/file_storage.rb +57 -0
  42. data/lib/datadog/ci/utils/stateful.rb +52 -0
  43. data/lib/datadog/ci/version.rb +1 -1
  44. data/lib/datadog/ci.rb +5 -4
  45. metadata +28 -5
  46. data/lib/datadog/ci/test_visibility/capabilities.rb +0 -36
@@ -4,7 +4,6 @@ require "datadog/core/environment/identity"
4
4
  require "datadog/core/telemetry/logging"
5
5
  require "datadog/core/utils/only_once"
6
6
 
7
- require_relative "capabilities"
8
7
  require_relative "serializers/factories/test_level"
9
8
 
10
9
  require_relative "../ext/app_types"
@@ -117,7 +116,7 @@ module Datadog
117
116
  packer.write("library_version")
118
117
  packer.write(Datadog::CI::VERSION::STRING)
119
118
 
120
- library_capabilities_tags = Capabilities.tags
119
+ library_capabilities_tags = Ext::Test::LibraryCapabilities::CAPABILITY_VERSIONS
121
120
 
122
121
  Ext::AppTypes::CI_SPAN_TYPES.each do |ci_span_type|
123
122
  packer.write(ci_span_type)
@@ -29,7 +29,7 @@ module Datadog
29
29
  @host = host
30
30
  @port = port
31
31
  @timeout = timeout
32
- @ssl = ssl.nil? ? true : ssl
32
+ @ssl = ssl.nil? || ssl
33
33
  @compress = compress.nil? ? false : compress
34
34
  end
35
35
 
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "tempfile"
5
+
6
+ module Datadog
7
+ module CI
8
+ module Utils
9
+ # FileStorage module provides functionality for storing and retrieving arbitrary Ruby objects in a temp file
10
+ # to share them between processes.
11
+ module FileStorage
12
+ TEMP_DIR = File.join(Dir.tmpdir, "datadog-ci-storage")
13
+
14
+ def self.store(key, value)
15
+ ensure_temp_dir_exists
16
+ file_path = file_path_for(key)
17
+
18
+ File.binwrite(file_path, Marshal.dump(value))
19
+
20
+ true
21
+ rescue => e
22
+ Datadog.logger.error("Failed to store data for key '#{key}': #{e.class} - #{e.message}")
23
+ false
24
+ end
25
+
26
+ def self.retrieve(key)
27
+ file_path = file_path_for(key)
28
+ return nil unless File.exist?(file_path)
29
+
30
+ Marshal.load(File.binread(file_path))
31
+ rescue => e
32
+ Datadog.logger.error("Failed to retrieve data for key '#{key}': #{e.class} - #{e.message}")
33
+ nil
34
+ end
35
+
36
+ def self.cleanup
37
+ return false unless Dir.exist?(TEMP_DIR)
38
+
39
+ FileUtils.rm_rf(TEMP_DIR)
40
+ true
41
+ rescue => e
42
+ Datadog.logger.error("Failed to cleanup storage directory: #{e.class} - #{e.message}")
43
+ false
44
+ end
45
+
46
+ def self.ensure_temp_dir_exists
47
+ FileUtils.mkdir_p(TEMP_DIR) unless Dir.exist?(TEMP_DIR)
48
+ end
49
+
50
+ def self.file_path_for(key)
51
+ sanitized_key = key.to_s.gsub(/[^a-zA-Z0-9_-]/, "_")
52
+ File.join(TEMP_DIR, "dd-ci-#{sanitized_key}.dat")
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "file_storage"
4
+
5
+ module Datadog
6
+ module CI
7
+ module Utils
8
+ # Module for components that need to persist and restore state
9
+ module Stateful
10
+ # Store component state
11
+ def store_component_state
12
+ state = serialize_state
13
+
14
+ res = Utils::FileStorage.store(storage_key, state)
15
+ Datadog.logger.debug { "Stored component state (key=#{storage_key}): #{res}" }
16
+
17
+ res
18
+ end
19
+
20
+ # Load component state
21
+ def load_component_state
22
+ test_visibility_component = Datadog.send(:components).test_visibility
23
+ return false unless test_visibility_component.client_process?
24
+
25
+ state = Utils::FileStorage.retrieve(storage_key)
26
+ unless state
27
+ Datadog.logger.debug { "No component state found in file storage (key=#{storage_key})" }
28
+ return false
29
+ end
30
+
31
+ restore_state(state)
32
+ Datadog.logger.debug { "Loaded component state from file storage (key=#{storage_key})" }
33
+
34
+ true
35
+ end
36
+
37
+ # These methods must be implemented by including classes
38
+ def serialize_state
39
+ raise NotImplementedError, "Components must implement #serialize_state"
40
+ end
41
+
42
+ def restore_state(state)
43
+ raise NotImplementedError, "Components must implement #restore_state"
44
+ end
45
+
46
+ def storage_key
47
+ raise NotImplementedError, "Components must implement #storage_key"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -4,7 +4,7 @@ module Datadog
4
4
  module CI
5
5
  module VERSION
6
6
  MAJOR = 1
7
- MINOR = 13
7
+ MINOR = 15
8
8
  PATCH = 0
9
9
  PRE = nil
10
10
  BUILD = nil
data/lib/datadog/ci.rb CHANGED
@@ -49,7 +49,7 @@ module Datadog
49
49
  1,
50
50
  {Ext::Telemetry::TAG_EVENT_TYPE => Ext::Telemetry::EventType::SESSION}
51
51
  )
52
- test_visibility.start_test_session(service: service, tags: tags, total_tests_count: total_tests_count)
52
+ test_visibility.start_test_session(service: service, tags: tags, estimated_total_tests_count: total_tests_count)
53
53
  end
54
54
 
55
55
  # The active, unfinished test session.
@@ -415,16 +415,17 @@ end
415
415
 
416
416
  # Integrations
417
417
 
418
- # Test frameworks (manual instrumentation)
418
+ # Test frameworks
419
419
  require_relative "ci/contrib/cucumber/integration"
420
420
  require_relative "ci/contrib/minitest/integration"
421
421
  require_relative "ci/contrib/rspec/integration"
422
422
 
423
- # Test runners (instrumented automatically when corresponding frameworks are instrumented)
423
+ # Test runners
424
424
  require_relative "ci/contrib/knapsack/integration"
425
425
  require_relative "ci/contrib/ciqueue/integration"
426
+ require_relative "ci/contrib/parallel_tests/integration"
426
427
 
427
- # Additional test libraries (auto instrumented later on test session start)
428
+ # Additional test libraries (auto instrumented on test session start)
428
429
  require_relative "ci/contrib/selenium/integration"
429
430
  require_relative "ci/contrib/cuprite/integration"
430
431
  require_relative "ci/contrib/simplecov/integration"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-25 00:00:00.000000000 Z
10
+ date: 2025-03-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: datadog
@@ -37,6 +37,20 @@ dependencies:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: drb
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
40
54
  description: |2
41
55
  datadog-ci is a Datadog's Test Optimization library for Ruby. It traces
42
56
  tests as they are being executed and brings developers visibility into
@@ -103,11 +117,17 @@ files:
103
117
  - lib/datadog/ci/contrib/minitest/runnable.rb
104
118
  - lib/datadog/ci/contrib/minitest/runner.rb
105
119
  - lib/datadog/ci/contrib/minitest/test.rb
120
+ - lib/datadog/ci/contrib/parallel_tests/cli.rb
121
+ - lib/datadog/ci/contrib/parallel_tests/configuration/settings.rb
122
+ - lib/datadog/ci/contrib/parallel_tests/ext.rb
123
+ - lib/datadog/ci/contrib/parallel_tests/integration.rb
124
+ - lib/datadog/ci/contrib/parallel_tests/patcher.rb
106
125
  - lib/datadog/ci/contrib/patcher.rb
107
126
  - lib/datadog/ci/contrib/rspec/configuration/settings.rb
108
127
  - lib/datadog/ci/contrib/rspec/example.rb
109
128
  - lib/datadog/ci/contrib/rspec/example_group.rb
110
129
  - lib/datadog/ci/contrib/rspec/ext.rb
130
+ - lib/datadog/ci/contrib/rspec/helpers.rb
111
131
  - lib/datadog/ci/contrib/rspec/integration.rb
112
132
  - lib/datadog/ci/contrib/rspec/patcher.rb
113
133
  - lib/datadog/ci/contrib/rspec/runner.rb
@@ -158,6 +178,8 @@ files:
158
178
  - lib/datadog/ci/git/tree_uploader.rb
159
179
  - lib/datadog/ci/git/upload_packfile.rb
160
180
  - lib/datadog/ci/git/user.rb
181
+ - lib/datadog/ci/readonly_test_module.rb
182
+ - lib/datadog/ci/readonly_test_session.rb
161
183
  - lib/datadog/ci/remote/component.rb
162
184
  - lib/datadog/ci/remote/library_settings.rb
163
185
  - lib/datadog/ci/remote/library_settings_client.rb
@@ -192,7 +214,6 @@ files:
192
214
  - lib/datadog/ci/test_retries/strategy/retry_new.rb
193
215
  - lib/datadog/ci/test_session.rb
194
216
  - lib/datadog/ci/test_suite.rb
195
- - lib/datadog/ci/test_visibility/capabilities.rb
196
217
  - lib/datadog/ci/test_visibility/component.rb
197
218
  - lib/datadog/ci/test_visibility/context.rb
198
219
  - lib/datadog/ci/test_visibility/flush.rb
@@ -208,8 +229,8 @@ files:
208
229
  - lib/datadog/ci/test_visibility/serializers/test_suite.rb
209
230
  - lib/datadog/ci/test_visibility/serializers/test_v1.rb
210
231
  - lib/datadog/ci/test_visibility/serializers/test_v2.rb
211
- - lib/datadog/ci/test_visibility/store/global.rb
212
- - lib/datadog/ci/test_visibility/store/local.rb
232
+ - lib/datadog/ci/test_visibility/store/fiber_local.rb
233
+ - lib/datadog/ci/test_visibility/store/process.rb
213
234
  - lib/datadog/ci/test_visibility/telemetry.rb
214
235
  - lib/datadog/ci/test_visibility/total_coverage.rb
215
236
  - lib/datadog/ci/test_visibility/transport.rb
@@ -226,9 +247,11 @@ files:
226
247
  - lib/datadog/ci/transport/telemetry.rb
227
248
  - lib/datadog/ci/utils/bundle.rb
228
249
  - lib/datadog/ci/utils/configuration.rb
250
+ - lib/datadog/ci/utils/file_storage.rb
229
251
  - lib/datadog/ci/utils/git.rb
230
252
  - lib/datadog/ci/utils/parsing.rb
231
253
  - lib/datadog/ci/utils/rum.rb
254
+ - lib/datadog/ci/utils/stateful.rb
232
255
  - lib/datadog/ci/utils/telemetry.rb
233
256
  - lib/datadog/ci/utils/test_run.rb
234
257
  - lib/datadog/ci/version.rb
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../ext/test"
4
-
5
- module Datadog
6
- module CI
7
- module TestVisibility
8
- # Generates internal tags for library capabilities
9
- module Capabilities
10
- def self.tags
11
- tags = {}
12
-
13
- test_optimisation = Datadog::CI.send(:test_optimisation)
14
- tags[Ext::Test::LibraryCapabilities::TAG_TEST_IMPACT_ANALYSIS] = test_optimisation.enabled.to_s
15
-
16
- test_management = Datadog::CI.send(:test_management)
17
- test_management_tag_value = test_management.enabled.to_s
18
-
19
- [
20
- Ext::Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_ATTEMPT_TO_FIX,
21
- Ext::Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_QUARANTINE,
22
- Ext::Test::LibraryCapabilities::TAG_TEST_MANAGEMENT_DISABLE
23
- ].each do |tag|
24
- tags[tag] = test_management_tag_value
25
- end
26
-
27
- test_retries = Datadog::CI.send(:test_retries)
28
- tags[Ext::Test::LibraryCapabilities::TAG_AUTO_TEST_RETRIES] = test_retries.auto_test_retries_feature_enabled.to_s
29
- tags[Ext::Test::LibraryCapabilities::TAG_EARLY_FLAKE_DETECTION] = test_retries.early_flake_detection_feature_enabled.to_s
30
-
31
- tags
32
- end
33
- end
34
- end
35
- end
36
- end