datadog-ci 0.8.3 → 1.0.0.beta2
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 +42 -0
- data/LICENSE-3rdparty.csv +1 -1
- data/README.md +40 -55
- data/ext/datadog_cov/datadog_cov.c +192 -0
- data/ext/datadog_cov/extconf.rb +18 -0
- data/lib/datadog/ci/configuration/components.rb +43 -9
- data/lib/datadog/ci/configuration/settings.rb +7 -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 +13 -18
- data/lib/datadog/ci/contrib/cucumber/integration.rb +1 -2
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +3 -0
- data/lib/datadog/ci/contrib/cucumber/step.rb +27 -0
- 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/hooks.rb +4 -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 +25 -23
- 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/providers/base.rb +1 -1
- data/lib/datadog/ci/ext/environment/providers/bitbucket.rb +1 -1
- data/lib/datadog/ci/ext/environment/providers/local_git.rb +8 -79
- data/lib/datadog/ci/ext/environment.rb +11 -16
- data/lib/datadog/ci/ext/settings.rb +1 -0
- data/lib/datadog/ci/ext/test.rb +5 -0
- data/lib/datadog/ci/ext/transport.rb +12 -0
- data/lib/datadog/ci/git/local_repository.rb +238 -0
- data/lib/datadog/ci/git/packfiles.rb +70 -0
- data/lib/datadog/ci/git/search_commits.rb +77 -0
- data/lib/datadog/ci/git/tree_uploader.rb +90 -0
- data/lib/datadog/ci/git/upload_packfile.rb +66 -0
- data/lib/datadog/ci/git/user.rb +29 -0
- data/lib/datadog/ci/itr/coverage/ddcov.rb +14 -0
- data/lib/datadog/ci/itr/coverage/event.rb +81 -0
- data/lib/datadog/ci/itr/coverage/transport.rb +42 -0
- data/lib/datadog/ci/itr/coverage/writer.rb +108 -0
- data/lib/datadog/ci/itr/runner.rb +143 -6
- data/lib/datadog/ci/itr/skippable.rb +106 -0
- data/lib/datadog/ci/span.rb +9 -0
- data/lib/datadog/ci/test.rb +20 -14
- data/lib/datadog/ci/test_module.rb +2 -2
- data/lib/datadog/ci/test_session.rb +2 -2
- data/lib/datadog/ci/test_suite.rb +2 -2
- data/lib/datadog/ci/test_visibility/context/global.rb +1 -3
- data/lib/datadog/ci/test_visibility/null_recorder.rb +5 -2
- data/lib/datadog/ci/test_visibility/recorder.rb +63 -8
- 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 +11 -54
- 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 +9 -1
- 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 +43 -6
- data/lib/datadog/ci/transport/remote_settings_api.rb +12 -6
- data/lib/datadog/ci/utils/configuration.rb +2 -2
- data/lib/datadog/ci/utils/git.rb +6 -67
- data/lib/datadog/ci/utils/parsing.rb +16 -0
- data/lib/datadog/ci/utils/test_run.rb +13 -0
- data/lib/datadog/ci/version.rb +5 -5
- data/lib/datadog/ci/worker.rb +35 -0
- data/lib/datadog/ci.rb +4 -0
- metadata +36 -4
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../ext/test"
|
4
|
-
require_relative "../../
|
4
|
+
require_relative "../../git/local_repository"
|
5
|
+
require_relative "../../utils/test_run"
|
5
6
|
require_relative "ext"
|
6
7
|
|
7
8
|
module Datadog
|
@@ -55,25 +56,26 @@ module Datadog
|
|
55
56
|
def on_test_case_started(event)
|
56
57
|
test_suite_name = test_suite_name(event.test_case)
|
57
58
|
|
59
|
+
# @type var tags: Hash[String, String]
|
58
60
|
tags = {
|
59
61
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
60
62
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s,
|
61
|
-
CI::Ext::Test::TAG_SOURCE_FILE =>
|
63
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(event.test_case.location.file),
|
62
64
|
CI::Ext::Test::TAG_SOURCE_START => event.test_case.location.line.to_s
|
63
65
|
}
|
64
66
|
|
67
|
+
if (parameters = extract_parameters_hash(event.test_case))
|
68
|
+
tags[CI::Ext::Test::TAG_PARAMETERS] = Utils::TestRun.test_parameters(arguments: parameters)
|
69
|
+
end
|
70
|
+
|
65
71
|
start_test_suite(test_suite_name) unless same_test_suite_as_current?(test_suite_name)
|
66
72
|
|
67
|
-
|
73
|
+
CI.start_test(
|
68
74
|
event.test_case.name,
|
69
75
|
test_suite_name,
|
70
76
|
tags: tags,
|
71
77
|
service: configuration[:service_name]
|
72
78
|
)
|
73
|
-
|
74
|
-
if test_span && (parameters = extract_parameters_hash(event.test_case))
|
75
|
-
test_span.set_parameters(parameters)
|
76
|
-
end
|
77
79
|
end
|
78
80
|
|
79
81
|
def on_test_case_finished(event)
|
@@ -100,9 +102,8 @@ module Datadog
|
|
100
102
|
def test_suite_name(test_case)
|
101
103
|
feature = if test_case.respond_to?(:feature)
|
102
104
|
test_case.feature
|
103
|
-
|
104
|
-
|
105
|
-
gherkin_doc.feature if gherkin_doc
|
105
|
+
else
|
106
|
+
@ast_lookup&.gherkin_document(test_case.location.file)&.feature
|
106
107
|
end
|
107
108
|
|
108
109
|
if feature
|
@@ -150,19 +151,13 @@ module Datadog
|
|
150
151
|
end
|
151
152
|
|
152
153
|
def finish_current_test_suite
|
153
|
-
|
154
|
-
return unless test_suite
|
155
|
-
|
156
|
-
test_suite.finish
|
154
|
+
@current_test_suite&.finish
|
157
155
|
|
158
156
|
@current_test_suite = nil
|
159
157
|
end
|
160
158
|
|
161
159
|
def same_test_suite_as_current?(test_suite_name)
|
162
|
-
|
163
|
-
return false unless test_suite
|
164
|
-
|
165
|
-
test_suite.name == test_suite_name
|
160
|
+
@current_test_suite&.name == test_suite_name
|
166
161
|
end
|
167
162
|
|
168
163
|
def extract_parameters_hash(test_case)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "datadog/tracing/contrib/patcher"
|
4
|
+
|
4
5
|
require_relative "instrumentation"
|
6
|
+
require_relative "step"
|
5
7
|
|
6
8
|
module Datadog
|
7
9
|
module CI
|
@@ -19,6 +21,7 @@ module Datadog
|
|
19
21
|
|
20
22
|
def patch
|
21
23
|
::Cucumber::Runtime.include(Instrumentation)
|
24
|
+
::Cucumber::Core::Test::Step.include(Datadog::CI::Contrib::Cucumber::Step)
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module CI
|
5
|
+
module Contrib
|
6
|
+
module Cucumber
|
7
|
+
# instruments Cucumber::Core::Test::Step from cucumber-ruby-core to change
|
8
|
+
module Step
|
9
|
+
def self.included(base)
|
10
|
+
base.prepend(InstanceMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
def execute(*args)
|
15
|
+
test_span = CI.active_test
|
16
|
+
if test_span&.skipped_by_itr?
|
17
|
+
@action.skip(*args)
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../ext/test"
|
4
|
+
require_relative "../../git/local_repository"
|
4
5
|
require_relative "ext"
|
5
6
|
require_relative "helpers"
|
6
7
|
|
@@ -24,17 +25,18 @@ module Datadog
|
|
24
25
|
|
25
26
|
source_file, line_number = method(name).source_location
|
26
27
|
|
27
|
-
CI.start_test(
|
28
|
+
test_span = CI.start_test(
|
28
29
|
name,
|
29
30
|
test_suite_name,
|
30
31
|
tags: {
|
31
32
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
32
33
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s,
|
33
|
-
CI::Ext::Test::TAG_SOURCE_FILE =>
|
34
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(source_file),
|
34
35
|
CI::Ext::Test::TAG_SOURCE_START => line_number.to_s
|
35
36
|
},
|
36
37
|
service: datadog_configuration[:service_name]
|
37
38
|
)
|
39
|
+
skip(CI::Ext::Test::ITR_TEST_SKIP_REASON) if test_span&.skipped_by_itr?
|
38
40
|
end
|
39
41
|
|
40
42
|
def after_teardown
|
@@ -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
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../ext/test"
|
4
|
-
require_relative "../../
|
4
|
+
require_relative "../../git/local_repository"
|
5
|
+
require_relative "../../utils/test_run"
|
5
6
|
require_relative "ext"
|
6
7
|
|
7
8
|
module Datadog
|
@@ -41,35 +42,36 @@ module Datadog
|
|
41
42
|
tags: {
|
42
43
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
43
44
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s,
|
44
|
-
CI::Ext::Test::TAG_SOURCE_FILE =>
|
45
|
-
CI::Ext::Test::TAG_SOURCE_START => metadata[:line_number].to_s
|
45
|
+
CI::Ext::Test::TAG_SOURCE_FILE => Git::LocalRepository.relative_to_root(metadata[:file_path]),
|
46
|
+
CI::Ext::Test::TAG_SOURCE_START => metadata[:line_number].to_s,
|
47
|
+
CI::Ext::Test::TAG_PARAMETERS => Utils::TestRun.test_parameters(
|
48
|
+
metadata: {"scoped_id" => metadata[:scoped_id]}
|
49
|
+
)
|
46
50
|
},
|
47
51
|
service: datadog_configuration[:service_name]
|
48
52
|
) do |test_span|
|
53
|
+
metadata[:skip] = CI::Ext::Test::ITR_TEST_SKIP_REASON if test_span&.skipped_by_itr?
|
54
|
+
|
49
55
|
result = super
|
50
56
|
|
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
|
57
|
+
case execution_result.status
|
58
|
+
when :passed
|
59
|
+
test_span&.passed!
|
60
|
+
test_suite_span&.passed!
|
61
|
+
when :failed
|
62
|
+
test_span&.failed!(exception: execution_result.exception)
|
63
|
+
test_suite_span&.failed!
|
64
|
+
else
|
65
|
+
# :pending or nil
|
66
|
+
test_span&.skipped!(
|
67
|
+
reason: execution_result.pending_message,
|
68
|
+
exception: execution_result.pending_exception
|
69
|
+
)
|
70
|
+
|
71
|
+
test_suite_span&.skipped!
|
70
72
|
end
|
71
73
|
|
72
|
-
test_suite_span
|
74
|
+
test_suite_span&.finish
|
73
75
|
|
74
76
|
result
|
75
77
|
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)
|
@@ -103,7 +103,7 @@ module Datadog
|
|
103
103
|
@branch = @tag = nil
|
104
104
|
|
105
105
|
# @type var branch_or_tag_string: untyped
|
106
|
-
if branch_or_tag_string
|
106
|
+
if branch_or_tag_string&.include?("tags/")
|
107
107
|
@tag = branch_or_tag_string
|
108
108
|
else
|
109
109
|
@branch = branch_or_tag_string
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "base"
|
4
|
-
require_relative "../../../
|
4
|
+
require_relative "../../../git/local_repository"
|
5
5
|
|
6
6
|
module Datadog
|
7
7
|
module CI
|
@@ -11,48 +11,23 @@ module Datadog
|
|
11
11
|
# As a fallback we try to fetch git information from the local git repository
|
12
12
|
class LocalGit < Base
|
13
13
|
def git_repository_url
|
14
|
-
|
15
|
-
rescue => e
|
16
|
-
Datadog.logger.debug(
|
17
|
-
"Unable to read git repository url: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
18
|
-
)
|
19
|
-
nil
|
14
|
+
CI::Git::LocalRepository.git_repository_url
|
20
15
|
end
|
21
16
|
|
22
17
|
def git_commit_sha
|
23
|
-
|
24
|
-
rescue => e
|
25
|
-
Datadog.logger.debug(
|
26
|
-
"Unable to read git commit SHA: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
27
|
-
)
|
28
|
-
nil
|
18
|
+
CI::Git::LocalRepository.git_commit_sha
|
29
19
|
end
|
30
20
|
|
31
21
|
def git_branch
|
32
|
-
|
33
|
-
rescue => e
|
34
|
-
Datadog.logger.debug(
|
35
|
-
"Unable to read git branch: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
36
|
-
)
|
37
|
-
nil
|
22
|
+
CI::Git::LocalRepository.git_branch
|
38
23
|
end
|
39
24
|
|
40
25
|
def git_tag
|
41
|
-
|
42
|
-
rescue => e
|
43
|
-
Datadog.logger.debug(
|
44
|
-
"Unable to read git tag: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
45
|
-
)
|
46
|
-
nil
|
26
|
+
CI::Git::LocalRepository.git_tag
|
47
27
|
end
|
48
28
|
|
49
29
|
def git_commit_message
|
50
|
-
|
51
|
-
rescue => e
|
52
|
-
Datadog.logger.debug(
|
53
|
-
"Unable to read git commit message: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
54
|
-
)
|
55
|
-
nil
|
30
|
+
CI::Git::LocalRepository.git_commit_message
|
56
31
|
end
|
57
32
|
|
58
33
|
def git_commit_author_name
|
@@ -80,12 +55,7 @@ module Datadog
|
|
80
55
|
end
|
81
56
|
|
82
57
|
def workspace_path
|
83
|
-
|
84
|
-
rescue => e
|
85
|
-
Datadog.logger.debug(
|
86
|
-
"Unable to read git base directory: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
87
|
-
)
|
88
|
-
nil
|
58
|
+
CI::Git::LocalRepository.git_root
|
89
59
|
end
|
90
60
|
|
91
61
|
private
|
@@ -105,48 +75,7 @@ module Datadog
|
|
105
75
|
end
|
106
76
|
|
107
77
|
def set_git_commit_users
|
108
|
-
|
109
|
-
output = Utils::Git.exec_git_command("git show -s --format='%an\t%ae\t%at\t%cn\t%ce\t%ct'")
|
110
|
-
unless output
|
111
|
-
Datadog.logger.debug(
|
112
|
-
"Unable to read git commit users: git command output is nil"
|
113
|
-
)
|
114
|
-
@author = @committer = NilUser.new
|
115
|
-
return
|
116
|
-
end
|
117
|
-
|
118
|
-
author_name, author_email, author_timestamp,
|
119
|
-
committer_name, committer_email, committer_timestamp = output.split("\t").each(&:strip!)
|
120
|
-
|
121
|
-
@author = GitUser.new(author_name, author_email, author_timestamp)
|
122
|
-
@committer = GitUser.new(committer_name, committer_email, committer_timestamp)
|
123
|
-
rescue => e
|
124
|
-
Datadog.logger.debug(
|
125
|
-
"Unable to read git commit users: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
|
126
|
-
)
|
127
|
-
@author = @committer = NilUser.new
|
128
|
-
end
|
129
|
-
|
130
|
-
class GitUser
|
131
|
-
attr_reader :name, :email, :timestamp
|
132
|
-
|
133
|
-
def initialize(name, email, timestamp)
|
134
|
-
@name = name
|
135
|
-
@email = email
|
136
|
-
@timestamp = timestamp
|
137
|
-
end
|
138
|
-
|
139
|
-
def date
|
140
|
-
return nil if timestamp.nil?
|
141
|
-
|
142
|
-
Time.at(timestamp.to_i).utc.to_datetime.iso8601
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
class NilUser < GitUser
|
147
|
-
def initialize
|
148
|
-
super(nil, nil, nil)
|
149
|
-
end
|
78
|
+
@author, @committer = CI::Git::LocalRepository.git_commit_users
|
150
79
|
end
|
151
80
|
end
|
152
81
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require_relative "git"
|
4
4
|
require_relative "environment/extractor"
|
5
5
|
|
6
|
+
require_relative "../utils/git"
|
7
|
+
|
6
8
|
module Datadog
|
7
9
|
module CI
|
8
10
|
module Ext
|
@@ -21,8 +23,6 @@ module Datadog
|
|
21
23
|
TAG_NODE_NAME = "ci.node.name"
|
22
24
|
TAG_CI_ENV_VARS = "_dd.ci.env_vars"
|
23
25
|
|
24
|
-
HEX_NUMBER_REGEXP = /[0-9a-f]{40}/i.freeze
|
25
|
-
|
26
26
|
module_function
|
27
27
|
|
28
28
|
def tags(env)
|
@@ -57,24 +57,19 @@ module Datadog
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def validate_git_sha(git_sha)
|
60
|
-
|
60
|
+
return if Utils::Git.valid_commit_sha?(git_sha)
|
61
61
|
|
62
|
-
|
63
|
-
message += " No value was set and no SHA was automatically extracted."
|
64
|
-
Datadog.logger.error(message)
|
65
|
-
return
|
66
|
-
end
|
62
|
+
message = "DD_GIT_COMMIT_SHA must be a full-length git SHA."
|
67
63
|
|
68
|
-
if git_sha.
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
message += if git_sha.nil? || git_sha.empty?
|
65
|
+
" No value was set and no SHA was automatically extracted."
|
66
|
+
elsif git_sha.length < Git::SHA_LENGTH
|
67
|
+
" Expected SHA length #{Git::SHA_LENGTH}, was #{git_sha.length}."
|
68
|
+
else
|
69
|
+
" Expected SHA to be a valid HEX number, got #{git_sha}."
|
72
70
|
end
|
73
71
|
|
74
|
-
|
75
|
-
message += " Expected SHA to be a valid HEX number, got #{git_sha}."
|
76
|
-
Datadog.logger.error(message)
|
77
|
-
end
|
72
|
+
Datadog.logger.error(message)
|
78
73
|
end
|
79
74
|
end
|
80
75
|
end
|
@@ -11,6 +11,7 @@ module Datadog
|
|
11
11
|
ENV_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED = "DD_CIVISIBILITY_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED"
|
12
12
|
ENV_FORCE_TEST_LEVEL_VISIBILITY = "DD_CIVISIBILITY_FORCE_TEST_LEVEL_VISIBILITY"
|
13
13
|
ENV_ITR_ENABLED = "DD_CIVISIBILITY_ITR_ENABLED"
|
14
|
+
ENV_GIT_METADATA_UPLOAD_ENABLED = "DD_CIVISIBILITY_GIT_METADATA_UPLOAD_ENABLED"
|
14
15
|
|
15
16
|
# Source: https://docs.datadoghq.com/getting_started/site/
|
16
17
|
DD_SITE_ALLOWLIST = [
|
data/lib/datadog/ci/ext/test.rb
CHANGED
@@ -26,6 +26,9 @@ module Datadog
|
|
26
26
|
# ITR tags
|
27
27
|
TAG_ITR_TEST_SKIPPING_ENABLED = "test.itr.tests_skipping.enabled"
|
28
28
|
TAG_ITR_TEST_SKIPPING_TYPE = "test.itr.tests_skipping.type"
|
29
|
+
TAG_ITR_TEST_SKIPPING_COUNT = "test.itr.tests_skipping.count"
|
30
|
+
TAG_ITR_SKIPPED_BY_ITR = "test.skipped_by_itr"
|
31
|
+
TAG_ITR_TESTS_SKIPPED = "_dd.ci.itr.tests_skipped"
|
29
32
|
|
30
33
|
# Code coverage tags
|
31
34
|
TAG_CODE_COVERAGE_ENABLED = "test.code_coverage.enabled"
|
@@ -43,6 +46,7 @@ module Datadog
|
|
43
46
|
# Environment runtime tags
|
44
47
|
TAG_OS_ARCHITECTURE = "os.architecture"
|
45
48
|
TAG_OS_PLATFORM = "os.platform"
|
49
|
+
TAG_OS_VERSION = "os.version"
|
46
50
|
TAG_RUNTIME_NAME = "runtime.name"
|
47
51
|
TAG_RUNTIME_VERSION = "runtime.version"
|
48
52
|
|
@@ -53,6 +57,7 @@ module Datadog
|
|
53
57
|
# could be either "test" or "suite" depending on whether we skip individual tests or whole suites
|
54
58
|
# we use test skipping for Ruby
|
55
59
|
ITR_TEST_SKIPPING_MODE = "test"
|
60
|
+
ITR_TEST_SKIP_REASON = "Skipped by Datadog's intelligent test runner"
|
56
61
|
|
57
62
|
# test status as recognized by Datadog
|
58
63
|
module Status
|
@@ -23,7 +23,11 @@ module Datadog
|
|
23
23
|
TEST_VISIBILITY_INTAKE_HOST_PREFIX = "citestcycle-intake"
|
24
24
|
TEST_VISIBILITY_INTAKE_PATH = "/api/v2/citestcycle"
|
25
25
|
|
26
|
+
TEST_COVERAGE_INTAKE_HOST_PREFIX = "citestcov-intake"
|
27
|
+
TEST_COVERAGE_INTAKE_PATH = "/api/v2/citestcov"
|
28
|
+
|
26
29
|
DD_API_HOST_PREFIX = "api"
|
30
|
+
|
27
31
|
DD_API_SETTINGS_PATH = "/api/v2/libraries/tests/services/setting"
|
28
32
|
DD_API_SETTINGS_TYPE = "ci_app_test_service_libraries_settings"
|
29
33
|
DD_API_SETTINGS_RESPONSE_DIG_KEYS = %w[data attributes].freeze
|
@@ -33,8 +37,16 @@ module Datadog
|
|
33
37
|
DD_API_SETTINGS_RESPONSE_REQUIRE_GIT_KEY = "require_git"
|
34
38
|
DD_API_SETTINGS_RESPONSE_DEFAULT = {DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY => false}.freeze
|
35
39
|
|
40
|
+
DD_API_GIT_SEARCH_COMMITS_PATH = "/api/v2/git/repository/search_commits"
|
41
|
+
|
42
|
+
DD_API_GIT_UPLOAD_PACKFILE_PATH = "/api/v2/git/repository/packfile"
|
43
|
+
|
44
|
+
DD_API_SKIPPABLE_TESTS_PATH = "/api/v2/ci/tests/skippable"
|
45
|
+
DD_API_SKIPPABLE_TESTS_TYPE = "test_params"
|
46
|
+
|
36
47
|
CONTENT_TYPE_MESSAGEPACK = "application/msgpack"
|
37
48
|
CONTENT_TYPE_JSON = "application/json"
|
49
|
+
CONTENT_TYPE_MULTIPART_FORM_DATA = "multipart/form-data"
|
38
50
|
CONTENT_ENCODING_GZIP = "gzip"
|
39
51
|
end
|
40
52
|
end
|