datadog-ci 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +45 -2
- data/README.md +1 -1
- data/lib/datadog/ci/codeowners/matcher.rb +102 -0
- data/lib/datadog/ci/codeowners/parser.rb +42 -0
- data/lib/datadog/ci/codeowners/rule.rb +33 -0
- data/lib/datadog/ci/concurrent_span.rb +2 -1
- data/lib/datadog/ci/configuration/components.rb +5 -5
- data/lib/datadog/ci/configuration/settings.rb +15 -0
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +4 -1
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +68 -37
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -1
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +4 -1
- data/lib/datadog/ci/contrib/minitest/helpers.rb +2 -1
- data/lib/datadog/ci/contrib/minitest/hooks.rb +9 -22
- data/lib/datadog/ci/contrib/minitest/patcher.rb +9 -6
- data/lib/datadog/ci/contrib/minitest/reporter.rb +50 -0
- data/lib/datadog/ci/contrib/minitest/runnable.rb +1 -1
- data/lib/datadog/ci/contrib/minitest/runner.rb +41 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +4 -1
- data/lib/datadog/ci/contrib/rspec/example.rb +55 -14
- data/lib/datadog/ci/contrib/rspec/example_group.rb +12 -7
- data/lib/datadog/ci/contrib/rspec/patcher.rb +10 -1
- data/lib/datadog/ci/contrib/rspec/runner.rb +7 -7
- data/lib/datadog/ci/ext/app_types.rb +2 -0
- data/lib/datadog/ci/ext/environment/providers/local_git.rb +8 -29
- data/lib/datadog/ci/ext/settings.rb +1 -0
- data/lib/datadog/ci/ext/test.rb +19 -8
- data/lib/datadog/ci/span.rb +9 -2
- data/lib/datadog/ci/test.rb +67 -2
- data/lib/datadog/ci/test_module.rb +1 -1
- data/lib/datadog/ci/test_session.rb +2 -2
- data/lib/datadog/ci/test_suite.rb +53 -2
- data/lib/datadog/ci/test_visibility/context/local.rb +3 -9
- data/lib/datadog/ci/test_visibility/null_recorder.rb +2 -22
- data/lib/datadog/ci/test_visibility/recorder.rb +25 -19
- data/lib/datadog/ci/test_visibility/serializers/base.rb +6 -5
- data/lib/datadog/ci/test_visibility/serializers/span.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/test_module.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/test_session.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/test_suite.rb +1 -1
- data/lib/datadog/ci/test_visibility/serializers/test_v1.rb +1 -1
- data/lib/datadog/ci/utils/configuration.rb +15 -0
- data/lib/datadog/ci/utils/git.rb +70 -0
- data/lib/datadog/ci/version.rb +1 -1
- data/lib/datadog/ci.rb +40 -56
- metadata +9 -89
- data/lib/datadog/ci/contrib/minitest/plugin.rb +0 -73
- data/lib/datadog/ci/null_span.rb +0 -63
- data/sig/datadog/ci/concurrent_span.rbs +0 -23
- data/sig/datadog/ci/configuration/components.rbs +0 -21
- data/sig/datadog/ci/configuration/extensions.rbs +0 -9
- data/sig/datadog/ci/configuration/settings.rbs +0 -16
- data/sig/datadog/ci/contrib/cucumber/configuration/settings.rbs +0 -12
- data/sig/datadog/ci/contrib/cucumber/ext.rbs +0 -21
- data/sig/datadog/ci/contrib/cucumber/formatter.rbs +0 -48
- data/sig/datadog/ci/contrib/cucumber/instrumentation.rbs +0 -16
- data/sig/datadog/ci/contrib/cucumber/integration.rbs +0 -26
- data/sig/datadog/ci/contrib/cucumber/patcher.rbs +0 -15
- data/sig/datadog/ci/contrib/integration.rbs +0 -44
- data/sig/datadog/ci/contrib/minitest/configuration/settings.rbs +0 -12
- data/sig/datadog/ci/contrib/minitest/ext.rbs +0 -19
- data/sig/datadog/ci/contrib/minitest/helpers.rbs +0 -13
- data/sig/datadog/ci/contrib/minitest/hooks.rbs +0 -27
- data/sig/datadog/ci/contrib/minitest/integration.rbs +0 -26
- data/sig/datadog/ci/contrib/minitest/patcher.rbs +0 -15
- data/sig/datadog/ci/contrib/minitest/plugin.rbs +0 -31
- data/sig/datadog/ci/contrib/minitest/runnable.rbs +0 -24
- data/sig/datadog/ci/contrib/rspec/configuration/settings.rbs +0 -12
- data/sig/datadog/ci/contrib/rspec/example.rbs +0 -20
- data/sig/datadog/ci/contrib/rspec/example_group.rbs +0 -21
- data/sig/datadog/ci/contrib/rspec/ext.rbs +0 -17
- data/sig/datadog/ci/contrib/rspec/integration.rbs +0 -26
- data/sig/datadog/ci/contrib/rspec/patcher.rbs +0 -15
- data/sig/datadog/ci/contrib/rspec/runner.rbs +0 -21
- data/sig/datadog/ci/contrib/settings.rbs +0 -25
- data/sig/datadog/ci/ext/app_types.rbs +0 -14
- data/sig/datadog/ci/ext/environment/extractor.rbs +0 -25
- data/sig/datadog/ci/ext/environment/providers/appveyor.rbs +0 -48
- data/sig/datadog/ci/ext/environment/providers/aws_code_pipeline.rbs +0 -19
- data/sig/datadog/ci/ext/environment/providers/azure.rbs +0 -56
- data/sig/datadog/ci/ext/environment/providers/base.rbs +0 -71
- data/sig/datadog/ci/ext/environment/providers/bitbucket.rbs +0 -37
- data/sig/datadog/ci/ext/environment/providers/bitrise.rbs +0 -41
- data/sig/datadog/ci/ext/environment/providers/buddy.rbs +0 -37
- data/sig/datadog/ci/ext/environment/providers/buildkite.rbs +0 -45
- data/sig/datadog/ci/ext/environment/providers/circleci.rbs +0 -41
- data/sig/datadog/ci/ext/environment/providers/codefresh.rbs +0 -25
- data/sig/datadog/ci/ext/environment/providers/github_actions.rbs +0 -42
- data/sig/datadog/ci/ext/environment/providers/gitlab.rbs +0 -57
- data/sig/datadog/ci/ext/environment/providers/jenkins.rbs +0 -35
- data/sig/datadog/ci/ext/environment/providers/local_git.rbs +0 -66
- data/sig/datadog/ci/ext/environment/providers/teamcity.rbs +0 -17
- data/sig/datadog/ci/ext/environment/providers/travis.rbs +0 -35
- data/sig/datadog/ci/ext/environment/providers/user_defined_tags.rbs +0 -33
- data/sig/datadog/ci/ext/environment/providers.rbs +0 -13
- data/sig/datadog/ci/ext/environment.rbs +0 -44
- data/sig/datadog/ci/ext/git.rbs +0 -53
- data/sig/datadog/ci/ext/settings.rbs +0 -14
- data/sig/datadog/ci/ext/test.rbs +0 -60
- data/sig/datadog/ci/ext/transport.rbs +0 -29
- data/sig/datadog/ci/null_span.rbs +0 -37
- data/sig/datadog/ci/span.rbs +0 -47
- data/sig/datadog/ci/test.rbs +0 -12
- data/sig/datadog/ci/test_module.rbs +0 -6
- data/sig/datadog/ci/test_session.rbs +0 -9
- data/sig/datadog/ci/test_suite.rbs +0 -6
- data/sig/datadog/ci/test_visibility/context/global.rbs +0 -39
- data/sig/datadog/ci/test_visibility/context/local.rbs +0 -23
- data/sig/datadog/ci/test_visibility/flush.rbs +0 -17
- data/sig/datadog/ci/test_visibility/null_recorder.rbs +0 -45
- data/sig/datadog/ci/test_visibility/recorder.rbs +0 -85
- data/sig/datadog/ci/test_visibility/serializers/base.rbs +0 -94
- data/sig/datadog/ci/test_visibility/serializers/factories/test_level.rbs +0 -13
- data/sig/datadog/ci/test_visibility/serializers/factories/test_suite_level.rbs +0 -13
- data/sig/datadog/ci/test_visibility/serializers/span.rbs +0 -18
- data/sig/datadog/ci/test_visibility/serializers/test_module.rbs +0 -26
- data/sig/datadog/ci/test_visibility/serializers/test_session.rbs +0 -26
- data/sig/datadog/ci/test_visibility/serializers/test_suite.rbs +0 -26
- data/sig/datadog/ci/test_visibility/serializers/test_v1.rbs +0 -23
- data/sig/datadog/ci/test_visibility/serializers/test_v2.rbs +0 -25
- data/sig/datadog/ci/test_visibility/transport.rbs +0 -35
- data/sig/datadog/ci/transport/api/base.rbs +0 -21
- data/sig/datadog/ci/transport/api/builder.rbs +0 -12
- data/sig/datadog/ci/transport/api/ci_test_cycle.rbs +0 -21
- data/sig/datadog/ci/transport/api/evp_proxy.rbs +0 -19
- data/sig/datadog/ci/transport/gzip.rbs +0 -9
- data/sig/datadog/ci/transport/http.rbs +0 -36
- data/sig/datadog/ci/utils/git.rbs +0 -11
- data/sig/datadog/ci/utils/test_run.rbs +0 -11
- data/sig/datadog/ci/utils/url.rbs +0 -9
- data/sig/datadog/ci/version.rbs +0 -16
- data/sig/datadog/ci.rbs +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14828e8c64b8eeb9c04d4ae2563e568b3b920b587f8e97e628896b143219daf0
|
4
|
+
data.tar.gz: b538d180acd0c18e1d8070adfdcd9f44dad65331048619de40db04cd876dfe01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60f8fda5f530404027669902b194c7e056af834c882adbc2b7d350eb62f7f75c2d63dae23bf6e98a8bebea0cc8ec34d4f5416fe667d1c30dff1fdb7ebb42854d
|
7
|
+
data.tar.gz: 1b2ad405dee8a1dd2ce24c3d5738ddcbc751f85d5aa5c29a287b614dcfc0a4764230a3b53e59967247fd0f64711fd81fc3863e49895098e7664aa81a3bf1b8e6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.7.0] - 2024-01-26
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* Source code integration ([#95][])
|
8
|
+
* CODEOWNERS support ([#98][])
|
9
|
+
* Cucumber scenarios with examples are treated as parametrized tests ([#100][])
|
10
|
+
* Deduplicate dynamically generated RSpec examples using test.parameters ([#101][])
|
11
|
+
* Repository name is used as default test service name ([#104][])
|
12
|
+
* Cucumber v9 support ([#99][])
|
13
|
+
* ci-queue runner support for minitest ([#110][])
|
14
|
+
* ci-queue support for rspec ([#112][])
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
* do not publish sig folder when publishing this gem to prevent steep errors in client applications ([#114][])
|
19
|
+
* minitest: fix rails parallel test runner ([#115][])
|
20
|
+
* Test suites and tests skipped by frameworks are correctly reported as skipped to Datadog ([#113][])
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
* Enable test suite level visibility by default (with killswitch) ([#109][])
|
25
|
+
* Test suite names are more human-readable now ([#105][])
|
26
|
+
* Remove span_type method in tracer-related models ([#107][])
|
27
|
+
* Manual tracing API: convert type parameter to keyword in Datadog::CI.trace, remove internal-only methods from public API ([#108][])
|
28
|
+
|
3
29
|
## [0.6.0] - 2024-01-03
|
4
30
|
|
5
31
|
### Added
|
@@ -124,7 +150,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
124
150
|
|
125
151
|
* Ruby versions < 2.7 no longer supported ([#8][])
|
126
152
|
|
127
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.
|
153
|
+
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.7.0...main
|
154
|
+
[0.7.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.6.0...v0.7.0
|
155
|
+
[0.6.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.1...v0.6.0
|
128
156
|
[0.5.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.0...v0.5.1
|
129
157
|
[0.5.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.1...v0.5.0
|
130
158
|
[0.4.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.0...v0.4.1
|
@@ -169,4 +197,19 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
169
197
|
[#87]: https://github.com/DataDog/datadog-ci-rb/issues/87
|
170
198
|
[#89]: https://github.com/DataDog/datadog-ci-rb/issues/89
|
171
199
|
[#90]: https://github.com/DataDog/datadog-ci-rb/issues/90
|
172
|
-
[#92]: https://github.com/DataDog/datadog-ci-rb/issues/92
|
200
|
+
[#92]: https://github.com/DataDog/datadog-ci-rb/issues/92
|
201
|
+
[#95]: https://github.com/DataDog/datadog-ci-rb/issues/95
|
202
|
+
[#98]: https://github.com/DataDog/datadog-ci-rb/issues/98
|
203
|
+
[#99]: https://github.com/DataDog/datadog-ci-rb/issues/99
|
204
|
+
[#100]: https://github.com/DataDog/datadog-ci-rb/issues/100
|
205
|
+
[#101]: https://github.com/DataDog/datadog-ci-rb/issues/101
|
206
|
+
[#104]: https://github.com/DataDog/datadog-ci-rb/issues/104
|
207
|
+
[#105]: https://github.com/DataDog/datadog-ci-rb/issues/105
|
208
|
+
[#107]: https://github.com/DataDog/datadog-ci-rb/issues/107
|
209
|
+
[#108]: https://github.com/DataDog/datadog-ci-rb/issues/108
|
210
|
+
[#109]: https://github.com/DataDog/datadog-ci-rb/issues/109
|
211
|
+
[#110]: https://github.com/DataDog/datadog-ci-rb/issues/110
|
212
|
+
[#112]: https://github.com/DataDog/datadog-ci-rb/issues/112
|
213
|
+
[#113]: https://github.com/DataDog/datadog-ci-rb/issues/113
|
214
|
+
[#114]: https://github.com/DataDog/datadog-ci-rb/issues/114
|
215
|
+
[#115]: https://github.com/DataDog/datadog-ci-rb/issues/115
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![CircleCI](https://dl.circleci.com/status-badge/img/gh/DataDog/datadog-ci-rb/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/DataDog/datadog-ci-rb/tree/main)
|
7
7
|
|
8
8
|
Datadog's Ruby Library for instrumenting your test and continuous integration pipeline.
|
9
|
-
Learn more on our [official website](https://docs.datadoghq.com/
|
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
11
|
> [!IMPORTANT]
|
12
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.
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "rule"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Codeowners
|
8
|
+
# Responsible for matching a test source file path to a list of owners
|
9
|
+
class Matcher
|
10
|
+
def initialize(codeowners_file_path)
|
11
|
+
@rules = parse(codeowners_file_path)
|
12
|
+
@rules.reverse!
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_owners(file_path)
|
16
|
+
# treat all file paths that we check as absolute from the repository root
|
17
|
+
file_path = "/#{file_path}" unless file_path.start_with?("/")
|
18
|
+
|
19
|
+
Datadog.logger.debug { "Matching file path #{file_path} to CODEOWNERS rules" }
|
20
|
+
|
21
|
+
@rules.each do |rule|
|
22
|
+
if rule.match?(file_path)
|
23
|
+
Datadog.logger.debug { "Matched rule [#{rule.pattern}] with owners #{rule.owners}" }
|
24
|
+
return rule.owners
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Datadog.logger.debug { "CODEOWNERS rule not matched" }
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def parse(codeowners_file_path)
|
35
|
+
unless File.exist?(codeowners_file_path)
|
36
|
+
Datadog.logger.debug { "CODEOWNERS file not found at #{codeowners_file_path}" }
|
37
|
+
return []
|
38
|
+
end
|
39
|
+
|
40
|
+
result = []
|
41
|
+
section_default_owners = []
|
42
|
+
|
43
|
+
File.open(codeowners_file_path, "r") do |f|
|
44
|
+
f.each_line do |line|
|
45
|
+
line.strip!
|
46
|
+
|
47
|
+
next if line.empty?
|
48
|
+
next if comment?(line)
|
49
|
+
|
50
|
+
pattern, *line_owners = line.strip.split(/\s+/)
|
51
|
+
next if pattern.nil? || pattern.empty?
|
52
|
+
|
53
|
+
# if the current line starts with section record the default owners for this section
|
54
|
+
if section?(pattern)
|
55
|
+
section_default_owners = line_owners
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
pattern = expand_pattern(pattern)
|
60
|
+
# if the current line doesn't have any owners then use the default owners for this section
|
61
|
+
if line_owners.empty? && !section_default_owners.empty?
|
62
|
+
line_owners = section_default_owners
|
63
|
+
end
|
64
|
+
|
65
|
+
result << Rule.new(pattern, line_owners)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
result
|
70
|
+
rescue => e
|
71
|
+
Datadog.logger.warn(
|
72
|
+
"Failed to parse codeowners file at #{codeowners_file_path}: " \
|
73
|
+
"#{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
74
|
+
)
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
def comment?(line)
|
79
|
+
line.start_with?("#")
|
80
|
+
end
|
81
|
+
|
82
|
+
def section?(line)
|
83
|
+
line.start_with?("[", "^[") && line.end_with?("]")
|
84
|
+
end
|
85
|
+
|
86
|
+
def expand_pattern(pattern)
|
87
|
+
return pattern if pattern == "*"
|
88
|
+
|
89
|
+
# if pattern ends with a slash then it matches everything deeply nested in this directory
|
90
|
+
pattern += "**" if pattern.end_with?(::File::SEPARATOR)
|
91
|
+
|
92
|
+
# if pattern doesn't start with a slash then it matches anywhere in the repository
|
93
|
+
if !pattern.start_with?(::File::SEPARATOR, "**#{::File::SEPARATOR}", "*#{::File::SEPARATOR}")
|
94
|
+
pattern = "**#{::File::SEPARATOR}#{pattern}"
|
95
|
+
end
|
96
|
+
|
97
|
+
pattern
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "matcher"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Codeowners
|
8
|
+
# Responsible for parsing a CODEOWNERS file
|
9
|
+
class Parser
|
10
|
+
DEFAULT_LOCATION = "CODEOWNERS"
|
11
|
+
POSSIBLE_CODEOWNERS_LOCATIONS = [
|
12
|
+
"CODEOWNERS",
|
13
|
+
".github/CODEOWNERS",
|
14
|
+
".gitlab/CODEOWNERS",
|
15
|
+
"docs/CODEOWNERS"
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
def initialize(root_file_path)
|
19
|
+
@root_file_path = root_file_path || Dir.pwd
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse
|
23
|
+
default_path = File.join(@root_file_path, DEFAULT_LOCATION)
|
24
|
+
# We are using the first codeowners file that we find or
|
25
|
+
# default location if nothing is found
|
26
|
+
#
|
27
|
+
# Matcher handles it internally and creates a class with
|
28
|
+
# an empty list of rules if the file is not found
|
29
|
+
codeowners_file_path = POSSIBLE_CODEOWNERS_LOCATIONS.map do |codeowners_location|
|
30
|
+
File.join(@root_file_path, codeowners_location)
|
31
|
+
end.find do |path|
|
32
|
+
File.exist?(path)
|
33
|
+
end || default_path
|
34
|
+
|
35
|
+
::Datadog.logger.debug { "Using CODEOWNERS file from: #{codeowners_file_path}" }
|
36
|
+
|
37
|
+
Matcher.new(codeowners_file_path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Datadog
|
2
|
+
module CI
|
3
|
+
module Codeowners
|
4
|
+
class Rule
|
5
|
+
attr_reader :pattern, :owners
|
6
|
+
|
7
|
+
def initialize(pattern, owners)
|
8
|
+
@pattern = pattern
|
9
|
+
@owners = owners
|
10
|
+
end
|
11
|
+
|
12
|
+
def match?(file_path)
|
13
|
+
res = false
|
14
|
+
# if pattern does not end with a separator or a wildcard, it could be either a directory or a file
|
15
|
+
if !pattern.end_with?(::File::SEPARATOR, "*")
|
16
|
+
directory_pattern = "#{pattern}#{::File::SEPARATOR}*"
|
17
|
+
res ||= File.fnmatch?(directory_pattern, file_path, flags)
|
18
|
+
end
|
19
|
+
|
20
|
+
res ||= File.fnmatch?(pattern, file_path, flags)
|
21
|
+
res
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def flags
|
27
|
+
return ::File::FNM_PATHNAME if pattern.end_with?("#{::File::SEPARATOR}*")
|
28
|
+
0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -41,7 +41,7 @@ module Datadog
|
|
41
41
|
elsif can_use_evp_proxy?(settings, agent_settings)
|
42
42
|
test_visibility_transport = build_evp_proxy_transport(settings, agent_settings)
|
43
43
|
else
|
44
|
-
settings.ci.
|
44
|
+
settings.ci.force_test_level_visibility = true
|
45
45
|
end
|
46
46
|
|
47
47
|
# Deactivate telemetry
|
@@ -72,7 +72,7 @@ module Datadog
|
|
72
72
|
settings.tracing.test_mode.writer_options = writer_options
|
73
73
|
|
74
74
|
@ci_recorder = TestVisibility::Recorder.new(
|
75
|
-
test_suite_level_visibility_enabled: settings.ci.
|
75
|
+
test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
@@ -119,10 +119,10 @@ module Datadog
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def serializers_factory(settings)
|
122
|
-
if settings.ci.
|
123
|
-
Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel
|
124
|
-
else
|
122
|
+
if settings.ci.force_test_level_visibility
|
125
123
|
Datadog::CI::TestVisibility::Serializers::Factories::TestLevel
|
124
|
+
else
|
125
|
+
Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -34,10 +34,25 @@ module Datadog
|
|
34
34
|
o.env CI::Ext::Settings::ENV_AGENTLESS_URL
|
35
35
|
end
|
36
36
|
|
37
|
+
option :force_test_level_visibility do |o|
|
38
|
+
o.type :bool
|
39
|
+
o.env CI::Ext::Settings::ENV_FORCE_TEST_LEVEL_VISIBILITY
|
40
|
+
o.default false
|
41
|
+
end
|
42
|
+
|
37
43
|
option :experimental_test_suite_level_visibility_enabled do |o|
|
38
44
|
o.type :bool
|
39
45
|
o.env CI::Ext::Settings::ENV_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED
|
40
46
|
o.default false
|
47
|
+
o.after_set do |value|
|
48
|
+
if value
|
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. " \
|
51
|
+
"Test suite level visibility is now enabled by default. " \
|
52
|
+
"If you want to disable test suite level visibility set configuration.ci.force_test_level_visibility = true."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
41
56
|
end
|
42
57
|
|
43
58
|
define_method(:instrument) do |integration_name, options = {}, &block|
|
@@ -4,6 +4,7 @@ require "datadog/core"
|
|
4
4
|
|
5
5
|
require_relative "../ext"
|
6
6
|
require_relative "../../settings"
|
7
|
+
require_relative "../../../utils/configuration"
|
7
8
|
|
8
9
|
module Datadog
|
9
10
|
module CI
|
@@ -21,7 +22,9 @@ module Datadog
|
|
21
22
|
|
22
23
|
option :service_name do |o|
|
23
24
|
o.type :string
|
24
|
-
o.default
|
25
|
+
o.default do
|
26
|
+
Utils::Configuration.fetch_service_name(Ext::DEFAULT_SERVICE_NAME)
|
27
|
+
end
|
25
28
|
end
|
26
29
|
|
27
30
|
# @deprecated Will be removed in 1.0
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../ext/test"
|
4
|
+
require_relative "../../utils/git"
|
4
5
|
require_relative "ext"
|
5
6
|
|
6
7
|
module Datadog
|
@@ -13,11 +14,12 @@ module Datadog
|
|
13
14
|
private :config
|
14
15
|
|
15
16
|
def initialize(config)
|
17
|
+
@ast_lookup = ::Cucumber::Formatter::AstLookup.new(config) if defined?(::Cucumber::Formatter::AstLookup)
|
16
18
|
@config = config
|
17
|
-
@failed_tests_count = 0
|
18
19
|
|
19
20
|
@current_test_suite = nil
|
20
|
-
|
21
|
+
|
22
|
+
@failed_tests_count = 0
|
21
23
|
|
22
24
|
bind_events(config)
|
23
25
|
end
|
@@ -35,12 +37,11 @@ module Datadog
|
|
35
37
|
test_session = CI.start_test_session(
|
36
38
|
tags: {
|
37
39
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
38
|
-
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s
|
39
|
-
CI::Ext::Test::TAG_TYPE => CI::Ext::Test::TEST_TYPE
|
40
|
+
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s
|
40
41
|
},
|
41
42
|
service: configuration[:service_name]
|
42
43
|
)
|
43
|
-
CI.start_test_module(test_session.name)
|
44
|
+
CI.start_test_module(test_session.name) if test_session
|
44
45
|
end
|
45
46
|
|
46
47
|
def on_test_run_finished(event)
|
@@ -52,58 +53,71 @@ module Datadog
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def on_test_case_started(event)
|
55
|
-
test_suite_name = event.test_case
|
56
|
+
test_suite_name = test_suite_name(event.test_case)
|
57
|
+
|
58
|
+
tags = {
|
59
|
+
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
60
|
+
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s,
|
61
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Utils::Git.relative_to_root(event.test_case.location.file),
|
62
|
+
CI::Ext::Test::TAG_SOURCE_START => event.test_case.location.line.to_s
|
63
|
+
}
|
56
64
|
|
57
65
|
start_test_suite(test_suite_name) unless same_test_suite_as_current?(test_suite_name)
|
58
66
|
|
59
|
-
CI.start_test(
|
67
|
+
test_span = CI.start_test(
|
60
68
|
event.test_case.name,
|
61
69
|
test_suite_name,
|
62
|
-
tags:
|
63
|
-
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
64
|
-
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s,
|
65
|
-
CI::Ext::Test::TAG_TYPE => CI::Ext::Test::TEST_TYPE
|
66
|
-
},
|
70
|
+
tags: tags,
|
67
71
|
service: configuration[:service_name]
|
68
72
|
)
|
73
|
+
|
74
|
+
if test_span && (parameters = extract_parameters_hash(event.test_case))
|
75
|
+
test_span.set_parameters(parameters)
|
76
|
+
end
|
69
77
|
end
|
70
78
|
|
71
79
|
def on_test_case_finished(event)
|
72
80
|
test_span = CI.active_test
|
73
81
|
return if test_span.nil?
|
74
82
|
|
75
|
-
|
76
|
-
|
77
|
-
#
|
78
|
-
# To track whether test suite failed or passed we need to
|
79
|
-
# track the number of failed tests in the current test suite.
|
80
|
-
if event.result.failed?
|
81
|
-
@failed_tests_count += 1
|
82
|
-
@failed_tests_in_current_test_suite += 1
|
83
|
-
end
|
84
|
-
|
85
|
-
finish_test(test_span, event.result)
|
83
|
+
finish_span(test_span, event.result)
|
84
|
+
@failed_tests_count += 1 if test_span.failed?
|
86
85
|
end
|
87
86
|
|
88
87
|
def on_test_step_started(event)
|
89
|
-
CI.trace(
|
88
|
+
CI.trace(event.test_step.to_s, type: Ext::STEP_SPAN_TYPE)
|
90
89
|
end
|
91
90
|
|
92
91
|
def on_test_step_finished(event)
|
93
|
-
current_step_span = CI.active_span
|
92
|
+
current_step_span = CI.active_span
|
94
93
|
return if current_step_span.nil?
|
95
94
|
|
96
|
-
|
95
|
+
finish_span(current_step_span, event.result)
|
97
96
|
end
|
98
97
|
|
99
98
|
private
|
100
99
|
|
101
|
-
def
|
102
|
-
if
|
103
|
-
|
104
|
-
elsif
|
100
|
+
def test_suite_name(test_case)
|
101
|
+
feature = if test_case.respond_to?(:feature)
|
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
|
106
|
+
end
|
107
|
+
|
108
|
+
if feature
|
109
|
+
"#{feature.name} at #{test_case.location.file}"
|
110
|
+
else
|
111
|
+
test_case.location.file
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def finish_span(span, result)
|
116
|
+
if !result.passed? && result.ok?(@config.strict)
|
117
|
+
span.skipped!(reason: result.message)
|
118
|
+
elsif result.passed?
|
105
119
|
span.passed!
|
106
|
-
|
120
|
+
else
|
107
121
|
span.failed!(exception: result.exception)
|
108
122
|
end
|
109
123
|
span.finish
|
@@ -139,13 +153,9 @@ module Datadog
|
|
139
153
|
test_suite = @current_test_suite
|
140
154
|
return unless test_suite
|
141
155
|
|
142
|
-
if @failed_tests_in_current_test_suite.zero?
|
143
|
-
test_suite.passed!
|
144
|
-
else
|
145
|
-
test_suite.failed!
|
146
|
-
end
|
147
|
-
@failed_tests_in_current_test_suite = 0
|
148
156
|
test_suite.finish
|
157
|
+
|
158
|
+
@current_test_suite = nil
|
149
159
|
end
|
150
160
|
|
151
161
|
def same_test_suite_as_current?(test_suite_name)
|
@@ -155,6 +165,27 @@ module Datadog
|
|
155
165
|
test_suite.name == test_suite_name
|
156
166
|
end
|
157
167
|
|
168
|
+
def extract_parameters_hash(test_case)
|
169
|
+
# not supported in cucumber < 4.0
|
170
|
+
return nil unless @ast_lookup
|
171
|
+
|
172
|
+
scenario_source = @ast_lookup.scenario_source(test_case)
|
173
|
+
|
174
|
+
# cucumber examples are only supported for scenario outlines
|
175
|
+
return nil unless scenario_source.type == :ScenarioOutline
|
176
|
+
|
177
|
+
scenario_source.examples.table_header.cells.map(&:value).zip(
|
178
|
+
scenario_source.row.cells.map(&:value)
|
179
|
+
).to_h
|
180
|
+
rescue => e
|
181
|
+
Datadog.logger.warn do
|
182
|
+
"Unable to extract parameters from test case #{test_case.name}: " \
|
183
|
+
"#{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
184
|
+
end
|
185
|
+
|
186
|
+
nil
|
187
|
+
end
|
188
|
+
|
158
189
|
def configuration
|
159
190
|
Datadog.configuration.ci[:cucumber]
|
160
191
|
end
|
@@ -17,8 +17,9 @@ module Datadog
|
|
17
17
|
attr_reader :datadog_formatter
|
18
18
|
|
19
19
|
def formatters
|
20
|
+
existing_formatters = super
|
20
21
|
@datadog_formatter ||= CI::Contrib::Cucumber::Formatter.new(@configuration)
|
21
|
-
[@datadog_formatter] +
|
22
|
+
[@datadog_formatter] + existing_formatters
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "../ext"
|
4
4
|
require_relative "../../settings"
|
5
|
+
require_relative "../../../utils/configuration"
|
5
6
|
|
6
7
|
module Datadog
|
7
8
|
module CI
|
@@ -19,7 +20,9 @@ module Datadog
|
|
19
20
|
|
20
21
|
option :service_name do |o|
|
21
22
|
o.type :string
|
22
|
-
o.default
|
23
|
+
o.default do
|
24
|
+
Utils::Configuration.fetch_service_name(Ext::DEFAULT_SERVICE_NAME)
|
25
|
+
end
|
23
26
|
end
|
24
27
|
|
25
28
|
# @deprecated Will be removed in 1.0
|
@@ -13,7 +13,8 @@ module Datadog
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.parallel?(klass)
|
16
|
-
klass.ancestors.include?(::Minitest::Parallel::Test)
|
16
|
+
klass.ancestors.include?(::Minitest::Parallel::Test) ||
|
17
|
+
(defined?(::Minitest::Queue) && ::Minitest.singleton_class.ancestors.include?(::Minitest::Queue))
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -14,8 +14,6 @@ module Datadog
|
|
14
14
|
super
|
15
15
|
return unless datadog_configuration[:enabled]
|
16
16
|
|
17
|
-
test_name = "#{class_name}##{name}"
|
18
|
-
|
19
17
|
test_suite_name = Helpers.test_suite_name(self.class, name)
|
20
18
|
if Helpers.parallel?(self.class)
|
21
19
|
test_suite_name = "#{test_suite_name} (#{name} concurrently)"
|
@@ -24,13 +22,16 @@ module Datadog
|
|
24
22
|
CI.start_test_suite(test_suite_name)
|
25
23
|
end
|
26
24
|
|
25
|
+
source_file, line_number = method(name).source_location
|
26
|
+
|
27
27
|
CI.start_test(
|
28
|
-
|
28
|
+
name,
|
29
29
|
test_suite_name,
|
30
30
|
tags: {
|
31
31
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
32
32
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s,
|
33
|
-
CI::Ext::Test::
|
33
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Utils::Git.relative_to_root(source_file),
|
34
|
+
CI::Ext::Test::TAG_SOURCE_START => line_number.to_s
|
34
35
|
},
|
35
36
|
service: datadog_configuration[:service_name]
|
36
37
|
)
|
@@ -40,9 +41,9 @@ module Datadog
|
|
40
41
|
test_span = CI.active_test
|
41
42
|
return super unless test_span
|
42
43
|
|
43
|
-
|
44
|
+
finish_with_result(test_span, result_code)
|
44
45
|
if Helpers.parallel?(self.class)
|
45
|
-
|
46
|
+
finish_with_result(test_span.test_suite, result_code)
|
46
47
|
end
|
47
48
|
|
48
49
|
super
|
@@ -50,23 +51,9 @@ module Datadog
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
53
|
-
def finish_test(test_span, result_code)
|
54
|
-
finish_with_result(test_span, result_code)
|
55
|
-
|
56
|
-
# mark test suite as failed if any test failed
|
57
|
-
if test_span.failed?
|
58
|
-
test_suite = test_span.test_suite
|
59
|
-
test_suite.failed! if test_suite
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def finish_test_suite(test_suite, result_code)
|
64
|
-
return unless test_suite
|
65
|
-
|
66
|
-
finish_with_result(test_suite, result_code)
|
67
|
-
end
|
68
|
-
|
69
54
|
def finish_with_result(span, result_code)
|
55
|
+
return unless span
|
56
|
+
|
70
57
|
case result_code
|
71
58
|
when "."
|
72
59
|
span.passed!
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "runner"
|
4
|
+
require_relative "reporter"
|
3
5
|
require_relative "hooks"
|
4
6
|
require_relative "runnable"
|
5
7
|
|
@@ -18,13 +20,14 @@ module Datadog
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def patch
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
::Minitest.include(Plugin)
|
23
|
+
# test session start
|
24
|
+
::Minitest.include(Runner)
|
25
|
+
# test suites (when not executed concurrently)
|
25
26
|
::Minitest::Runnable.include(Runnable)
|
26
|
-
|
27
|
-
::Minitest.
|
27
|
+
# tests; test suites (when executed concurrently)
|
28
|
+
::Minitest::Test.include(Hooks)
|
29
|
+
# test session finish
|
30
|
+
::Minitest::CompositeReporter.include(Reporter)
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|