datadog-ci 1.0.0.beta2 → 1.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +106 -72
- data/ext/datadog_cov/datadog_cov.c +36 -10
- data/lib/datadog/ci/configuration/components.rb +21 -2
- data/lib/datadog/ci/configuration/settings.rb +9 -3
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +4 -1
- data/lib/datadog/ci/contrib/minitest/patcher.rb +2 -2
- data/lib/datadog/ci/contrib/minitest/test.rb +105 -0
- data/lib/datadog/ci/contrib/rspec/example.rb +2 -0
- data/lib/datadog/ci/contrib/rspec/knapsack_pro/extension.rb +30 -0
- data/lib/datadog/ci/contrib/rspec/knapsack_pro/runner.rb +57 -0
- data/lib/datadog/ci/contrib/rspec/patcher.rb +17 -1
- data/lib/datadog/ci/ext/environment.rb +5 -0
- data/lib/datadog/ci/ext/settings.rb +1 -0
- data/lib/datadog/ci/ext/test.rb +3 -1
- data/lib/datadog/ci/itr/coverage/writer.rb +7 -1
- data/lib/datadog/ci/itr/runner.rb +30 -6
- data/lib/datadog/ci/itr/skippable.rb +4 -2
- data/lib/datadog/ci/span.rb +7 -0
- data/lib/datadog/ci/test.rb +18 -0
- data/lib/datadog/ci/test_visibility/serializers/base.rb +3 -2
- data/lib/datadog/ci/test_visibility/serializers/factories/test_level.rb +3 -3
- data/lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb +6 -6
- data/lib/datadog/ci/test_visibility/serializers/test_v2.rb +14 -2
- data/lib/datadog/ci/test_visibility/transport.rb +5 -1
- data/lib/datadog/ci/transport/remote_settings_api.rb +4 -2
- data/lib/datadog/ci/utils/bundle.rb +26 -0
- data/lib/datadog/ci/utils/test_run.rb +12 -0
- data/lib/datadog/ci/version.rb +1 -1
- metadata +10 -7
- data/lib/datadog/ci/contrib/minitest/hooks.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035d75d50e0e09c7895bc0e434c5ac1e0655618763ac724a94989833e0c07d61
|
4
|
+
data.tar.gz: bfbd5d6ff101ef51e59d3546d110f906f178c23602241f85b3a8b413524a9900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b6463b913cbff1e20a2c3f4fcaa6c47814ba693eee5682fa41c3baa74f9e92414b4e554ec8407807d6eeb1744f0c76d87bb0889bd0e639c6ebdc3de1dcd180
|
7
|
+
data.tar.gz: dca4568f30dbaef22e8fac94389e682beb21ba6f92f0578553ff01d2ad289f38d33f899c79bef604f3f83906d6c31b9e64a9495cc3dc986fb321bd810430780d
|
data/CHANGELOG.md
CHANGED
@@ -1,117 +1,141 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.0.0.beta4] - 2024-05-14
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* Knapsack Pro 7/RSpec 3 support ([#172][])
|
8
|
+
* add settings option to ignore code coverage for bundled gems location ([#174][])
|
9
|
+
* log an error message if tracing is disabled but test visibility is enabled ([#175][])
|
10
|
+
|
11
|
+
### Removed
|
12
|
+
|
13
|
+
* remove deprecated use alias ([#173][])
|
14
|
+
|
15
|
+
## [1.0.0.beta3] - 2024-04-30
|
16
|
+
|
17
|
+
### Added
|
18
|
+
|
19
|
+
- "why this test was skipped" feature ([#165])
|
20
|
+
- custom configurations tags support for ITR ([#166])
|
21
|
+
- unskippable tests for ITR ([#167])
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- additional debug logging, do not skip tests when running in forked processes ([#168])
|
26
|
+
|
3
27
|
## [1.0.0.beta2] - 2024-04-23
|
4
28
|
|
5
29
|
### Added
|
6
30
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
31
|
+
- Code coverage events writer ([#150])
|
32
|
+
- Git tree upload - git command line integration ([#151])
|
33
|
+
- Add Git::SearchCommits api client ([#152])
|
34
|
+
- Upload packfiles API client ([#153])
|
35
|
+
- Git tree uploader ([#154])
|
36
|
+
- Git repository unshallowing logic ([#155])
|
37
|
+
- Git upload async worker ([#156])
|
38
|
+
- Reduce ITR-induced code coverage overhead for default branch ([#157])
|
39
|
+
- Skippable tests api client ([#158])
|
40
|
+
- Request skippable tests when configuring ITR ([#159])
|
41
|
+
- Test skipping implementation ([#160])
|
18
42
|
|
19
43
|
## [1.0.0.beta1] - 2024-03-25
|
20
44
|
|
21
45
|
### Added
|
22
46
|
|
23
|
-
|
24
|
-
|
47
|
+
- datadog-cov native extension for per test code coverage ([#137])
|
48
|
+
- citestcov transport to serialize and send code coverage events ([#148])
|
25
49
|
|
26
50
|
### Removed
|
27
51
|
|
28
|
-
|
52
|
+
- Ruby 2.1-2.6 support is dropped
|
29
53
|
|
30
54
|
## [0.8.3] - 2024-03-20
|
31
55
|
|
32
56
|
### Fixed
|
33
57
|
|
34
|
-
|
58
|
+
- fix: cucumber-ruby 9.2 includes breaking change for Cucumber::Core::Test::Result ([#145][])
|
35
59
|
|
36
60
|
### Changed
|
37
61
|
|
38
|
-
|
39
|
-
|
62
|
+
- remove temporary hack and use Core::Remote::Negotiation's new constructor param ([#142][])
|
63
|
+
- use filter_basic_auth method from Datadog::Core ([#141][])
|
40
64
|
|
41
65
|
## [0.8.2] - 2024-03-19
|
42
66
|
|
43
67
|
### Fixed
|
44
68
|
|
45
|
-
|
69
|
+
- assign the single running test suite for a test if none found by test suite name ([#139][])
|
46
70
|
|
47
71
|
## [0.8.1] - 2024-03-12
|
48
72
|
|
49
73
|
### Fixed
|
50
74
|
|
51
|
-
|
75
|
+
- fix minitest instrumentation with mixins ([#134][])
|
52
76
|
|
53
77
|
## [0.8.0] - 2024-03-08
|
54
78
|
|
55
79
|
### Added
|
56
80
|
|
57
|
-
|
81
|
+
- gzip agent payloads support via evp_proxy/v4 ([#123][])
|
58
82
|
|
59
83
|
### Changed
|
60
84
|
|
61
|
-
|
85
|
+
- Add note to README on using VCR ([#122][])
|
62
86
|
|
63
87
|
### Fixed
|
64
88
|
|
65
|
-
|
89
|
+
- use framework name as test module name to make test fingerprints stable ([#131][])
|
66
90
|
|
67
91
|
## [0.7.0] - 2024-01-26
|
68
92
|
|
69
93
|
### Added
|
70
94
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
95
|
+
- Source code integration ([#95][])
|
96
|
+
- CODEOWNERS support ([#98][])
|
97
|
+
- Cucumber scenarios with examples are treated as parametrized tests ([#100][])
|
98
|
+
- Deduplicate dynamically generated RSpec examples using test.parameters ([#101][])
|
99
|
+
- Repository name is used as default test service name ([#104][])
|
100
|
+
- Cucumber v9 support ([#99][])
|
101
|
+
- ci-queue runner support for minitest ([#110][])
|
102
|
+
- ci-queue support for rspec ([#112][])
|
79
103
|
|
80
104
|
### Fixed
|
81
105
|
|
82
|
-
|
83
|
-
|
84
|
-
|
106
|
+
- do not publish sig folder when publishing this gem to prevent steep errors in client applications ([#114][])
|
107
|
+
- minitest: fix rails parallel test runner ([#115][])
|
108
|
+
- Test suites and tests skipped by frameworks are correctly reported as skipped to Datadog ([#113][])
|
85
109
|
|
86
110
|
### Changed
|
87
111
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
112
|
+
- Enable test suite level visibility by default (with killswitch) ([#109][])
|
113
|
+
- Test suite names are more human-readable now ([#105][])
|
114
|
+
- Remove span_type method in tracer-related models ([#107][])
|
115
|
+
- Manual tracing API: convert type parameter to keyword in Datadog::CI.trace, remove internal-only methods from public API ([#108][])
|
92
116
|
|
93
117
|
## [0.6.0] - 2024-01-03
|
94
118
|
|
95
119
|
### Added
|
96
120
|
|
97
|
-
|
98
|
-
|
99
|
-
|
121
|
+
- Test suite level visibility instrumentation for RSpec ([#86][])
|
122
|
+
- Test suite level visibility instrumentation for Cucumber ([#90][])
|
123
|
+
- Test suite level visibility instrumentation for Minitest framework ([#92][])
|
100
124
|
|
101
125
|
### Fixed
|
102
126
|
|
103
|
-
|
127
|
+
- Do not instantiate TestVisibility::Recorder unless CI visibility is enabled ([#89][])
|
104
128
|
|
105
129
|
## [0.5.1] - 2023-12-11
|
106
130
|
|
107
131
|
### Fixed
|
108
132
|
|
109
|
-
|
133
|
+
- do not collect environment tags when CI is not enabled ([#87][])
|
110
134
|
|
111
135
|
### Changed
|
112
136
|
|
113
|
-
|
114
|
-
|
137
|
+
- Move private classes and modules deeper in module hierarchy ([#85][])
|
138
|
+
- update appraisal dependencies ([#84][])
|
115
139
|
|
116
140
|
## [0.5.0] - 2023-12-06
|
117
141
|
|
@@ -123,98 +147,100 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
123
147
|
|
124
148
|
### Added
|
125
149
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
150
|
+
- Test suite level visibility: add test session public API ([#72][])
|
151
|
+
- Test suite level visibility: test module support ([#76][])
|
152
|
+
- Test suite level visibility: test suites support ([#77][])
|
153
|
+
- add YARD documentation ([#82][])
|
154
|
+
- support validation errors for CI spans ([#78][])
|
131
155
|
|
132
156
|
### Changed
|
133
157
|
|
134
|
-
|
135
|
-
|
158
|
+
- Validate DD_SITE variable ([#79][])
|
159
|
+
- Document how to use WebMock with datadog-ci ([#80][])
|
136
160
|
|
137
161
|
### Fixed
|
138
162
|
|
139
|
-
|
140
|
-
|
163
|
+
- Datadog::CI.trace_test always starts a new trace ([#74][])
|
164
|
+
- Skip tracing when CI mode disabled and manual API is used ([#75][])
|
141
165
|
|
142
166
|
### Removed
|
143
167
|
|
144
|
-
|
168
|
+
- Deprecate operation name setting, change service_name to service in public API ([#81][])
|
145
169
|
|
146
170
|
## [0.4.1] - 2023-11-22
|
147
171
|
|
148
172
|
### Fixed
|
149
173
|
|
150
|
-
|
174
|
+
- disable 128-bit trace id generation in CI mode ([#70][])
|
151
175
|
|
152
176
|
## [0.4.0] - 2023-11-21
|
153
177
|
|
154
178
|
### Added
|
155
179
|
|
156
|
-
|
180
|
+
- Public API for manual test instrumentation ([#64][]) ([#61][])
|
157
181
|
|
158
182
|
### Changed
|
159
183
|
|
160
|
-
|
184
|
+
- fix tracing instrumentation example in readme ([#60][])
|
161
185
|
|
162
186
|
### Fixed
|
163
187
|
|
164
|
-
|
188
|
+
- Remove user credentials from ssh URLs and from GITHUB_REPO_URL environment variable ([#66][])
|
165
189
|
|
166
190
|
### Removed
|
167
191
|
|
168
|
-
|
192
|
+
- Remove _dd.measured tag from spans ([#65][])
|
169
193
|
|
170
194
|
## [0.3.0] - 2023-10-25
|
171
195
|
|
172
196
|
### Added
|
173
197
|
|
174
|
-
|
175
|
-
|
198
|
+
- Add AWS CodePipeline support for automatic CI tags extraction ([#54][])
|
199
|
+
- Support test visibility protocol via Datadog Agent with EVP proxy ([#51][])
|
176
200
|
|
177
201
|
### Changed
|
178
202
|
|
179
|
-
|
203
|
+
- Migrate to Net::HTTP adapter from Core module of ddtrace gem ([#49][])
|
180
204
|
|
181
205
|
## [0.2.0] - 2023-10-05
|
182
206
|
|
183
207
|
### Added
|
184
208
|
|
185
|
-
|
209
|
+
- [CIAPP-2959] Agentless mode ([#33][])
|
186
210
|
|
187
211
|
### Fixed
|
188
212
|
|
189
|
-
|
213
|
+
- [CIAPP-4278] Fix an issue with emojis in commit message breaking LocalGit tags provider ([#40][])
|
190
214
|
|
191
215
|
## [0.1.1] - 2023-09-14
|
192
216
|
|
193
217
|
### Fixed
|
194
218
|
|
195
|
-
|
219
|
+
- Fix circular dependencies warnings ([#31][])
|
196
220
|
|
197
221
|
## 0.1.0 - 2023-09-12
|
198
222
|
|
199
223
|
### Added
|
200
224
|
|
201
|
-
|
202
|
-
|
203
|
-
|
225
|
+
- Add cucumber 8.0.0 support ([#7][])
|
226
|
+
- Docs: contribution documentation ([#14][], [#28][])
|
227
|
+
- Dev process: issue templates ([#20][])
|
204
228
|
|
205
229
|
### Changed
|
206
230
|
|
207
|
-
|
231
|
+
- Validate customer-supplied git tags ([#15][])
|
208
232
|
|
209
233
|
### Fixed
|
210
234
|
|
211
|
-
|
235
|
+
- Fix Datadog::CI::Environment to support the new CI specs ([#11][])
|
212
236
|
|
213
237
|
### Removed
|
214
238
|
|
215
|
-
|
239
|
+
- Ruby versions < 2.7 no longer supported ([#8][])
|
216
240
|
|
217
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/
|
241
|
+
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta4...main
|
242
|
+
[1.0.0.beta4]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta3...v1.0.0.beta4
|
243
|
+
[1.0.0.beta3]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta2...v1.0.0.beta3
|
218
244
|
[1.0.0.beta2]: https://github.com/DataDog/datadog-ci-rb/compare/v1.0.0.beta1...v1.0.0.beta2
|
219
245
|
[1.0.0.beta1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.3...v1.0.0.beta1
|
220
246
|
[0.8.3]: https://github.com/DataDog/datadog-ci-rb/compare/v0.8.2...v0.8.3
|
@@ -304,3 +330,11 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
304
330
|
[#158]: https://github.com/DataDog/datadog-ci-rb/issues/158
|
305
331
|
[#159]: https://github.com/DataDog/datadog-ci-rb/issues/159
|
306
332
|
[#160]: https://github.com/DataDog/datadog-ci-rb/issues/160
|
333
|
+
[#165]: https://github.com/DataDog/datadog-ci-rb/issues/165
|
334
|
+
[#166]: https://github.com/DataDog/datadog-ci-rb/issues/166
|
335
|
+
[#167]: https://github.com/DataDog/datadog-ci-rb/issues/167
|
336
|
+
[#168]: https://github.com/DataDog/datadog-ci-rb/issues/168
|
337
|
+
[#172]: https://github.com/DataDog/datadog-ci-rb/issues/172
|
338
|
+
[#173]: https://github.com/DataDog/datadog-ci-rb/issues/173
|
339
|
+
[#174]: https://github.com/DataDog/datadog-ci-rb/issues/174
|
340
|
+
[#175]: https://github.com/DataDog/datadog-ci-rb/issues/175
|
@@ -5,10 +5,35 @@
|
|
5
5
|
#define DD_COV_TARGET_FILES 1
|
6
6
|
#define DD_COV_TARGET_LINES 2
|
7
7
|
|
8
|
+
static int is_prefix(VALUE prefix, const char *str)
|
9
|
+
{
|
10
|
+
if (prefix == Qnil)
|
11
|
+
{
|
12
|
+
return 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
const char *c_prefix = RSTRING_PTR(prefix);
|
16
|
+
if (c_prefix == NULL)
|
17
|
+
{
|
18
|
+
return 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
long prefix_len = RSTRING_LEN(prefix);
|
22
|
+
if (strncmp(c_prefix, str, prefix_len) == 0)
|
23
|
+
{
|
24
|
+
return 1;
|
25
|
+
}
|
26
|
+
else
|
27
|
+
{
|
28
|
+
return 0;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
8
32
|
// Data structure
|
9
33
|
struct dd_cov_data
|
10
34
|
{
|
11
35
|
VALUE root;
|
36
|
+
VALUE ignored_path;
|
12
37
|
int mode;
|
13
38
|
VALUE coverage;
|
14
39
|
};
|
@@ -18,6 +43,7 @@ static void dd_cov_mark(void *ptr)
|
|
18
43
|
struct dd_cov_data *dd_cov_data = ptr;
|
19
44
|
rb_gc_mark_movable(dd_cov_data->coverage);
|
20
45
|
rb_gc_mark_movable(dd_cov_data->root);
|
46
|
+
rb_gc_mark_movable(dd_cov_data->ignored_path);
|
21
47
|
}
|
22
48
|
|
23
49
|
static void dd_cov_free(void *ptr)
|
@@ -32,6 +58,7 @@ static void dd_cov_compact(void *ptr)
|
|
32
58
|
struct dd_cov_data *dd_cov_data = ptr;
|
33
59
|
dd_cov_data->coverage = rb_gc_location(dd_cov_data->coverage);
|
34
60
|
dd_cov_data->root = rb_gc_location(dd_cov_data->root);
|
61
|
+
dd_cov_data->ignored_path = rb_gc_location(dd_cov_data->ignored_path);
|
35
62
|
}
|
36
63
|
|
37
64
|
const rb_data_type_t dd_cov_data_type = {
|
@@ -49,6 +76,7 @@ static VALUE dd_cov_allocate(VALUE klass)
|
|
49
76
|
VALUE obj = TypedData_Make_Struct(klass, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
|
50
77
|
dd_cov_data->coverage = rb_hash_new();
|
51
78
|
dd_cov_data->root = Qnil;
|
79
|
+
dd_cov_data->ignored_path = Qnil;
|
52
80
|
dd_cov_data->mode = DD_COV_TARGET_FILES;
|
53
81
|
return obj;
|
54
82
|
}
|
@@ -66,6 +94,8 @@ static VALUE dd_cov_initialize(int argc, VALUE *argv, VALUE self)
|
|
66
94
|
rb_raise(rb_eArgError, "root is required");
|
67
95
|
}
|
68
96
|
|
97
|
+
VALUE rb_ignored_path = rb_hash_lookup(opt, ID2SYM(rb_intern("ignored_path")));
|
98
|
+
|
69
99
|
VALUE rb_mode = rb_hash_lookup(opt, ID2SYM(rb_intern("mode")));
|
70
100
|
if (!RTEST(rb_mode) || rb_mode == ID2SYM(rb_intern("files")))
|
71
101
|
{
|
@@ -84,6 +114,7 @@ static VALUE dd_cov_initialize(int argc, VALUE *argv, VALUE self)
|
|
84
114
|
TypedData_Get_Struct(self, struct dd_cov_data, &dd_cov_data_type, dd_cov_data);
|
85
115
|
|
86
116
|
dd_cov_data->root = rb_root;
|
117
|
+
dd_cov_data->ignored_path = rb_ignored_path;
|
87
118
|
dd_cov_data->mode = mode;
|
88
119
|
|
89
120
|
return Qnil;
|
@@ -100,20 +131,15 @@ static void dd_cov_update_line_coverage(rb_event_flag_t event, VALUE data, VALUE
|
|
100
131
|
return;
|
101
132
|
}
|
102
133
|
|
103
|
-
if
|
134
|
+
// if given filename is not located under the root, we skip it
|
135
|
+
if (is_prefix(dd_cov_data->root, filename) == 0)
|
104
136
|
{
|
105
137
|
return;
|
106
138
|
}
|
107
139
|
|
108
|
-
|
109
|
-
|
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)
|
140
|
+
// if ignored_path is provided and given filename is located under the ignored_path, we skip it too
|
141
|
+
// this is useful for ignoring bundled gems location
|
142
|
+
if (RTEST(dd_cov_data->ignored_path) && is_prefix(dd_cov_data->ignored_path, filename) == 1)
|
117
143
|
{
|
118
144
|
return;
|
119
145
|
}
|
@@ -13,6 +13,7 @@ require_relative "../test_visibility/serializers/factories/test_suite_level"
|
|
13
13
|
require_relative "../test_visibility/transport"
|
14
14
|
require_relative "../transport/api/builder"
|
15
15
|
require_relative "../transport/remote_settings_api"
|
16
|
+
require_relative "../utils/test_run"
|
16
17
|
require_relative "../worker"
|
17
18
|
|
18
19
|
module Datadog
|
@@ -42,6 +43,16 @@ module Datadog
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def activate_ci!(settings)
|
46
|
+
unless settings.tracing.enabled
|
47
|
+
Datadog.logger.error(
|
48
|
+
"CI visibility requires tracing to be enabled. Disabling CI visibility. " \
|
49
|
+
"NOTE: if you didn't disable tracing intentionally, add `c.tracing.enabled = true` to " \
|
50
|
+
"your Datadog.configure block."
|
51
|
+
)
|
52
|
+
settings.ci.enabled = false
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
45
56
|
# Configure ddtrace library for CI visibility mode
|
46
57
|
# Deactivate telemetry
|
47
58
|
settings.telemetry.enabled = false
|
@@ -59,6 +70,9 @@ module Datadog
|
|
59
70
|
# Choose user defined TraceFlush or default to CI TraceFlush
|
60
71
|
settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new
|
61
72
|
|
73
|
+
# startup logs are useless for CI visibility and create noise
|
74
|
+
settings.diagnostics.startup_logs.enabled = false
|
75
|
+
|
62
76
|
# transport creation
|
63
77
|
writer_options = settings.ci.writer_options
|
64
78
|
coverage_writer = nil
|
@@ -90,16 +104,21 @@ module Datadog
|
|
90
104
|
|
91
105
|
settings.tracing.test_mode.writer_options = writer_options
|
92
106
|
|
107
|
+
custom_configuration_tags = Utils::TestRun.custom_configuration(settings.tags)
|
108
|
+
|
93
109
|
remote_settings_api = Transport::RemoteSettingsApi.new(
|
94
110
|
api: test_visibility_api,
|
95
|
-
dd_env: settings.env
|
111
|
+
dd_env: settings.env,
|
112
|
+
config_tags: custom_configuration_tags
|
96
113
|
)
|
97
114
|
|
98
115
|
itr = ITR::Runner.new(
|
99
116
|
api: test_visibility_api,
|
100
117
|
dd_env: settings.env,
|
118
|
+
config_tags: custom_configuration_tags,
|
101
119
|
coverage_writer: coverage_writer,
|
102
|
-
enabled: settings.ci.enabled && settings.ci.itr_enabled
|
120
|
+
enabled: settings.ci.enabled && settings.ci.itr_enabled,
|
121
|
+
bundle_location: settings.ci.itr_code_coverage_excluded_bundle_path
|
103
122
|
)
|
104
123
|
|
105
124
|
git_tree_uploader = Git::TreeUploader.new(api: test_visibility_api)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../ext/settings"
|
4
|
+
require_relative "../utils/bundle"
|
4
5
|
|
5
6
|
module Datadog
|
6
7
|
module CI
|
@@ -67,6 +68,14 @@ module Datadog
|
|
67
68
|
o.default true
|
68
69
|
end
|
69
70
|
|
71
|
+
option :itr_code_coverage_excluded_bundle_path do |o|
|
72
|
+
o.type :string, nilable: true
|
73
|
+
o.env CI::Ext::Settings::ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH
|
74
|
+
o.default do
|
75
|
+
Datadog::CI::Utils::Bundle.location
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
70
79
|
define_method(:instrument) do |integration_name, options = {}, &block|
|
71
80
|
return unless enabled
|
72
81
|
|
@@ -89,9 +98,6 @@ module Datadog
|
|
89
98
|
fetch_integration(integration_name).configuration
|
90
99
|
end
|
91
100
|
|
92
|
-
# @deprecated Will be removed on datadog-ci-rb 1.0.
|
93
|
-
alias_method :use, :instrument
|
94
|
-
|
95
101
|
option :trace_flush
|
96
102
|
|
97
103
|
option :writer_options do |o|
|
@@ -70,12 +70,15 @@ module Datadog
|
|
70
70
|
|
71
71
|
start_test_suite(test_suite_name) unless same_test_suite_as_current?(test_suite_name)
|
72
72
|
|
73
|
-
CI.start_test(
|
73
|
+
test_span = CI.start_test(
|
74
74
|
event.test_case.name,
|
75
75
|
test_suite_name,
|
76
76
|
tags: tags,
|
77
77
|
service: configuration[:service_name]
|
78
78
|
)
|
79
|
+
if event.test_case.match_tags?("@#{CI::Ext::Test::ITR_UNSKIPPABLE_OPTION}")
|
80
|
+
test_span&.itr_unskippable!
|
81
|
+
end
|
79
82
|
end
|
80
83
|
|
81
84
|
def on_test_case_finished(event)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "runner"
|
4
4
|
require_relative "reporter"
|
5
|
-
require_relative "
|
5
|
+
require_relative "test"
|
6
6
|
require_relative "runnable"
|
7
7
|
|
8
8
|
module Datadog
|
@@ -25,7 +25,7 @@ module Datadog
|
|
25
25
|
# test suites (when not executed concurrently)
|
26
26
|
::Minitest::Runnable.include(Runnable)
|
27
27
|
# tests; test suites (when executed concurrently)
|
28
|
-
::Minitest::Test.include(
|
28
|
+
::Minitest::Test.include(Test)
|
29
29
|
# test session finish
|
30
30
|
::Minitest::CompositeReporter.include(Reporter)
|
31
31
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../ext/test"
|
4
|
+
require_relative "../../git/local_repository"
|
5
|
+
require_relative "ext"
|
6
|
+
require_relative "helpers"
|
7
|
+
|
8
|
+
module Datadog
|
9
|
+
module CI
|
10
|
+
module Contrib
|
11
|
+
module Minitest
|
12
|
+
# Lifecycle hooks to instrument Minitest::Test
|
13
|
+
module Test
|
14
|
+
def self.included(base)
|
15
|
+
base.prepend(InstanceMethods)
|
16
|
+
base.singleton_class.prepend(ClassMethods)
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def before_setup
|
21
|
+
super
|
22
|
+
return unless datadog_configuration[:enabled]
|
23
|
+
|
24
|
+
test_suite_name = Helpers.test_suite_name(self.class, name)
|
25
|
+
if Helpers.parallel?(self.class)
|
26
|
+
test_suite_name = "#{test_suite_name} (#{name} concurrently)"
|
27
|
+
|
28
|
+
# for parallel execution we need to start a new test suite for each test
|
29
|
+
CI.start_test_suite(test_suite_name)
|
30
|
+
end
|
31
|
+
|
32
|
+
source_file, line_number = method(name).source_location
|
33
|
+
|
34
|
+
test_span = CI.start_test(
|
35
|
+
name,
|
36
|
+
test_suite_name,
|
37
|
+
tags: {
|
38
|
+
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
39
|
+
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s,
|
40
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(source_file),
|
41
|
+
CI::Ext::Test::TAG_SOURCE_START => line_number.to_s
|
42
|
+
},
|
43
|
+
service: datadog_configuration[:service_name]
|
44
|
+
)
|
45
|
+
test_span&.itr_unskippable! if self.class.dd_suite_unskippable? || self.class.dd_test_unskippable?(name)
|
46
|
+
skip(CI::Ext::Test::ITR_TEST_SKIP_REASON) if test_span&.skipped_by_itr?
|
47
|
+
end
|
48
|
+
|
49
|
+
def after_teardown
|
50
|
+
test_span = CI.active_test
|
51
|
+
return super unless test_span
|
52
|
+
|
53
|
+
finish_with_result(test_span, result_code)
|
54
|
+
if Helpers.parallel?(self.class)
|
55
|
+
finish_with_result(test_span.test_suite, result_code)
|
56
|
+
end
|
57
|
+
|
58
|
+
super
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def finish_with_result(span, result_code)
|
64
|
+
return unless span
|
65
|
+
|
66
|
+
case result_code
|
67
|
+
when "."
|
68
|
+
span.passed!
|
69
|
+
when "E", "F"
|
70
|
+
span.failed!(exception: failure)
|
71
|
+
when "S"
|
72
|
+
span.skipped!(reason: failure.message)
|
73
|
+
end
|
74
|
+
span.finish
|
75
|
+
end
|
76
|
+
|
77
|
+
def datadog_configuration
|
78
|
+
Datadog.configuration.ci[:minitest]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module ClassMethods
|
83
|
+
def datadog_itr_unskippable(*args)
|
84
|
+
if args.nil? || args.empty?
|
85
|
+
@datadog_itr_unskippable_suite = true
|
86
|
+
else
|
87
|
+
@datadog_itr_unskippable_tests = args
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def dd_suite_unskippable?
|
92
|
+
@datadog_itr_unskippable_suite
|
93
|
+
end
|
94
|
+
|
95
|
+
def dd_test_unskippable?(test_name)
|
96
|
+
return false unless @datadog_itr_unskippable_tests
|
97
|
+
|
98
|
+
@datadog_itr_unskippable_tests.include?(test_name)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -50,6 +50,8 @@ module Datadog
|
|
50
50
|
},
|
51
51
|
service: datadog_configuration[:service_name]
|
52
52
|
) do |test_span|
|
53
|
+
test_span&.itr_unskippable! if metadata[CI::Ext::Test::ITR_UNSKIPPABLE_OPTION]
|
54
|
+
|
53
55
|
metadata[:skip] = CI::Ext::Test::ITR_TEST_SKIP_REASON if test_span&.skipped_by_itr?
|
54
56
|
|
55
57
|
result = super
|