datadog-ci 0.8.2 → 1.0.0.beta1
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 +4 -4
- data/CHANGELOG.md +30 -1
- data/LICENSE-3rdparty.csv +1 -1
- data/README.md +22 -9
- data/ext/datadog_cov/datadog_cov.c +192 -0
- data/ext/datadog_cov/extconf.rb +18 -0
- data/lib/datadog/ci/configuration/settings.rb +1 -1
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +0 -15
- data/lib/datadog/ci/contrib/cucumber/ext.rb +1 -5
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +17 -14
- data/lib/datadog/ci/contrib/cucumber/integration.rb +1 -2
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +0 -15
- data/lib/datadog/ci/contrib/minitest/ext.rb +1 -5
- data/lib/datadog/ci/contrib/minitest/helpers.rb +1 -2
- data/lib/datadog/ci/contrib/minitest/integration.rb +1 -1
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +0 -15
- data/lib/datadog/ci/contrib/rspec/example.rb +18 -20
- data/lib/datadog/ci/contrib/rspec/ext.rb +0 -4
- data/lib/datadog/ci/contrib/rspec/integration.rb +1 -2
- data/lib/datadog/ci/contrib/settings.rb +0 -3
- data/lib/datadog/ci/ext/environment/extractor.rb +3 -2
- data/lib/datadog/ci/ext/environment/providers/base.rb +1 -1
- data/lib/datadog/ci/ext/environment/providers/bitbucket.rb +1 -1
- data/lib/datadog/ci/ext/environment/providers/github_actions.rb +3 -2
- data/lib/datadog/ci/ext/environment.rb +1 -1
- data/lib/datadog/ci/ext/transport.rb +4 -0
- data/lib/datadog/ci/itr/coverage/ddcov.rb +14 -0
- data/lib/datadog/ci/itr/coverage/event.rb +64 -0
- data/lib/datadog/ci/itr/coverage/transport.rb +42 -0
- data/lib/datadog/ci/itr/runner.rb +28 -0
- data/lib/datadog/ci/test.rb +1 -2
- data/lib/datadog/ci/test_visibility/context/global.rb +1 -3
- data/lib/datadog/ci/test_visibility/null_recorder.rb +1 -1
- data/lib/datadog/ci/test_visibility/recorder.rb +20 -3
- data/lib/datadog/ci/test_visibility/serializers/base.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/factories/test_level.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb +1 -1
- data/lib/datadog/ci/test_visibility/transport.rb +10 -53
- data/lib/datadog/ci/transport/api/agentless.rb +8 -1
- data/lib/datadog/ci/transport/api/base.rb +23 -0
- data/lib/datadog/ci/transport/api/builder.rb +14 -5
- data/lib/datadog/ci/transport/api/evp_proxy.rb +8 -0
- data/lib/datadog/ci/transport/event_platform_transport.rb +88 -0
- data/lib/datadog/ci/transport/http.rb +19 -2
- data/lib/datadog/ci/utils/git.rb +2 -2
- data/lib/datadog/ci/version.rb +5 -5
- metadata +25 -5
- data/lib/datadog/ci/utils/url.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8fceb9a2aa80df65f2cac9d910c13253e7c6b1259217af0756f33ecdda8ddd2
|
4
|
+
data.tar.gz: fc946c548d828c80b47612eab9c970968aedf034bfb9f09fb25d7f28acc8da82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253e6acd8ff643842d7c976a02eebbaf3ae844ac7b58a514adaf24538ba8bf4778786565760fed03d730f816ed56a3ad56c96c81a67f1c449ce67c0898086c33
|
7
|
+
data.tar.gz: 86bb8eb4b352d099b90c6b59ca4e5fb3b2fdd3a93562c0e9ba7e04123b4b59bc3c690cf1b85ddefb0634010476c80fce5f323ad73c54e1b9e9739444d14a64b4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
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
|
+
|
14
|
+
## [0.8.3] - 2024-03-20
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
* fix: cucumber-ruby 9.2 includes breaking change for Cucumber::Core::Test::Result ([#145][])
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
* remove temporary hack and use Core::Remote::Negotiation's new constructor param ([#142][])
|
23
|
+
* use filter_basic_auth method from Datadog::Core ([#141][])
|
24
|
+
|
3
25
|
## [0.8.2] - 2024-03-19
|
4
26
|
|
5
27
|
### Fixed
|
@@ -176,7 +198,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
176
198
|
|
177
199
|
* Ruby versions < 2.7 no longer supported ([#8][])
|
178
200
|
|
179
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.
|
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
|
203
|
+
[0.8.3]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.2...v0.8.3
|
180
204
|
[0.8.2]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.1...v0.8.2
|
181
205
|
[0.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.0...v0.8.1
|
182
206
|
[0.8.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.7.0...v0.8.0
|
@@ -246,4 +270,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
246
270
|
[#123]: https://github.com/DataDog/datadog-ci-rb/issues/123
|
247
271
|
[#131]: https://github.com/DataDog/datadog-ci-rb/issues/131
|
248
272
|
[#134]: https://github.com/DataDog/datadog-ci-rb/issues/134
|
273
|
+
[#137]: https://github.com/DataDog/datadog-ci-rb/issues/137
|
249
274
|
[#139]: https://github.com/DataDog/datadog-ci-rb/issues/139
|
275
|
+
[#141]: https://github.com/DataDog/datadog-ci-rb/issues/141
|
276
|
+
[#142]: https://github.com/DataDog/datadog-ci-rb/issues/142
|
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
|
-
|
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
|
-
|
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
|
|
@@ -79,13 +75,31 @@ if ENV["DD_ENV"] == "ci"
|
|
79
75
|
end
|
80
76
|
```
|
81
77
|
|
78
|
+
> [!IMPORTANT]
|
79
|
+
> When using `minitest/autorun` the order of requires matters: `datadog/ci` must be
|
80
|
+
> always required before `minitest/autorun`.
|
81
|
+
|
82
|
+
Example using `minitest/autorun`
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require 'datadog/ci'
|
86
|
+
require 'minitest/autorun'
|
87
|
+
|
88
|
+
if ENV["DD_ENV"] == "ci"
|
89
|
+
Datadog.configure do |c|
|
90
|
+
c.ci.enabled = true
|
91
|
+
c.service = 'my-ruby-app'
|
92
|
+
c.ci.instrument :minitest
|
93
|
+
end
|
94
|
+
end
|
95
|
+
```
|
96
|
+
|
82
97
|
`options` are the following keyword arguments:
|
83
98
|
|
84
99
|
| Key | Description | Default |
|
85
100
|
| --- | ----------- | ------- |
|
86
101
|
| `enabled` | Defines whether Minitest tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
87
102
|
| `service_name` | Service name used for `minitest` instrumentation. | `'minitest'` |
|
88
|
-
| `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'` |
|
89
103
|
|
90
104
|
### Cucumber
|
91
105
|
|
@@ -116,7 +130,6 @@ end
|
|
116
130
|
| --- | ----------- | ------- |
|
117
131
|
| `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
|
118
132
|
| `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
|
119
|
-
| `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'` |
|
120
133
|
|
121
134
|
## Agentless mode
|
122
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
|
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
|
-
#
|
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
|
75
|
-
test_span
|
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
|
-
|
104
|
-
|
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
|
@@ -113,7 +112,7 @@ module Datadog
|
|
113
112
|
end
|
114
113
|
|
115
114
|
def finish_span(span, result)
|
116
|
-
if !result.passed? &&
|
115
|
+
if !result.passed? && ok?(result, @config.strict)
|
117
116
|
span.skipped!(reason: result.message)
|
118
117
|
elsif result.passed?
|
119
118
|
span.passed!
|
@@ -150,19 +149,13 @@ module Datadog
|
|
150
149
|
end
|
151
150
|
|
152
151
|
def finish_current_test_suite
|
153
|
-
|
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
|
-
|
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)
|
@@ -186,6 +179,16 @@ module Datadog
|
|
186
179
|
nil
|
187
180
|
end
|
188
181
|
|
182
|
+
def ok?(result, strict)
|
183
|
+
# in minor update in Cucumber 9.2.0, the arity of the `ok?` method changed
|
184
|
+
parameters = result.method(:ok?).parameters
|
185
|
+
if parameters == [[:opt, :be_strict]]
|
186
|
+
result.ok?(strict)
|
187
|
+
else
|
188
|
+
result.ok?(strict: strict)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
189
192
|
def configuration
|
190
193
|
Datadog.configuration.ci[:cucumber]
|
191
194
|
end
|
@@ -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
|
-
#
|
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
|
-
|
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
|
@@ -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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
70
|
+
test_suite_span&.finish
|
73
71
|
|
74
72
|
result
|
75
73
|
end
|
@@ -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)
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "datadog/core/utils/url"
|
4
|
+
|
3
5
|
require_relative "../git"
|
4
6
|
require_relative "../../utils/git"
|
5
|
-
require_relative "../../utils/url"
|
6
7
|
require_relative "providers"
|
7
8
|
|
8
9
|
module Datadog
|
@@ -76,7 +77,7 @@ module Datadog
|
|
76
77
|
|
77
78
|
@tags[Git::TAG_TAG] = Utils::Git.normalize_ref(@tags[Git::TAG_TAG])
|
78
79
|
@tags[Git::TAG_BRANCH] = Utils::Git.normalize_ref(@tags[Git::TAG_BRANCH])
|
79
|
-
@tags[Git::TAG_REPOSITORY_URL] = Utils::Url.
|
80
|
+
@tags[Git::TAG_REPOSITORY_URL] = Datadog::Core::Utils::Url.filter_basic_auth(
|
80
81
|
@tags[Git::TAG_REPOSITORY_URL]
|
81
82
|
)
|
82
83
|
end
|