datadog-ci 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 651794a9813c4b1b10909b0de41e4d25f90b95736815894f83356e03f9fa86d5
|
4
|
+
data.tar.gz: 1f8c32423bb4527c7faf6232acf842fcc6c3db404baf1e836e0d57bbd57a7d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c81e9f43de5457aa57aacfbacf2d432c47e0e8f9de68477d45ea9e20da3773687a0d85e79df51e73ce2c133c6e8432c9f8f9a83c35c65d0fe0f587e58968857
|
7
|
+
data.tar.gz: c37907789e0c3f0bbd9cc283d245f8be60d90c0c888bd707db7119b0e36375d3ae10227a7d08d43d448d2af6d42e339ffd4bdfce479028aef1e3b3de1549870b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.10.0] - 2024-12-05
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* Skip before(:all) context hooks when all examples are skipped ([#262][])
|
8
|
+
|
3
9
|
## [1.9.0] - 2024-11-26
|
4
10
|
|
5
11
|
### Added
|
@@ -362,7 +368,8 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
362
368
|
|
363
369
|
- Ruby versions < 2.7 no longer supported ([#8][])
|
364
370
|
|
365
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.
|
371
|
+
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.10.0...main
|
372
|
+
[1.10.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.9.0...v1.10.0
|
366
373
|
[1.9.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.1...v1.9.0
|
367
374
|
[1.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.0...v1.8.1
|
368
375
|
[1.8.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.7.0...v1.8.0
|
@@ -521,4 +528,5 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
521
528
|
[#244]: https://github.com/DataDog/datadog-ci-rb/issues/244
|
522
529
|
[#248]: https://github.com/DataDog/datadog-ci-rb/issues/248
|
523
530
|
[#250]: https://github.com/DataDog/datadog-ci-rb/issues/250
|
524
|
-
[#259]: https://github.com/DataDog/datadog-ci-rb/issues/259
|
531
|
+
[#259]: https://github.com/DataDog/datadog-ci-rb/issues/259
|
532
|
+
[#262]: https://github.com/DataDog/datadog-ci-rb/issues/262
|
@@ -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
|
-
|
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
|
-
|
47
|
-
|
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 =>
|
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
|
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
|
-
|
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
|
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
|
data/lib/datadog/ci/test.rb
CHANGED
@@ -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?(
|
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?(
|
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(
|
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
|
-
|
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
|
|
data/lib/datadog/ci/version.rb
CHANGED
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.
|
4
|
+
version: 1.10.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
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: datadog
|