datadog-ci 1.0.0.beta2 → 1.0.0.beta4
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 +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
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "knapsack_pro/extensions/rspec_extension"
|
4
|
+
|
5
|
+
require_relative "runner"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Contrib
|
10
|
+
module RSpec
|
11
|
+
# Instrument RSpec::Core::Example
|
12
|
+
module KnapsackPro
|
13
|
+
module Extension
|
14
|
+
def self.included(base)
|
15
|
+
base.singleton_class.prepend(ClassMethods)
|
16
|
+
end
|
17
|
+
|
18
|
+
module ClassMethods
|
19
|
+
def setup!
|
20
|
+
super
|
21
|
+
|
22
|
+
::RSpec::Core::Runner.include(Datadog::CI::Contrib::RSpec::KnapsackPro::Runner)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../../ext/test"
|
4
|
+
require_relative "../ext"
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module CI
|
8
|
+
module Contrib
|
9
|
+
module RSpec
|
10
|
+
module KnapsackPro
|
11
|
+
module Runner
|
12
|
+
def self.included(base)
|
13
|
+
base.prepend(InstanceMethods)
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
def knapsack__run_specs(*)
|
18
|
+
return super unless datadog_configuration[:enabled]
|
19
|
+
|
20
|
+
test_session = CI.start_test_session(
|
21
|
+
tags: {
|
22
|
+
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
23
|
+
CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s
|
24
|
+
},
|
25
|
+
service: datadog_configuration[:service_name]
|
26
|
+
)
|
27
|
+
|
28
|
+
test_module = CI.start_test_module(Ext::FRAMEWORK)
|
29
|
+
|
30
|
+
result = super
|
31
|
+
return result unless test_module && test_session
|
32
|
+
|
33
|
+
if result != 0
|
34
|
+
test_module.failed!
|
35
|
+
test_session.failed!
|
36
|
+
else
|
37
|
+
test_module.passed!
|
38
|
+
test_session.passed!
|
39
|
+
end
|
40
|
+
test_module.finish
|
41
|
+
test_session.finish
|
42
|
+
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def datadog_configuration
|
49
|
+
Datadog.configuration.ci[:rspec]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -21,19 +21,35 @@ module Datadog
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def patch
|
24
|
+
# ci-queue test runner instrumentation
|
25
|
+
# https://github.com/Shopify/ci-queue
|
24
26
|
if ci_queue?
|
25
27
|
::RSpec::Queue::Runner.include(Runner)
|
26
28
|
end
|
27
29
|
|
30
|
+
# Knapsack Pro test runner instrumentation
|
31
|
+
# https://github.com/KnapsackPro/knapsack_pro-ruby
|
32
|
+
if knapsack_pro?
|
33
|
+
require_relative "knapsack_pro/extension"
|
34
|
+
::KnapsackPro::Extensions::RSpecExtension.include(KnapsackPro::Extension)
|
35
|
+
end
|
36
|
+
|
28
37
|
::RSpec::Core::Runner.include(Runner)
|
29
38
|
::RSpec::Core::Example.include(Example)
|
30
39
|
::RSpec::Core::ExampleGroup.include(ExampleGroup)
|
31
40
|
end
|
32
41
|
|
33
42
|
def ci_queue?
|
34
|
-
# ::RSpec::Queue::Runner is a ci-queue runner
|
35
43
|
defined?(::RSpec::Queue::Runner)
|
36
44
|
end
|
45
|
+
|
46
|
+
def knapsack_pro?
|
47
|
+
knapsack_version = Gem.loaded_specs["knapsack_pro"]&.version
|
48
|
+
|
49
|
+
# additional instrumentation is needed for KnapsackPro version 7 and later
|
50
|
+
defined?(::KnapsackPro) &&
|
51
|
+
knapsack_version && knapsack_version >= Gem::Version.new("7")
|
52
|
+
end
|
37
53
|
end
|
38
54
|
end
|
39
55
|
end
|
@@ -12,6 +12,7 @@ module Datadog
|
|
12
12
|
ENV_FORCE_TEST_LEVEL_VISIBILITY = "DD_CIVISIBILITY_FORCE_TEST_LEVEL_VISIBILITY"
|
13
13
|
ENV_ITR_ENABLED = "DD_CIVISIBILITY_ITR_ENABLED"
|
14
14
|
ENV_GIT_METADATA_UPLOAD_ENABLED = "DD_CIVISIBILITY_GIT_METADATA_UPLOAD_ENABLED"
|
15
|
+
ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH = "DD_CIVISIBILITY_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH"
|
15
16
|
|
16
17
|
# Source: https://docs.datadoghq.com/getting_started/site/
|
17
18
|
DD_SITE_ALLOWLIST = [
|
data/lib/datadog/ci/ext/test.rb
CHANGED
@@ -8,7 +8,6 @@ module Datadog
|
|
8
8
|
module Test
|
9
9
|
CONTEXT_ORIGIN = "ciapp-test"
|
10
10
|
|
11
|
-
TAG_ARGUMENTS = "test.arguments"
|
12
11
|
TAG_FRAMEWORK = "test.framework"
|
13
12
|
TAG_FRAMEWORK_VERSION = "test.framework_version"
|
14
13
|
TAG_NAME = "test.name"
|
@@ -29,6 +28,8 @@ module Datadog
|
|
29
28
|
TAG_ITR_TEST_SKIPPING_COUNT = "test.itr.tests_skipping.count"
|
30
29
|
TAG_ITR_SKIPPED_BY_ITR = "test.skipped_by_itr"
|
31
30
|
TAG_ITR_TESTS_SKIPPED = "_dd.ci.itr.tests_skipped"
|
31
|
+
TAG_ITR_UNSKIPPABLE = "test.itr.unskippable"
|
32
|
+
TAG_ITR_FORCED_RUN = "test.itr.forced_run"
|
32
33
|
|
33
34
|
# Code coverage tags
|
34
35
|
TAG_CODE_COVERAGE_ENABLED = "test.code_coverage.enabled"
|
@@ -58,6 +59,7 @@ module Datadog
|
|
58
59
|
# we use test skipping for Ruby
|
59
60
|
ITR_TEST_SKIPPING_MODE = "test"
|
60
61
|
ITR_TEST_SKIP_REASON = "Skipped by Datadog's intelligent test runner"
|
62
|
+
ITR_UNSKIPPABLE_OPTION = :datadog_itr_unskippable
|
61
63
|
|
62
64
|
# test status as recognized by Datadog
|
63
65
|
module Status
|
@@ -58,9 +58,15 @@ module Datadog
|
|
58
58
|
def perform(*events)
|
59
59
|
responses = transport.send_events(events)
|
60
60
|
|
61
|
-
|
61
|
+
if responses.find(&:server_error?)
|
62
|
+
loop_back_off!
|
63
|
+
Datadog.logger.warn { "Encountered server error while sending coverage events" }
|
64
|
+
end
|
62
65
|
|
63
66
|
nil
|
67
|
+
rescue => e
|
68
|
+
Datadog.logger.warn { "Error while sending coverage events: #{e}" }
|
69
|
+
loop_back_off!
|
64
70
|
end
|
65
71
|
|
66
72
|
def stop(force_stop = false, timeout = @shutdown_timeout)
|
@@ -27,13 +27,22 @@ module Datadog
|
|
27
27
|
|
28
28
|
def initialize(
|
29
29
|
dd_env:,
|
30
|
+
config_tags: {},
|
30
31
|
api: nil,
|
31
32
|
coverage_writer: nil,
|
32
|
-
enabled: false
|
33
|
+
enabled: false,
|
34
|
+
bundle_location: nil
|
33
35
|
)
|
34
36
|
@enabled = enabled
|
35
37
|
@api = api
|
36
38
|
@dd_env = dd_env
|
39
|
+
@config_tags = config_tags || {}
|
40
|
+
|
41
|
+
@bundle_location = if bundle_location && !File.absolute_path?(bundle_location)
|
42
|
+
File.join(Git::LocalRepository.root, bundle_location)
|
43
|
+
else
|
44
|
+
bundle_location
|
45
|
+
end
|
37
46
|
|
38
47
|
@test_skipping_enabled = false
|
39
48
|
@code_coverage_enabled = false
|
@@ -41,7 +50,7 @@ module Datadog
|
|
41
50
|
@coverage_writer = coverage_writer
|
42
51
|
|
43
52
|
@correlation_id = nil
|
44
|
-
@skippable_tests =
|
53
|
+
@skippable_tests = Set.new
|
45
54
|
|
46
55
|
@skipped_tests_count = 0
|
47
56
|
@mutex = Mutex.new
|
@@ -127,6 +136,11 @@ module Datadog
|
|
127
136
|
|
128
137
|
skippable_test_id = Utils::TestRun.skippable_test_id(test.name, test.test_suite_name, test.parameters)
|
129
138
|
if @skippable_tests.include?(skippable_test_id)
|
139
|
+
if forked?
|
140
|
+
Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
|
141
|
+
return
|
142
|
+
end
|
143
|
+
|
130
144
|
test.set_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR, "true")
|
131
145
|
|
132
146
|
Datadog.logger.debug { "Marked test as skippable: #{skippable_test_id}" }
|
@@ -136,13 +150,13 @@ module Datadog
|
|
136
150
|
end
|
137
151
|
|
138
152
|
def count_skipped_test(test)
|
153
|
+
return if !test.skipped? || !test.skipped_by_itr?
|
154
|
+
|
139
155
|
if forked?
|
140
156
|
Datadog.logger.warn { "ITR is not supported for forking test runners yet" }
|
141
157
|
return
|
142
158
|
end
|
143
159
|
|
144
|
-
return if !test.skipped? || !test.skipped_by_itr?
|
145
|
-
|
146
160
|
@mutex.synchronize do
|
147
161
|
@skipped_tests_count += 1
|
148
162
|
end
|
@@ -151,6 +165,9 @@ module Datadog
|
|
151
165
|
def write_test_session_tags(test_session)
|
152
166
|
return if !enabled?
|
153
167
|
|
168
|
+
Datadog.logger.debug { "Finished ITR session with test skipping enabled: #{@test_skipping_enabled}" }
|
169
|
+
Datadog.logger.debug { "#{@skipped_tests_count} tests were skipped" }
|
170
|
+
|
154
171
|
test_session.set_tag(Ext::Test::TAG_ITR_TESTS_SKIPPED, @skipped_tests_count.positive?.to_s)
|
155
172
|
test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_COUNT, @skipped_tests_count)
|
156
173
|
end
|
@@ -167,7 +184,10 @@ module Datadog
|
|
167
184
|
end
|
168
185
|
|
169
186
|
def coverage_collector
|
170
|
-
Thread.current[:dd_coverage_collector] ||= Coverage::DDCov.new(
|
187
|
+
Thread.current[:dd_coverage_collector] ||= Coverage::DDCov.new(
|
188
|
+
root: Git::LocalRepository.root,
|
189
|
+
ignored_path: @bundle_location
|
190
|
+
)
|
171
191
|
end
|
172
192
|
|
173
193
|
def load_datadog_cov!
|
@@ -191,11 +211,15 @@ module Datadog
|
|
191
211
|
# we can only request skippable tests if git metadata is already uploaded
|
192
212
|
git_tree_upload_worker.wait_until_done
|
193
213
|
|
194
|
-
skippable_response =
|
214
|
+
skippable_response =
|
215
|
+
Skippable.new(api: @api, dd_env: @dd_env, config_tags: @config_tags)
|
216
|
+
.fetch_skippable_tests(test_session)
|
217
|
+
|
195
218
|
@correlation_id = skippable_response.correlation_id
|
196
219
|
@skippable_tests = skippable_response.tests
|
197
220
|
|
198
221
|
Datadog.logger.debug { "Fetched skippable tests: \n #{@skippable_tests}" }
|
222
|
+
Datadog.logger.debug { "Found #{@skippable_tests.count} skippable tests." }
|
199
223
|
Datadog.logger.debug { "ITR correlation ID: #{@correlation_id}" }
|
200
224
|
end
|
201
225
|
end
|
@@ -57,9 +57,10 @@ module Datadog
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def initialize(dd_env:, api: nil)
|
60
|
+
def initialize(dd_env:, api: nil, config_tags: {})
|
61
61
|
@api = api
|
62
62
|
@dd_env = dd_env
|
63
|
+
@config_tags = config_tags
|
63
64
|
end
|
64
65
|
|
65
66
|
def fetch_skippable_tests(test_session)
|
@@ -94,7 +95,8 @@ module Datadog
|
|
94
95
|
Ext::Test::TAG_OS_ARCHITECTURE => test_session.os_architecture,
|
95
96
|
Ext::Test::TAG_OS_VERSION => test_session.os_version,
|
96
97
|
Ext::Test::TAG_RUNTIME_NAME => test_session.runtime_name,
|
97
|
-
Ext::Test::TAG_RUNTIME_VERSION => test_session.runtime_version
|
98
|
+
Ext::Test::TAG_RUNTIME_VERSION => test_session.runtime_version,
|
99
|
+
"custom" => @config_tags
|
98
100
|
}
|
99
101
|
}
|
100
102
|
}
|
data/lib/datadog/ci/span.rb
CHANGED
@@ -102,6 +102,13 @@ module Datadog
|
|
102
102
|
tracer_span.set_tag(key, value)
|
103
103
|
end
|
104
104
|
|
105
|
+
# Removes tag by key.
|
106
|
+
# @param [String] key the key of the tag.
|
107
|
+
# @return [void]
|
108
|
+
def clear_tag(key)
|
109
|
+
tracer_span.clear_tag(key)
|
110
|
+
end
|
111
|
+
|
105
112
|
# Sets metric value by key.
|
106
113
|
# @param [String] key the key of the metric.
|
107
114
|
# @param [Numeric] value the value of the metric.
|
data/lib/datadog/ci/test.rb
CHANGED
@@ -69,6 +69,24 @@ module Datadog
|
|
69
69
|
get_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR) == "true"
|
70
70
|
end
|
71
71
|
|
72
|
+
# Marks this test as unskippable by the intelligent test runner.
|
73
|
+
# This must be done before the test execution starts.
|
74
|
+
#
|
75
|
+
# Examples of tests that should be unskippable:
|
76
|
+
# - tests that read files from disk
|
77
|
+
# - tests that make network requests
|
78
|
+
# - tests that call external processes
|
79
|
+
# - tests that use forking or threading
|
80
|
+
#
|
81
|
+
# @return [void]
|
82
|
+
def itr_unskippable!
|
83
|
+
set_tag(Ext::Test::TAG_ITR_UNSKIPPABLE, "true")
|
84
|
+
if skipped_by_itr?
|
85
|
+
clear_tag(Ext::Test::TAG_ITR_SKIPPED_BY_ITR)
|
86
|
+
set_tag(Ext::Test::TAG_ITR_FORCED_RUN, "true")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
72
90
|
# Sets the status of the span to "pass".
|
73
91
|
# @return [void]
|
74
92
|
def passed!
|
@@ -28,11 +28,12 @@ module Datadog
|
|
28
28
|
"duration"
|
29
29
|
].freeze
|
30
30
|
|
31
|
-
attr_reader :trace, :span, :meta
|
31
|
+
attr_reader :trace, :span, :meta, :options
|
32
32
|
|
33
|
-
def initialize(trace, span)
|
33
|
+
def initialize(trace, span, options: {})
|
34
34
|
@trace = trace
|
35
35
|
@span = span
|
36
|
+
@options = options
|
36
37
|
|
37
38
|
@meta = @span.meta.reject { |key, _| Ext::Test::TRANSIENT_TAGS.include?(key) }
|
38
39
|
|
@@ -14,12 +14,12 @@ module Datadog
|
|
14
14
|
module TestLevel
|
15
15
|
module_function
|
16
16
|
|
17
|
-
def serializer(trace, span)
|
17
|
+
def serializer(trace, span, options: {})
|
18
18
|
case span.type
|
19
19
|
when Datadog::CI::Ext::AppTypes::TYPE_TEST
|
20
|
-
Serializers::TestV1.new(trace, span)
|
20
|
+
Serializers::TestV1.new(trace, span, options: options)
|
21
21
|
else
|
22
|
-
Serializers::Span.new(trace, span)
|
22
|
+
Serializers::Span.new(trace, span, options: options)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -15,18 +15,18 @@ module Datadog
|
|
15
15
|
module TestSuiteLevel
|
16
16
|
module_function
|
17
17
|
|
18
|
-
def serializer(trace, span)
|
18
|
+
def serializer(trace, span, options: {})
|
19
19
|
case span.type
|
20
20
|
when Datadog::CI::Ext::AppTypes::TYPE_TEST
|
21
|
-
Serializers::TestV2.new(trace, span)
|
21
|
+
Serializers::TestV2.new(trace, span, options: options)
|
22
22
|
when Datadog::CI::Ext::AppTypes::TYPE_TEST_SESSION
|
23
|
-
Serializers::TestSession.new(trace, span)
|
23
|
+
Serializers::TestSession.new(trace, span, options: options)
|
24
24
|
when Datadog::CI::Ext::AppTypes::TYPE_TEST_MODULE
|
25
|
-
Serializers::TestModule.new(trace, span)
|
25
|
+
Serializers::TestModule.new(trace, span, options: options)
|
26
26
|
when Datadog::CI::Ext::AppTypes::TYPE_TEST_SUITE
|
27
|
-
Serializers::TestSuite.new(trace, span)
|
27
|
+
Serializers::TestSuite.new(trace, span, options: options)
|
28
28
|
else
|
29
|
-
Serializers::Span.new(trace, span)
|
29
|
+
Serializers::Span.new(trace, span, options: options)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -10,22 +10,34 @@ module Datadog
|
|
10
10
|
class TestV2 < TestV1
|
11
11
|
CONTENT_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + TestV1::CONTENT_FIELDS).freeze
|
12
12
|
|
13
|
+
CONTENT_FIELDS_WITH_ITR_CORRELATION_ID = (CONTENT_FIELDS + ["itr_correlation_id"]).freeze
|
14
|
+
|
13
15
|
CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS)
|
14
16
|
|
17
|
+
CONTENT_MAP_SIZE_WITH_ITR_CORRELATION_ID = calculate_content_map_size(CONTENT_FIELDS_WITH_ITR_CORRELATION_ID)
|
18
|
+
|
15
19
|
REQUIRED_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + TestV1::REQUIRED_FIELDS).freeze
|
16
20
|
|
17
21
|
def content_fields
|
18
|
-
CONTENT_FIELDS
|
22
|
+
return CONTENT_FIELDS if itr_correlation_id.nil?
|
23
|
+
|
24
|
+
CONTENT_FIELDS_WITH_ITR_CORRELATION_ID
|
19
25
|
end
|
20
26
|
|
21
27
|
def content_map_size
|
22
|
-
CONTENT_MAP_SIZE
|
28
|
+
return CONTENT_MAP_SIZE if itr_correlation_id.nil?
|
29
|
+
|
30
|
+
CONTENT_MAP_SIZE_WITH_ITR_CORRELATION_ID
|
23
31
|
end
|
24
32
|
|
25
33
|
def version
|
26
34
|
2
|
27
35
|
end
|
28
36
|
|
37
|
+
def itr_correlation_id
|
38
|
+
options[:itr_correlation_id]
|
39
|
+
end
|
40
|
+
|
29
41
|
private
|
30
42
|
|
31
43
|
def required_fields
|
@@ -45,7 +45,7 @@ module Datadog
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def encode_span(trace, span)
|
48
|
-
serializer = serializers_factory.serializer(trace, span)
|
48
|
+
serializer = serializers_factory.serializer(trace, span, options: {itr_correlation_id: itr&.correlation_id})
|
49
49
|
|
50
50
|
if serializer.valid?
|
51
51
|
encoded = encoder.encode(serializer)
|
@@ -98,6 +98,10 @@ module Datadog
|
|
98
98
|
|
99
99
|
packer.write("events")
|
100
100
|
end
|
101
|
+
|
102
|
+
def itr
|
103
|
+
@itr ||= Datadog::CI.send(:itr_runner)
|
104
|
+
end
|
101
105
|
end
|
102
106
|
end
|
103
107
|
end
|
@@ -51,9 +51,10 @@ module Datadog
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def initialize(dd_env:, api: nil)
|
54
|
+
def initialize(dd_env:, api: nil, config_tags: {})
|
55
55
|
@api = api
|
56
56
|
@dd_env = dd_env
|
57
|
+
@config_tags = config_tags || {}
|
57
58
|
end
|
58
59
|
|
59
60
|
def fetch_library_settings(test_session)
|
@@ -90,7 +91,8 @@ module Datadog
|
|
90
91
|
Ext::Test::TAG_OS_ARCHITECTURE => test_session.os_architecture,
|
91
92
|
Ext::Test::TAG_OS_VERSION => test_session.os_version,
|
92
93
|
Ext::Test::TAG_RUNTIME_NAME => test_session.runtime_name,
|
93
|
-
Ext::Test::TAG_RUNTIME_VERSION => test_session.runtime_version
|
94
|
+
Ext::Test::TAG_RUNTIME_VERSION => test_session.runtime_version,
|
95
|
+
"custom" => @config_tags
|
94
96
|
}
|
95
97
|
}
|
96
98
|
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../ext/environment"
|
4
|
+
require_relative "../git/local_repository"
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module CI
|
8
|
+
module Utils
|
9
|
+
module Bundle
|
10
|
+
def self.location
|
11
|
+
require "bundler"
|
12
|
+
bundle_path = Bundler.bundle_path.to_s
|
13
|
+
bundle_path if bundle_path&.start_with?(Datadog::CI::Git::LocalRepository.root)
|
14
|
+
rescue => e
|
15
|
+
Datadog.logger.warn("Failed to find bundled gems location: #{e}")
|
16
|
+
|
17
|
+
Ext::Environment::POSSIBLE_BUNDLE_LOCATIONS.each do |location|
|
18
|
+
path = File.join(Datadog::CI::Git::LocalRepository.root, location)
|
19
|
+
return path if File.directory?(path)
|
20
|
+
end
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -22,6 +22,18 @@ module Datadog
|
|
22
22
|
}
|
23
23
|
)
|
24
24
|
end
|
25
|
+
|
26
|
+
def self.custom_configuration(env_tags)
|
27
|
+
return {} if env_tags.nil?
|
28
|
+
|
29
|
+
res = {}
|
30
|
+
env_tags.each do |tag, value|
|
31
|
+
next unless tag.start_with?("test.configuration.")
|
32
|
+
|
33
|
+
res[tag.sub("test.configuration.", "")] = value
|
34
|
+
end
|
35
|
+
res
|
36
|
+
end
|
25
37
|
end
|
26
38
|
end
|
27
39
|
end
|
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.0.0.
|
4
|
+
version: 1.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: datadog
|
@@ -77,17 +77,19 @@ files:
|
|
77
77
|
- lib/datadog/ci/contrib/minitest/configuration/settings.rb
|
78
78
|
- lib/datadog/ci/contrib/minitest/ext.rb
|
79
79
|
- lib/datadog/ci/contrib/minitest/helpers.rb
|
80
|
-
- lib/datadog/ci/contrib/minitest/hooks.rb
|
81
80
|
- lib/datadog/ci/contrib/minitest/integration.rb
|
82
81
|
- lib/datadog/ci/contrib/minitest/patcher.rb
|
83
82
|
- lib/datadog/ci/contrib/minitest/reporter.rb
|
84
83
|
- lib/datadog/ci/contrib/minitest/runnable.rb
|
85
84
|
- lib/datadog/ci/contrib/minitest/runner.rb
|
85
|
+
- lib/datadog/ci/contrib/minitest/test.rb
|
86
86
|
- lib/datadog/ci/contrib/rspec/configuration/settings.rb
|
87
87
|
- lib/datadog/ci/contrib/rspec/example.rb
|
88
88
|
- lib/datadog/ci/contrib/rspec/example_group.rb
|
89
89
|
- lib/datadog/ci/contrib/rspec/ext.rb
|
90
90
|
- lib/datadog/ci/contrib/rspec/integration.rb
|
91
|
+
- lib/datadog/ci/contrib/rspec/knapsack_pro/extension.rb
|
92
|
+
- lib/datadog/ci/contrib/rspec/knapsack_pro/runner.rb
|
91
93
|
- lib/datadog/ci/contrib/rspec/patcher.rb
|
92
94
|
- lib/datadog/ci/contrib/rspec/runner.rb
|
93
95
|
- lib/datadog/ci/contrib/settings.rb
|
@@ -156,6 +158,7 @@ files:
|
|
156
158
|
- lib/datadog/ci/transport/gzip.rb
|
157
159
|
- lib/datadog/ci/transport/http.rb
|
158
160
|
- lib/datadog/ci/transport/remote_settings_api.rb
|
161
|
+
- lib/datadog/ci/utils/bundle.rb
|
159
162
|
- lib/datadog/ci/utils/configuration.rb
|
160
163
|
- lib/datadog/ci/utils/git.rb
|
161
164
|
- lib/datadog/ci/utils/parsing.rb
|
@@ -170,7 +173,7 @@ metadata:
|
|
170
173
|
changelog_uri: https://github.com/DataDog/datadog-ci-rb/blob/main/CHANGELOG.md
|
171
174
|
homepage_uri: https://github.com/DataDog/datadog-ci-rb
|
172
175
|
source_code_uri: https://github.com/DataDog/datadog-ci-rb
|
173
|
-
post_install_message:
|
176
|
+
post_install_message:
|
174
177
|
rdoc_options: []
|
175
178
|
require_paths:
|
176
179
|
- lib
|
@@ -188,8 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
191
|
- !ruby/object:Gem::Version
|
189
192
|
version: 2.0.0
|
190
193
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
194
|
+
rubygems_version: 3.4.19
|
195
|
+
signing_key:
|
193
196
|
specification_version: 4
|
194
197
|
summary: Datadog CI visibility for your ruby application
|
195
198
|
test_files: []
|