datadog-ci 0.8.3 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/LICENSE-3rdparty.csv +1 -1
  4. data/README.md +3 -9
  5. data/ext/datadog_cov/datadog_cov.c +192 -0
  6. data/ext/datadog_cov/extconf.rb +18 -0
  7. data/lib/datadog/ci/configuration/settings.rb +1 -1
  8. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +0 -15
  9. data/lib/datadog/ci/contrib/cucumber/ext.rb +1 -5
  10. data/lib/datadog/ci/contrib/cucumber/formatter.rb +6 -13
  11. data/lib/datadog/ci/contrib/cucumber/integration.rb +1 -2
  12. data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +0 -15
  13. data/lib/datadog/ci/contrib/minitest/ext.rb +1 -5
  14. data/lib/datadog/ci/contrib/minitest/helpers.rb +1 -2
  15. data/lib/datadog/ci/contrib/minitest/integration.rb +1 -1
  16. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +0 -15
  17. data/lib/datadog/ci/contrib/rspec/example.rb +18 -20
  18. data/lib/datadog/ci/contrib/rspec/ext.rb +0 -4
  19. data/lib/datadog/ci/contrib/rspec/integration.rb +1 -2
  20. data/lib/datadog/ci/contrib/settings.rb +0 -3
  21. data/lib/datadog/ci/ext/environment/providers/base.rb +1 -1
  22. data/lib/datadog/ci/ext/environment/providers/bitbucket.rb +1 -1
  23. data/lib/datadog/ci/ext/environment.rb +1 -1
  24. data/lib/datadog/ci/ext/transport.rb +4 -0
  25. data/lib/datadog/ci/itr/coverage/ddcov.rb +14 -0
  26. data/lib/datadog/ci/itr/coverage/event.rb +64 -0
  27. data/lib/datadog/ci/itr/coverage/transport.rb +42 -0
  28. data/lib/datadog/ci/itr/runner.rb +28 -0
  29. data/lib/datadog/ci/test.rb +1 -2
  30. data/lib/datadog/ci/test_visibility/context/global.rb +1 -3
  31. data/lib/datadog/ci/test_visibility/null_recorder.rb +1 -1
  32. data/lib/datadog/ci/test_visibility/recorder.rb +20 -3
  33. data/lib/datadog/ci/test_visibility/serializers/base.rb +1 -1
  34. data/lib/datadog/ci/test_visibility/serializers/factories/test_level.rb +1 -1
  35. data/lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb +1 -1
  36. data/lib/datadog/ci/test_visibility/transport.rb +10 -53
  37. data/lib/datadog/ci/transport/api/agentless.rb +8 -1
  38. data/lib/datadog/ci/transport/api/base.rb +23 -0
  39. data/lib/datadog/ci/transport/api/builder.rb +9 -1
  40. data/lib/datadog/ci/transport/api/evp_proxy.rb +8 -0
  41. data/lib/datadog/ci/transport/event_platform_transport.rb +88 -0
  42. data/lib/datadog/ci/transport/http.rb +19 -2
  43. data/lib/datadog/ci/utils/git.rb +2 -2
  44. data/lib/datadog/ci/version.rb +5 -5
  45. metadata +25 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf750f24412b0800ba1599f22c5b12e8679dddc1d0e9a30aed98d0a51a6badd3
4
- data.tar.gz: 652631fac9702beb340f136e32d4b72b3b38d7c84a8de7dc8ce4f203dc67983b
3
+ metadata.gz: d8fceb9a2aa80df65f2cac9d910c13253e7c6b1259217af0756f33ecdda8ddd2
4
+ data.tar.gz: fc946c548d828c80b47612eab9c970968aedf034bfb9f09fb25d7f28acc8da82
5
5
  SHA512:
6
- metadata.gz: 3295d136609aca4be41cc041613873297a5e91bb37a428a6612a1e62f7e547db2bb2c836f4a0348fdd4466d085a29ec78a26962d48f1c59e05163dcb26668783
7
- data.tar.gz: 5446bba62689a4133a75b64437efd47f8369814e863c8ddab0c91d52692b5bf71b5be2a4f4264839ec81374ff3c4ff498e4c2cd7a8c54f566e63558cb1f55cff
6
+ metadata.gz: 253e6acd8ff643842d7c976a02eebbaf3ae844ac7b58a514adaf24538ba8bf4778786565760fed03d730f816ed56a3ad56c96c81a67f1c449ce67c0898086c33
7
+ data.tar.gz: 86bb8eb4b352d099b90c6b59ca4e5fb3b2fdd3a93562c0e9ba7e04123b4b59bc3c690cf1b85ddefb0634010476c80fce5f323ad73c54e1b9e9739444d14a64b4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.0.beta1] - 2024-03-25
4
+
5
+ ### Added
6
+
7
+ * datadog-cov native extension for per test code coverage ([#137])
8
+ * citestcov transport to serialize and send code coverage events ([#148])
9
+
10
+ ### Removed
11
+
12
+ * Ruby 2.1-2.6 support is dropped
13
+
3
14
  ## [0.8.3] - 2024-03-20
4
15
 
5
16
  ### Fixed
@@ -188,6 +199,7 @@ Currently test suite level visibility is not used by our instrumentation: it wil
188
199
  * Ruby versions < 2.7 no longer supported ([#8][])
189
200
 
190
201
  [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.3...main
202
+ [1.0.0.beta1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.3...v1.0.0.beta1
191
203
  [0.8.3]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.2...v0.8.3
192
204
  [0.8.2]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.1...v0.8.2
193
205
  [0.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.0...v0.8.1
@@ -258,7 +270,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
258
270
  [#123]: https://github.com/DataDog/datadog-ci-rb/issues/123
259
271
  [#131]: https://github.com/DataDog/datadog-ci-rb/issues/131
260
272
  [#134]: https://github.com/DataDog/datadog-ci-rb/issues/134
273
+ [#137]: https://github.com/DataDog/datadog-ci-rb/issues/137
261
274
  [#139]: https://github.com/DataDog/datadog-ci-rb/issues/139
262
275
  [#141]: https://github.com/DataDog/datadog-ci-rb/issues/141
263
276
  [#142]: https://github.com/DataDog/datadog-ci-rb/issues/142
264
277
  [#145]: https://github.com/DataDog/datadog-ci-rb/issues/145
278
+ [#148]: https://github.com/DataDog/datadog-ci-rb/issues/148
data/LICENSE-3rdparty.csv CHANGED
@@ -1,3 +1,3 @@
1
1
  Component,Origin,License,Copyright
2
- dd-trace-rb,https://github.com/DataDog/dd-trace-rb,Apache 2.0,"Copyright 2016-Present Datadog, Inc."
2
+ datadog,https://github.com/DataDog/dd-trace-rb,Apache 2.0,"Copyright 2016-Present Datadog, Inc."
3
3
  msgpack,https://rubygems.org/gems/msgpack,Apache-2.0,"Copyright (c) 2008-2015 Sadayuki Furuhashi"
data/README.md CHANGED
@@ -8,17 +8,14 @@
8
8
  Datadog's Ruby Library for instrumenting your test and continuous integration pipeline.
9
9
  Learn more on our [official website](https://docs.datadoghq.com/tests/) and check out our [documentation for this library](https://docs.datadoghq.com/tests/setup/ruby/?tab=cloudciprovideragentless).
10
10
 
11
- > [!IMPORTANT]
12
- > The `datadog-ci` gem is currently a component of [`ddtrace`](https://github.com/datadog/dd-trace-rb) and should not be used without it.
13
- >
14
- > We expect this to change in the future.
15
-
16
11
  ## Installation
17
12
 
18
13
  Add to your Gemfile.
19
14
 
20
15
  ```ruby
21
- gem "ddtrace"
16
+ group :test do
17
+ gem "datadog-ci"
18
+ end
22
19
  ```
23
20
 
24
21
  ## Usage
@@ -52,7 +49,6 @@ end
52
49
  | --- | ----------- | ------- |
53
50
  | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
54
51
  | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
55
- | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `rspec` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'rspec.example'` |
56
52
 
57
53
  ### Minitest
58
54
 
@@ -104,7 +100,6 @@ end
104
100
  | --- | ----------- | ------- |
105
101
  | `enabled` | Defines whether Minitest tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
106
102
  | `service_name` | Service name used for `minitest` instrumentation. | `'minitest'` |
107
- | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `minitest` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'minitest.test'` |
108
103
 
109
104
  ### Cucumber
110
105
 
@@ -135,7 +130,6 @@ end
135
130
  | --- | ----------- | ------- |
136
131
  | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
137
132
  | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
138
- | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `cucumber` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'cucumber.test'` |
139
133
 
140
134
  ## Agentless mode
141
135
 
@@ -0,0 +1,192 @@
1
+ #include <ruby.h>
2
+ #include <ruby/debug.h>
3
+
4
+ // constants
5
+ #define DD_COV_TARGET_FILES 1
6
+ #define DD_COV_TARGET_LINES 2
7
+
8
+ // Data structure
9
+ struct dd_cov_data
10
+ {
11
+ VALUE root;
12
+ int mode;
13
+ VALUE coverage;
14
+ };
15
+
16
+ static void dd_cov_mark(void *ptr)
17
+ {
18
+ struct dd_cov_data *dd_cov_data = ptr;
19
+ rb_gc_mark_movable(dd_cov_data->coverage);
20
+ rb_gc_mark_movable(dd_cov_data->root);
21
+ }
22
+
23
+ static void dd_cov_free(void *ptr)
24
+ {
25
+ struct dd_cov_data *dd_cov_data = ptr;
26
+
27
+ xfree(dd_cov_data);
28
+ }
29
+
30
+ static void dd_cov_compact(void *ptr)
31
+ {
32
+ struct dd_cov_data *dd_cov_data = ptr;
33
+ dd_cov_data->coverage = rb_gc_location(dd_cov_data->coverage);
34
+ dd_cov_data->root = rb_gc_location(dd_cov_data->root);
35
+ }
36
+
37
+ const rb_data_type_t dd_cov_data_type = {
38
+ .wrap_struct_name = "dd_cov",
39
+ .function = {
40
+ .dmark = dd_cov_mark,
41
+ .dfree = dd_cov_free,
42
+ .dsize = NULL,
43
+ .dcompact = dd_cov_compact},
44
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
45
+
46
+ static VALUE dd_cov_allocate(VALUE klass)
47
+ {
48
+ struct dd_cov_data *dd_cov_data;
49
+ VALUE obj = TypedData_Make_Struct(klass, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
50
+ dd_cov_data->coverage = rb_hash_new();
51
+ dd_cov_data->root = Qnil;
52
+ dd_cov_data->mode = DD_COV_TARGET_FILES;
53
+ return obj;
54
+ }
55
+
56
+ // DDCov methods
57
+ static VALUE dd_cov_initialize(int argc, VALUE *argv, VALUE self)
58
+ {
59
+ VALUE opt;
60
+ int mode;
61
+
62
+ rb_scan_args(argc, argv, "10", &opt);
63
+ VALUE rb_root = rb_hash_lookup(opt, ID2SYM(rb_intern("root")));
64
+ if (!RTEST(rb_root))
65
+ {
66
+ rb_raise(rb_eArgError, "root is required");
67
+ }
68
+
69
+ VALUE rb_mode = rb_hash_lookup(opt, ID2SYM(rb_intern("mode")));
70
+ if (!RTEST(rb_mode) || rb_mode == ID2SYM(rb_intern("files")))
71
+ {
72
+ mode = DD_COV_TARGET_FILES;
73
+ }
74
+ else if (rb_mode == ID2SYM(rb_intern("lines")))
75
+ {
76
+ mode = DD_COV_TARGET_LINES;
77
+ }
78
+ else
79
+ {
80
+ rb_raise(rb_eArgError, "mode is invalid");
81
+ }
82
+
83
+ struct dd_cov_data *dd_cov_data;
84
+ TypedData_Get_Struct(self, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
85
+
86
+ dd_cov_data->root = rb_root;
87
+ dd_cov_data->mode = mode;
88
+
89
+ return Qnil;
90
+ }
91
+
92
+ static void dd_cov_update_line_coverage(rb_event_flag_t event, VALUE data, VALUE self, ID id, VALUE klass)
93
+ {
94
+ struct dd_cov_data *dd_cov_data;
95
+ TypedData_Get_Struct(data, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
96
+
97
+ const char *filename = rb_sourcefile();
98
+ if (filename == NULL)
99
+ {
100
+ return;
101
+ }
102
+
103
+ if (dd_cov_data->root == Qnil)
104
+ {
105
+ return;
106
+ }
107
+
108
+ char *c_root = RSTRING_PTR(dd_cov_data->root);
109
+ if (c_root == NULL)
110
+ {
111
+ return;
112
+ }
113
+ long root_len = RSTRING_LEN(dd_cov_data->root);
114
+ // check that root is a prefix of the filename
115
+ // so this file is located under the given root
116
+ if (strncmp(c_root, filename, root_len) != 0)
117
+ {
118
+ return;
119
+ }
120
+
121
+ VALUE rb_str_source_file = rb_str_new2(filename);
122
+
123
+ if (dd_cov_data->mode == DD_COV_TARGET_FILES)
124
+ {
125
+ rb_hash_aset(dd_cov_data->coverage, rb_str_source_file, Qtrue);
126
+ return;
127
+ }
128
+
129
+ // this isn't optimized yet, this is a POC to show that lines coverage is possible
130
+ // ITR beta is going to use files coverage, we'll get back to this part when
131
+ // we need to implement lines coverage
132
+ if (dd_cov_data->mode == DD_COV_TARGET_LINES)
133
+ {
134
+ int line_number = rb_sourceline();
135
+ if (line_number <= 0)
136
+ {
137
+ return;
138
+ }
139
+
140
+ VALUE rb_lines = rb_hash_aref(dd_cov_data->coverage, rb_str_source_file);
141
+ if (rb_lines == Qnil)
142
+ {
143
+ rb_lines = rb_hash_new();
144
+ rb_hash_aset(dd_cov_data->coverage, rb_str_source_file, rb_lines);
145
+ }
146
+
147
+ rb_hash_aset(rb_lines, INT2FIX(line_number), Qtrue);
148
+ }
149
+ }
150
+
151
+ static VALUE dd_cov_start(VALUE self)
152
+ {
153
+ // get current thread
154
+ VALUE thval = rb_thread_current();
155
+
156
+ // add event hook
157
+ rb_thread_add_event_hook(thval, dd_cov_update_line_coverage, RUBY_EVENT_LINE, self);
158
+
159
+ return self;
160
+ }
161
+
162
+ static VALUE dd_cov_stop(VALUE self)
163
+ {
164
+ // get current thread
165
+ VALUE thval = rb_thread_current();
166
+ // remove event hook for the current thread
167
+ rb_thread_remove_event_hook(thval, dd_cov_update_line_coverage);
168
+
169
+ struct dd_cov_data *dd_cov_data;
170
+ TypedData_Get_Struct(self, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
171
+
172
+ VALUE cov = dd_cov_data->coverage;
173
+
174
+ dd_cov_data->coverage = rb_hash_new();
175
+
176
+ return cov;
177
+ }
178
+
179
+ void Init_datadog_cov(void)
180
+ {
181
+ VALUE mDatadog = rb_define_module("Datadog");
182
+ VALUE mCI = rb_define_module_under(mDatadog, "CI");
183
+ VALUE mITR = rb_define_module_under(mCI, "ITR");
184
+ VALUE mCoverage = rb_define_module_under(mITR, "Coverage");
185
+ VALUE cDatadogCov = rb_define_class_under(mCoverage, "DDCov", rb_cObject);
186
+
187
+ rb_define_alloc_func(cDatadogCov, dd_cov_allocate);
188
+
189
+ rb_define_method(cDatadogCov, "initialize", dd_cov_initialize, -1);
190
+ rb_define_method(cDatadogCov, "start", dd_cov_start, 0);
191
+ rb_define_method(cDatadogCov, "stop", dd_cov_stop, 0);
192
+ }
@@ -0,0 +1,18 @@
1
+ if RUBY_ENGINE != "ruby" || Gem.win_platform?
2
+ warn(
3
+ "WARN: Skipping build of code coverage native extension because of unsupported platform."
4
+ )
5
+
6
+ File.write("Makefile", "all install clean: # dummy makefile that does nothing")
7
+ exit
8
+ end
9
+
10
+ require "mkmf"
11
+
12
+ # Tag the native extension library with the Ruby version and Ruby platform.
13
+ # This makes it easier for development (avoids "oops I forgot to rebuild when I switched my Ruby") and ensures that
14
+ # the wrong library is never loaded.
15
+ # When requiring, we need to use the exact same string, including the version and the platform.
16
+ EXTENSION_NAME = "datadog_cov.#{RUBY_VERSION}_#{RUBY_PLATFORM}".freeze
17
+
18
+ create_makefile(EXTENSION_NAME)
@@ -47,7 +47,7 @@ module Datadog
47
47
  o.after_set do |value|
48
48
  if value
49
49
  Datadog::Core.log_deprecation do
50
- "The experimental_test_suite_level_visibility_enabled setting has no effect and will be removed in 1.0. " \
50
+ "The experimental_test_suite_level_visibility_enabled setting has no effect and will be removed in 2.0. " \
51
51
  "Test suite level visibility is now enabled by default. " \
52
52
  "If you want to disable test suite level visibility set configuration.ci.force_test_level_visibility = true."
53
53
  end
@@ -26,21 +26,6 @@ module Datadog
26
26
  Utils::Configuration.fetch_service_name(Ext::DEFAULT_SERVICE_NAME)
27
27
  end
28
28
  end
29
-
30
- # @deprecated Will be removed in 1.0
31
- option :operation_name do |o|
32
- o.type :string
33
- o.env Ext::ENV_OPERATION_NAME
34
- o.default Ext::OPERATION_NAME
35
-
36
- o.after_set do |value|
37
- if value && value != Ext::OPERATION_NAME
38
- Datadog::Core.log_deprecation do
39
- "The operation_name setting has no effect and will be removed in 1.0"
40
- end
41
- end
42
- end
43
- end
44
29
  end
45
30
  end
46
31
  end
@@ -5,7 +5,7 @@ module Datadog
5
5
  module Contrib
6
6
  module Cucumber
7
7
  # Cucumber integration constants
8
- # TODO: mark as `@public_api` when GA, to protect from resource and tag name changes.
8
+ # @public_api
9
9
  module Ext
10
10
  ENV_ENABLED = "DD_TRACE_CUCUMBER_ENABLED"
11
11
  DEFAULT_SERVICE_NAME = "cucumber"
@@ -13,10 +13,6 @@ module Datadog
13
13
  FRAMEWORK = "cucumber"
14
14
 
15
15
  STEP_SPAN_TYPE = "step"
16
-
17
- # TODO: remove in 1.0
18
- ENV_OPERATION_NAME = "DD_TRACE_CUCUMBER_OPERATION_NAME"
19
- OPERATION_NAME = "cucumber.test"
20
16
  end
21
17
  end
22
18
  end
@@ -71,8 +71,8 @@ module Datadog
71
71
  service: configuration[:service_name]
72
72
  )
73
73
 
74
- if test_span && (parameters = extract_parameters_hash(event.test_case))
75
- test_span.set_parameters(parameters)
74
+ if (parameters = extract_parameters_hash(event.test_case))
75
+ test_span&.set_parameters(parameters)
76
76
  end
77
77
  end
78
78
 
@@ -100,9 +100,8 @@ module Datadog
100
100
  def test_suite_name(test_case)
101
101
  feature = if test_case.respond_to?(:feature)
102
102
  test_case.feature
103
- elsif @ast_lookup
104
- gherkin_doc = @ast_lookup.gherkin_document(test_case.location.file)
105
- gherkin_doc.feature if gherkin_doc
103
+ else
104
+ @ast_lookup&.gherkin_document(test_case.location.file)&.feature
106
105
  end
107
106
 
108
107
  if feature
@@ -150,19 +149,13 @@ module Datadog
150
149
  end
151
150
 
152
151
  def finish_current_test_suite
153
- test_suite = @current_test_suite
154
- return unless test_suite
155
-
156
- test_suite.finish
152
+ @current_test_suite&.finish
157
153
 
158
154
  @current_test_suite = nil
159
155
  end
160
156
 
161
157
  def same_test_suite_as_current?(test_suite_name)
162
- test_suite = @current_test_suite
163
- return false unless test_suite
164
-
165
- test_suite.name == test_suite_name
158
+ @current_test_suite&.name == test_suite_name
166
159
  end
167
160
 
168
161
  def extract_parameters_hash(test_case)
@@ -17,8 +17,7 @@ module Datadog
17
17
  register_as :cucumber
18
18
 
19
19
  def self.version
20
- Gem.loaded_specs["cucumber"] \
21
- && Gem.loaded_specs["cucumber"].version
20
+ Gem.loaded_specs["cucumber"]&.version
22
21
  end
23
22
 
24
23
  def self.loaded?
@@ -24,21 +24,6 @@ module Datadog
24
24
  Utils::Configuration.fetch_service_name(Ext::DEFAULT_SERVICE_NAME)
25
25
  end
26
26
  end
27
-
28
- # @deprecated Will be removed in 1.0
29
- option :operation_name do |o|
30
- o.type :string
31
- o.env Ext::ENV_OPERATION_NAME
32
- o.default Ext::OPERATION_NAME
33
-
34
- o.after_set do |value|
35
- if value && value != Ext::OPERATION_NAME
36
- Datadog::Core.log_deprecation do
37
- "The operation_name setting has no effect and will be removed in 1.0"
38
- end
39
- end
40
- end
41
- end
42
27
  end
43
28
  end
44
29
  end
@@ -5,17 +5,13 @@ module Datadog
5
5
  module Contrib
6
6
  module Minitest
7
7
  # Minitest integration constants
8
- # TODO: mark as `@public_api` when GA, to protect from resource and tag name changes.
8
+ # @public_api
9
9
  module Ext
10
10
  ENV_ENABLED = "DD_TRACE_MINITEST_ENABLED"
11
11
 
12
12
  FRAMEWORK = "minitest"
13
13
 
14
14
  DEFAULT_SERVICE_NAME = "minitest"
15
-
16
- # TODO: remove in 1.0
17
- ENV_OPERATION_NAME = "DD_TRACE_MINITEST_OPERATION_NAME"
18
- OPERATION_NAME = "minitest.test"
19
15
  end
20
16
  end
21
17
  end
@@ -25,8 +25,7 @@ module Datadog
25
25
  def self.extract_source_location_from_class(klass)
26
26
  return nil if klass.nil? || klass.name.nil?
27
27
 
28
- source_location = klass.const_source_location(klass.name)
29
- source_location.first unless source_location.nil?
28
+ klass.const_source_location(klass.name)&.first
30
29
  rescue
31
30
  nil
32
31
  end
@@ -17,7 +17,7 @@ module Datadog
17
17
  register_as :minitest
18
18
 
19
19
  def self.version
20
- Gem.loaded_specs["minitest"] && Gem.loaded_specs["minitest"].version
20
+ Gem.loaded_specs["minitest"]&.version
21
21
  end
22
22
 
23
23
  def self.loaded?
@@ -24,21 +24,6 @@ module Datadog
24
24
  Utils::Configuration.fetch_service_name(Ext::DEFAULT_SERVICE_NAME)
25
25
  end
26
26
  end
27
-
28
- # @deprecated Will be removed in 1.0
29
- option :operation_name do |o|
30
- o.type :string
31
- o.env Ext::ENV_OPERATION_NAME
32
- o.default Ext::OPERATION_NAME
33
-
34
- o.after_set do |value|
35
- if value && value != Ext::OPERATION_NAME
36
- Datadog::Core.log_deprecation do
37
- "The operation_name setting has no effect and will be removed in 1.0"
38
- end
39
- end
40
- end
41
- end
42
27
  end
43
28
  end
44
29
  end
@@ -48,28 +48,26 @@ module Datadog
48
48
  ) do |test_span|
49
49
  result = super
50
50
 
51
- if test_span
52
- test_span.set_parameters({}, {"scoped_id" => metadata[:scoped_id]})
53
-
54
- case execution_result.status
55
- when :passed
56
- test_span.passed!
57
- test_suite_span.passed! if test_suite_span
58
- when :failed
59
- test_span.failed!(exception: execution_result.exception)
60
- test_suite_span.failed! if test_suite_span
61
- else
62
- # :pending or nil
63
- test_span.skipped!(
64
- reason: execution_result.pending_message,
65
- exception: execution_result.pending_exception
66
- )
67
-
68
- test_suite_span.skipped! if test_suite_span
69
- end
51
+ test_span&.set_parameters({}, {"scoped_id" => metadata[:scoped_id]})
52
+
53
+ case execution_result.status
54
+ when :passed
55
+ test_span&.passed!
56
+ test_suite_span&.passed!
57
+ when :failed
58
+ test_span&.failed!(exception: execution_result.exception)
59
+ test_suite_span&.failed!
60
+ else
61
+ # :pending or nil
62
+ test_span&.skipped!(
63
+ reason: execution_result.pending_message,
64
+ exception: execution_result.pending_exception
65
+ )
66
+
67
+ test_suite_span&.skipped!
70
68
  end
71
69
 
72
- test_suite_span.finish if test_suite_span
70
+ test_suite_span&.finish
73
71
 
74
72
  result
75
73
  end
@@ -11,10 +11,6 @@ module Datadog
11
11
  DEFAULT_SERVICE_NAME = "rspec"
12
12
 
13
13
  ENV_ENABLED = "DD_TRACE_RSPEC_ENABLED"
14
-
15
- # TODO: remove in 1.0
16
- ENV_OPERATION_NAME = "DD_TRACE_RSPEC_OPERATION_NAME"
17
- OPERATION_NAME = "rspec.example"
18
14
  end
19
15
  end
20
16
  end
@@ -17,8 +17,7 @@ module Datadog
17
17
  register_as :rspec
18
18
 
19
19
  def self.version
20
- Gem.loaded_specs["rspec-core"] \
21
- && Gem.loaded_specs["rspec-core"].version
20
+ Gem.loaded_specs["rspec-core"]&.version
22
21
  end
23
22
 
24
23
  def self.loaded?
@@ -11,9 +11,6 @@ module Datadog
11
11
  option :enabled, default: true
12
12
  option :service_name
13
13
 
14
- # @deprecated Will be removed in 1.0
15
- option :operation_name
16
-
17
14
  def configure(options = {})
18
15
  self.class.options.each do |name, _value|
19
16
  self[name] = options[name] if options.key?(name)
@@ -103,7 +103,7 @@ module Datadog
103
103
  @branch = @tag = nil
104
104
 
105
105
  # @type var branch_or_tag_string: untyped
106
- if branch_or_tag_string && branch_or_tag_string.include?("tags/")
106
+ if branch_or_tag_string&.include?("tags/")
107
107
  @tag = branch_or_tag_string
108
108
  else
109
109
  @branch = branch_or_tag_string
@@ -20,7 +20,7 @@ module Datadog
20
20
  end
21
21
 
22
22
  def pipeline_id
23
- env["BITBUCKET_PIPELINE_UUID"] ? env["BITBUCKET_PIPELINE_UUID"].tr("{}", "") : nil
23
+ env["BITBUCKET_PIPELINE_UUID"]&.tr("{}", "")
24
24
  end
25
25
 
26
26
  def pipeline_name
@@ -71,7 +71,7 @@ module Datadog
71
71
  return
72
72
  end
73
73
 
74
- unless HEX_NUMBER_REGEXP =~ git_sha
74
+ unless HEX_NUMBER_REGEXP.match?(git_sha)
75
75
  message += " Expected SHA to be a valid HEX number, got #{git_sha}."
76
76
  Datadog.logger.error(message)
77
77
  end
@@ -23,6 +23,9 @@ module Datadog
23
23
  TEST_VISIBILITY_INTAKE_HOST_PREFIX = "citestcycle-intake"
24
24
  TEST_VISIBILITY_INTAKE_PATH = "/api/v2/citestcycle"
25
25
 
26
+ TEST_COVERAGE_INTAKE_HOST_PREFIX = "citestcov-intake"
27
+ TEST_COVERAGE_INTAKE_PATH = "/api/v2/citestcov"
28
+
26
29
  DD_API_HOST_PREFIX = "api"
27
30
  DD_API_SETTINGS_PATH = "/api/v2/libraries/tests/services/setting"
28
31
  DD_API_SETTINGS_TYPE = "ci_app_test_service_libraries_settings"
@@ -35,6 +38,7 @@ module Datadog
35
38
 
36
39
  CONTENT_TYPE_MESSAGEPACK = "application/msgpack"
37
40
  CONTENT_TYPE_JSON = "application/json"
41
+ CONTENT_TYPE_MULTIPART_FORM_DATA = "multipart/form-data"
38
42
  CONTENT_ENCODING_GZIP = "gzip"
39
43
  end
40
44
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module CI
5
+ module ITR
6
+ module Coverage
7
+ # Placeholder for code coverage collection
8
+ # Implementation in ext/datadog_cov
9
+ class DDCov
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end