datadog-ci 1.26.0 → 1.28.0
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 +45 -2
- data/ext/datadog_ci_native/datadog_cov.c +2 -2
- data/lib/datadog/ci/cli/command/exec.rb +1 -1
- data/lib/datadog/ci/cli/command/skippable_tests_percentage.rb +2 -2
- data/lib/datadog/ci/cli/command/skippable_tests_percentage_estimate.rb +2 -2
- data/lib/datadog/ci/code_coverage/component.rb +55 -0
- data/lib/datadog/ci/code_coverage/null_component.rb +24 -0
- data/lib/datadog/ci/code_coverage/transport.rb +66 -0
- data/lib/datadog/ci/configuration/components.rb +45 -29
- data/lib/datadog/ci/configuration/settings.rb +20 -2
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +11 -11
- data/lib/datadog/ci/contrib/knapsack/runner.rb +4 -4
- data/lib/datadog/ci/contrib/minitest/helpers.rb +2 -2
- data/lib/datadog/ci/contrib/minitest/runnable_minitest_6.rb +2 -2
- data/lib/datadog/ci/contrib/minitest/runner.rb +5 -5
- data/lib/datadog/ci/contrib/minitest/test.rb +5 -5
- data/lib/datadog/ci/contrib/parallel_tests/cli.rb +7 -7
- data/lib/datadog/ci/contrib/rspec/example.rb +220 -62
- data/lib/datadog/ci/contrib/rspec/example_group.rb +67 -35
- data/lib/datadog/ci/contrib/rspec/runner.rb +4 -4
- data/lib/datadog/ci/contrib/simplecov/ext.rb +2 -0
- data/lib/datadog/ci/contrib/simplecov/patcher.rb +2 -0
- data/lib/datadog/ci/contrib/simplecov/report_uploader.rb +59 -0
- data/lib/datadog/ci/ext/environment/providers/github_actions.rb +65 -2
- data/lib/datadog/ci/ext/environment.rb +10 -0
- data/lib/datadog/ci/ext/settings.rb +2 -0
- data/lib/datadog/ci/ext/telemetry.rb +5 -0
- data/lib/datadog/ci/ext/test.rb +0 -5
- data/lib/datadog/ci/ext/transport.rb +4 -0
- data/lib/datadog/ci/git/cli.rb +59 -1
- data/lib/datadog/ci/git/tree_uploader.rb +4 -4
- data/lib/datadog/ci/logs/component.rb +3 -3
- data/lib/datadog/ci/remote/component.rb +12 -7
- data/lib/datadog/ci/remote/library_settings.rb +8 -0
- data/lib/datadog/ci/span.rb +3 -3
- data/lib/datadog/ci/test.rb +31 -22
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/component.rb +173 -21
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/coverage/ddcov.rb +1 -1
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/coverage/event.rb +1 -1
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/coverage/transport.rb +1 -1
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/null_component.rb +21 -7
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/skippable.rb +1 -1
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/skippable_percentage/base.rb +9 -9
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/skippable_percentage/calculator.rb +5 -5
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/skippable_percentage/estimator.rb +3 -3
- data/lib/datadog/ci/{test_optimisation → test_impact_analysis}/telemetry.rb +3 -3
- data/lib/datadog/ci/test_management/component.rb +9 -0
- data/lib/datadog/ci/test_management/null_component.rb +8 -0
- data/lib/datadog/ci/test_module.rb +1 -1
- data/lib/datadog/ci/test_retries/component.rb +7 -0
- data/lib/datadog/ci/test_retries/driver/base.rb +4 -0
- data/lib/datadog/ci/test_retries/driver/no_retry.rb +4 -0
- data/lib/datadog/ci/test_retries/driver/retry_flake_detection.rb +15 -2
- data/lib/datadog/ci/test_retries/driver/retry_flaky_fixed.rb +7 -3
- data/lib/datadog/ci/test_retries/strategy/retry_flaky_fixed.rb +1 -1
- data/lib/datadog/ci/test_session.rb +2 -2
- data/lib/datadog/ci/test_suite.rb +17 -22
- data/lib/datadog/ci/{test_visibility → test_tracing}/component.rb +12 -13
- data/lib/datadog/ci/{test_visibility → test_tracing}/context.rb +7 -7
- data/lib/datadog/ci/{test_visibility/total_coverage.rb → test_tracing/deprecated_total_coverage_metric.rb} +2 -2
- data/lib/datadog/ci/{test_visibility → test_tracing}/flush.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/known_tests.rb +60 -7
- data/lib/datadog/ci/{test_visibility → test_tracing}/null_component.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/null_transport.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/base.rb +3 -3
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/factories/test_level.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/factories/test_suite_level.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/span.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/test_module.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/test_session.rb +2 -2
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/test_suite.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/test_v1.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/serializers/test_v2.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/store/fiber_local.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/store/process.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/telemetry.rb +1 -1
- data/lib/datadog/ci/{test_visibility → test_tracing}/transport.rb +8 -8
- data/lib/datadog/ci/transport/api/agentless.rb +8 -1
- data/lib/datadog/ci/transport/api/base.rb +21 -0
- data/lib/datadog/ci/transport/api/builder.rb +5 -1
- data/lib/datadog/ci/transport/api/evp_proxy.rb +8 -0
- data/lib/datadog/ci/utils/bundle.rb +14 -0
- data/lib/datadog/ci/utils/stateful.rb +2 -2
- data/lib/datadog/ci/version.rb +1 -1
- data/lib/datadog/ci.rb +15 -15
- metadata +35 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9b1bc98a924cc6601633633b9feb70bf48f79872266845b55505f1c5cd12837
|
|
4
|
+
data.tar.gz: e3aa6b68b3d65959178370fb7c4f2ee26094efb8de1da9e7f22d0b35e0a07729
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0562103f425826f918fd9c2c53ceacdb27e6e19280fd2e9ce47c67e1a7da631ab0b4c6dcf2fe28868aa166f5c5822b160a539f6f65ec462d5f7417c4d491a58
|
|
7
|
+
data.tar.gz: 4dbf986a49b767d5bc579800bd89716ef24f3263017c40c3410026fc879a5774626bb84f572386eb7ed93298031ed680ccbf1e7ff280061ba2d5d3674ab5c8fe
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [1.28.0] - 2026-02-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
* Early exit test retries when further retries no longer provide value ([#473][])
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
* Fix source location tags for specs created by rswag-specs ([#468][])
|
|
12
|
+
|
|
13
|
+
## [1.27.0] - 2026-01-22
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
* Add context-level code coverage tracking for RSpec to improve Test Impact Analysis correctness ([#460][])
|
|
19
|
+
* Add automatic uploading of code coverage reports to Datadog Code Coverage product ([#456][])
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
* Use pagination for known tests API ([#455][]) ([#458][])
|
|
24
|
+
* GitHub Actions: extract numeric job ID for accurate job URLs ([#457][])
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
* RSpec: take into account Test Management disabled tests when deciding to skip context hooks ([#463][])
|
|
29
|
+
* Fix for attempt-to-fix flow: don't mask failures for flaky tests being fixed ([#464][])
|
|
30
|
+
* Pass -c safe.directory to all git commands to fix dubious ownership errors ([#454][])
|
|
31
|
+
* fix: rename DD_TRACE_CI_ENABLED to DD_CIVISIBILITY_ENABLED with backwards compatibility ([#453][])
|
|
32
|
+
|
|
3
33
|
## [1.26.0] - 2026-01-09
|
|
4
34
|
|
|
5
35
|
========== Changelog ==========
|
|
@@ -578,7 +608,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
|
578
608
|
|
|
579
609
|
- Ruby versions < 2.7 no longer supported ([#8][])
|
|
580
610
|
|
|
581
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.
|
|
611
|
+
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.28.0...main
|
|
612
|
+
[1.28.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.27.0...v1.28.0
|
|
613
|
+
[1.27.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.26.0...v1.27.0
|
|
582
614
|
[1.26.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.25.0...v1.26.0
|
|
583
615
|
[1.25.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.24.0...v1.25.0
|
|
584
616
|
[1.24.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.23.3...v1.24.0
|
|
@@ -819,4 +851,15 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
|
819
851
|
[#440]: https://github.com/DataDog/datadog-ci-rb/issues/440
|
|
820
852
|
[#442]: https://github.com/DataDog/datadog-ci-rb/issues/442
|
|
821
853
|
[#444]: https://github.com/DataDog/datadog-ci-rb/issues/444
|
|
822
|
-
[#446]: https://github.com/DataDog/datadog-ci-rb/issues/446
|
|
854
|
+
[#446]: https://github.com/DataDog/datadog-ci-rb/issues/446
|
|
855
|
+
[#453]: https://github.com/DataDog/datadog-ci-rb/issues/453
|
|
856
|
+
[#454]: https://github.com/DataDog/datadog-ci-rb/issues/454
|
|
857
|
+
[#455]: https://github.com/DataDog/datadog-ci-rb/issues/455
|
|
858
|
+
[#456]: https://github.com/DataDog/datadog-ci-rb/issues/456
|
|
859
|
+
[#457]: https://github.com/DataDog/datadog-ci-rb/issues/457
|
|
860
|
+
[#458]: https://github.com/DataDog/datadog-ci-rb/issues/458
|
|
861
|
+
[#460]: https://github.com/DataDog/datadog-ci-rb/issues/460
|
|
862
|
+
[#463]: https://github.com/DataDog/datadog-ci-rb/issues/463
|
|
863
|
+
[#464]: https://github.com/DataDog/datadog-ci-rb/issues/464
|
|
864
|
+
[#468]: https://github.com/DataDog/datadog-ci-rb/issues/468
|
|
865
|
+
[#473]: https://github.com/DataDog/datadog-ci-rb/issues/473
|
|
@@ -381,8 +381,8 @@ static VALUE dd_cov_stop(VALUE self) {
|
|
|
381
381
|
void Init_datadog_cov(void) {
|
|
382
382
|
VALUE mDatadog = rb_define_module("Datadog");
|
|
383
383
|
VALUE mCI = rb_define_module_under(mDatadog, "CI");
|
|
384
|
-
VALUE
|
|
385
|
-
VALUE mCoverage = rb_define_module_under(
|
|
384
|
+
VALUE mTestImpactAnalysis = rb_define_module_under(mCI, "TestImpactAnalysis");
|
|
385
|
+
VALUE mCoverage = rb_define_module_under(mTestImpactAnalysis, "Coverage");
|
|
386
386
|
VALUE cDatadogCov = rb_define_class_under(mCoverage, "DDCov", rb_cObject);
|
|
387
387
|
|
|
388
388
|
rb_define_alloc_func(cDatadogCov, dd_cov_allocate);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require_relative "base"
|
|
2
|
-
require_relative "../../
|
|
2
|
+
require_relative "../../test_impact_analysis/skippable_percentage/calculator"
|
|
3
3
|
|
|
4
4
|
module Datadog
|
|
5
5
|
module CI
|
|
@@ -9,7 +9,7 @@ module Datadog
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
11
|
def build_action
|
|
12
|
-
::Datadog::CI::
|
|
12
|
+
::Datadog::CI::TestImpactAnalysis::SkippablePercentage::Calculator.new(
|
|
13
13
|
rspec_cli_options: (options[:"rspec-opts"] || "").split,
|
|
14
14
|
verbose: !options[:verbose].nil?,
|
|
15
15
|
spec_path: options[:"spec-path"] || "spec"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require_relative "base"
|
|
2
|
-
require_relative "../../
|
|
2
|
+
require_relative "../../test_impact_analysis/skippable_percentage/estimator"
|
|
3
3
|
|
|
4
4
|
module Datadog
|
|
5
5
|
module CI
|
|
@@ -9,7 +9,7 @@ module Datadog
|
|
|
9
9
|
private
|
|
10
10
|
|
|
11
11
|
def build_action
|
|
12
|
-
::Datadog::CI::
|
|
12
|
+
::Datadog::CI::TestImpactAnalysis::SkippablePercentage::Estimator.new(
|
|
13
13
|
verbose: !options[:verbose].nil?,
|
|
14
14
|
spec_path: options[:"spec-path"] || "spec"
|
|
15
15
|
)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../ext/environment"
|
|
4
|
+
require_relative "transport"
|
|
5
|
+
|
|
6
|
+
module Datadog
|
|
7
|
+
module CI
|
|
8
|
+
module CodeCoverage
|
|
9
|
+
# CodeCoverage component is responsible for uploading code coverage reports
|
|
10
|
+
# to Datadog's Code Coverage product.
|
|
11
|
+
class Component
|
|
12
|
+
COVERAGE_REPORT_TYPE = "coverage_report"
|
|
13
|
+
|
|
14
|
+
attr_reader :enabled
|
|
15
|
+
|
|
16
|
+
def initialize(enabled:, transport:)
|
|
17
|
+
@enabled = enabled
|
|
18
|
+
@transport = transport
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def configure(library_configuration)
|
|
22
|
+
@enabled &&= library_configuration.coverage_report_upload_enabled?
|
|
23
|
+
|
|
24
|
+
Datadog.logger.debug do
|
|
25
|
+
"[#{self.class.name}] Configured with enabled=#{@enabled}"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def upload(serialized_report:, format:)
|
|
30
|
+
return unless @enabled
|
|
31
|
+
return if serialized_report.nil?
|
|
32
|
+
|
|
33
|
+
Datadog.logger.debug { "[#{self.class.name}] Uploading coverage report..." }
|
|
34
|
+
|
|
35
|
+
event = build_event(format)
|
|
36
|
+
|
|
37
|
+
@transport.send_coverage_report(event: event, coverage_report: serialized_report)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def shutdown!
|
|
41
|
+
# noop - transport is synchronous
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def build_event(format)
|
|
47
|
+
{
|
|
48
|
+
"type" => COVERAGE_REPORT_TYPE,
|
|
49
|
+
"format" => format
|
|
50
|
+
}.merge(Ext::Environment.tags(ENV))
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Datadog
|
|
4
|
+
module CI
|
|
5
|
+
module CodeCoverage
|
|
6
|
+
class NullComponent
|
|
7
|
+
attr_reader :enabled
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@enabled = false
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def configure(library_configuration)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def upload(serialized_report:, format:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def shutdown!
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
require_relative "../ext/telemetry"
|
|
6
|
+
require_relative "../ext/transport"
|
|
7
|
+
require_relative "../transport/gzip"
|
|
8
|
+
require_relative "../transport/telemetry"
|
|
9
|
+
require_relative "../utils/telemetry"
|
|
10
|
+
|
|
11
|
+
module Datadog
|
|
12
|
+
module CI
|
|
13
|
+
module CodeCoverage
|
|
14
|
+
class Transport
|
|
15
|
+
attr_reader :api
|
|
16
|
+
|
|
17
|
+
def initialize(api:)
|
|
18
|
+
@api = api
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def send_coverage_report(event:, coverage_report:)
|
|
22
|
+
return nil if api.nil?
|
|
23
|
+
|
|
24
|
+
Datadog.logger.debug { "[#{self.class.name}] Sending coverage report..." }
|
|
25
|
+
|
|
26
|
+
compressed_coverage_report = CI::Transport::Gzip.compress(coverage_report)
|
|
27
|
+
event_json = event.to_json
|
|
28
|
+
|
|
29
|
+
response = api.cicovreprt_request(
|
|
30
|
+
path: Ext::Transport::CODE_COVERAGE_REPORT_INTAKE_PATH,
|
|
31
|
+
event_payload: event_json,
|
|
32
|
+
compressed_coverage_report: compressed_coverage_report
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
CI::Transport::Telemetry.api_requests(
|
|
36
|
+
Ext::Telemetry::METRIC_COVERAGE_UPLOAD_REQUEST,
|
|
37
|
+
1,
|
|
38
|
+
compressed: response.request_compressed
|
|
39
|
+
)
|
|
40
|
+
Utils::Telemetry.distribution(
|
|
41
|
+
Ext::Telemetry::METRIC_COVERAGE_UPLOAD_REQUEST_MS,
|
|
42
|
+
response.duration_ms
|
|
43
|
+
)
|
|
44
|
+
Utils::Telemetry.distribution(
|
|
45
|
+
Ext::Telemetry::METRIC_COVERAGE_UPLOAD_REQUEST_BYTES,
|
|
46
|
+
compressed_coverage_report.bytesize.to_f,
|
|
47
|
+
{Ext::Telemetry::TAG_REQUEST_COMPRESSED => response.request_compressed.to_s}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
unless response.ok?
|
|
51
|
+
CI::Transport::Telemetry.api_requests_errors(
|
|
52
|
+
Ext::Telemetry::METRIC_COVERAGE_UPLOAD_REQUEST_ERRORS,
|
|
53
|
+
1,
|
|
54
|
+
error_type: response.telemetry_error_type,
|
|
55
|
+
status_code: response.code
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
Datadog.logger.warn { "[#{self.class.name}] Failed to send coverage report: #{response.inspect}" }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
response
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
require "datadog/core/telemetry/ext"
|
|
4
4
|
|
|
5
5
|
require_relative "../ext/settings"
|
|
6
|
+
require_relative "../code_coverage/component"
|
|
7
|
+
require_relative "../code_coverage/null_component"
|
|
8
|
+
require_relative "../code_coverage/transport"
|
|
6
9
|
require_relative "../git/tree_uploader"
|
|
7
10
|
require_relative "../impacted_tests_detection/component"
|
|
8
11
|
require_relative "../impacted_tests_detection/null_component"
|
|
@@ -14,21 +17,21 @@ require_relative "../remote/library_settings_client"
|
|
|
14
17
|
require_relative "../test_management/component"
|
|
15
18
|
require_relative "../test_management/null_component"
|
|
16
19
|
require_relative "../test_management/tests_properties"
|
|
17
|
-
require_relative "../
|
|
18
|
-
require_relative "../
|
|
19
|
-
require_relative "../
|
|
20
|
+
require_relative "../test_impact_analysis/null_component"
|
|
21
|
+
require_relative "../test_impact_analysis/component"
|
|
22
|
+
require_relative "../test_impact_analysis/coverage/transport"
|
|
20
23
|
require_relative "../test_retries/component"
|
|
21
24
|
require_relative "../test_retries/null_component"
|
|
22
25
|
require_relative "../test_discovery/component"
|
|
23
26
|
require_relative "../test_discovery/null_component"
|
|
24
|
-
require_relative "../
|
|
25
|
-
require_relative "../
|
|
26
|
-
require_relative "../
|
|
27
|
-
require_relative "../
|
|
28
|
-
require_relative "../
|
|
29
|
-
require_relative "../
|
|
30
|
-
require_relative "../
|
|
31
|
-
require_relative "../
|
|
27
|
+
require_relative "../test_tracing/component"
|
|
28
|
+
require_relative "../test_tracing/flush"
|
|
29
|
+
require_relative "../test_tracing/known_tests"
|
|
30
|
+
require_relative "../test_tracing/null_component"
|
|
31
|
+
require_relative "../test_tracing/serializers/factories/test_level"
|
|
32
|
+
require_relative "../test_tracing/serializers/factories/test_suite_level"
|
|
33
|
+
require_relative "../test_tracing/null_transport"
|
|
34
|
+
require_relative "../test_tracing/transport"
|
|
32
35
|
require_relative "../transport/adapters/telemetry_webmock_safe_adapter"
|
|
33
36
|
require_relative "../transport/api/builder"
|
|
34
37
|
require_relative "../utils/parsing"
|
|
@@ -41,18 +44,19 @@ module Datadog
|
|
|
41
44
|
module Configuration
|
|
42
45
|
# Adds CI behavior to Datadog trace components
|
|
43
46
|
module Components
|
|
44
|
-
attr_reader :
|
|
45
|
-
:test_management, :agentless_logs_submission, :impacted_tests_detection, :test_discovery
|
|
47
|
+
attr_reader :test_tracing, :test_impact_analysis, :git_tree_upload_worker, :ci_remote, :test_retries,
|
|
48
|
+
:test_management, :agentless_logs_submission, :impacted_tests_detection, :test_discovery, :code_coverage
|
|
46
49
|
|
|
47
50
|
def initialize(settings)
|
|
48
|
-
@
|
|
49
|
-
@
|
|
51
|
+
@test_impact_analysis = TestImpactAnalysis::NullComponent.new
|
|
52
|
+
@test_tracing = TestTracing::NullComponent.new
|
|
50
53
|
@git_tree_upload_worker = DummyWorker.new
|
|
51
54
|
@ci_remote = Remote::NullComponent.new
|
|
52
55
|
@test_retries = TestRetries::NullComponent.new
|
|
53
56
|
@test_management = TestManagement::NullComponent.new
|
|
54
57
|
@impacted_tests_detection = ImpactedTestsDetection::NullComponent.new
|
|
55
58
|
@test_discovery = TestDiscovery::NullComponent.new
|
|
59
|
+
@code_coverage = CodeCoverage::NullComponent.new
|
|
56
60
|
|
|
57
61
|
# Activate CI mode if enabled
|
|
58
62
|
if settings.ci.enabled
|
|
@@ -65,10 +69,11 @@ module Datadog
|
|
|
65
69
|
def shutdown!(replacement = nil)
|
|
66
70
|
super
|
|
67
71
|
|
|
68
|
-
@
|
|
69
|
-
@
|
|
72
|
+
@test_tracing&.shutdown!
|
|
73
|
+
@test_impact_analysis&.shutdown!
|
|
70
74
|
@agentless_logs_submission&.shutdown!
|
|
71
75
|
@test_discovery&.shutdown!
|
|
76
|
+
@code_coverage&.shutdown!
|
|
72
77
|
@git_tree_upload_worker&.stop
|
|
73
78
|
end
|
|
74
79
|
|
|
@@ -117,7 +122,7 @@ module Datadog
|
|
|
117
122
|
# Activate underlying tracing test mode with async worker
|
|
118
123
|
settings.tracing.test_mode.enabled = true
|
|
119
124
|
settings.tracing.test_mode.async = true
|
|
120
|
-
settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::
|
|
125
|
+
settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestTracing::Flush::Partial.new
|
|
121
126
|
|
|
122
127
|
trace_writer_options = settings.ci.writer_options
|
|
123
128
|
trace_writer_options[:shutdown_timeout] = 60
|
|
@@ -146,9 +151,9 @@ module Datadog
|
|
|
146
151
|
tests_properties_client: TestManagement::TestsProperties.new(api: test_visibility_api)
|
|
147
152
|
)
|
|
148
153
|
|
|
149
|
-
# @type ivar @
|
|
150
|
-
@
|
|
151
|
-
@
|
|
154
|
+
# @type ivar @test_impact_analysis: Datadog::CI::TestImpactAnalysis::Component
|
|
155
|
+
@test_impact_analysis = build_test_impact_analysis(settings, test_visibility_api)
|
|
156
|
+
@test_tracing = TestTracing::Component.new(
|
|
152
157
|
test_suite_level_visibility_enabled: !settings.ci.force_test_level_visibility,
|
|
153
158
|
logical_test_session_name: settings.ci.test_session_name,
|
|
154
159
|
known_tests_client: build_known_tests_client(settings, test_visibility_api),
|
|
@@ -158,9 +163,11 @@ module Datadog
|
|
|
158
163
|
@agentless_logs_submission = build_agentless_logs_component(settings, test_visibility_api)
|
|
159
164
|
|
|
160
165
|
@impacted_tests_detection = ImpactedTestsDetection::Component.new(enabled: settings.ci.impacted_tests_detection_enabled)
|
|
166
|
+
|
|
167
|
+
@code_coverage = build_code_coverage(settings, test_visibility_api)
|
|
161
168
|
end
|
|
162
169
|
|
|
163
|
-
def
|
|
170
|
+
def build_test_impact_analysis(settings, test_visibility_api)
|
|
164
171
|
if settings.ci.itr_code_coverage_use_single_threaded_mode &&
|
|
165
172
|
settings.ci.itr_test_impact_analysis_use_allocation_tracing
|
|
166
173
|
Datadog.logger.warn(
|
|
@@ -184,7 +191,7 @@ module Datadog
|
|
|
184
191
|
settings.ci.itr_test_impact_analysis_use_allocation_tracing = false
|
|
185
192
|
end
|
|
186
193
|
|
|
187
|
-
|
|
194
|
+
TestImpactAnalysis::Component.new(
|
|
188
195
|
api: test_visibility_api,
|
|
189
196
|
dd_env: settings.env,
|
|
190
197
|
config_tags: custom_configuration(settings),
|
|
@@ -236,11 +243,11 @@ module Datadog
|
|
|
236
243
|
|
|
237
244
|
def build_tracing_transport(settings, api)
|
|
238
245
|
# NullTransport ignores traces
|
|
239
|
-
return
|
|
246
|
+
return TestTracing::NullTransport.new if settings.ci.discard_traces
|
|
240
247
|
# nil means that default legacy APM transport will be used (only for very old Datadog Agent versions)
|
|
241
248
|
return nil if api.nil?
|
|
242
249
|
|
|
243
|
-
|
|
250
|
+
TestTracing::Transport.new(
|
|
244
251
|
api: api,
|
|
245
252
|
serializers_factory: serializers_factory(settings),
|
|
246
253
|
dd_env: settings.env
|
|
@@ -252,7 +259,7 @@ module Datadog
|
|
|
252
259
|
return nil if api.nil? || settings.ci.discard_traces
|
|
253
260
|
|
|
254
261
|
AsyncWriter.new(
|
|
255
|
-
transport:
|
|
262
|
+
transport: TestImpactAnalysis::Coverage::Transport.new(api: api)
|
|
256
263
|
)
|
|
257
264
|
end
|
|
258
265
|
|
|
@@ -276,13 +283,22 @@ module Datadog
|
|
|
276
283
|
end
|
|
277
284
|
|
|
278
285
|
def build_known_tests_client(settings, api)
|
|
279
|
-
|
|
286
|
+
TestTracing::KnownTests.new(
|
|
280
287
|
api: api,
|
|
281
288
|
dd_env: settings.env,
|
|
282
289
|
config_tags: custom_configuration(settings)
|
|
283
290
|
)
|
|
284
291
|
end
|
|
285
292
|
|
|
293
|
+
def build_code_coverage(settings, api)
|
|
294
|
+
return CodeCoverage::NullComponent.new if api.nil? || settings.ci.discard_traces
|
|
295
|
+
|
|
296
|
+
CodeCoverage::Component.new(
|
|
297
|
+
enabled: settings.ci.code_coverage_report_upload_enabled,
|
|
298
|
+
transport: CodeCoverage::Transport.new(api: api)
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
286
302
|
def build_agentless_logs_component(settings, api)
|
|
287
303
|
if settings.ci.agentless_logs_submission_enabled && !settings.ci.agentless_mode_enabled
|
|
288
304
|
Datadog.logger.warn(
|
|
@@ -314,9 +330,9 @@ module Datadog
|
|
|
314
330
|
|
|
315
331
|
def serializers_factory(settings)
|
|
316
332
|
if settings.ci.force_test_level_visibility
|
|
317
|
-
|
|
333
|
+
TestTracing::Serializers::Factories::TestLevel
|
|
318
334
|
else
|
|
319
|
-
|
|
335
|
+
TestTracing::Serializers::Factories::TestSuiteLevel
|
|
320
336
|
end
|
|
321
337
|
end
|
|
322
338
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require_relative "../contrib/instrumentation"
|
|
4
4
|
require_relative "../ext/settings"
|
|
5
5
|
require_relative "../utils/bundle"
|
|
6
|
+
require_relative "../utils/parsing"
|
|
6
7
|
|
|
7
8
|
module Datadog
|
|
8
9
|
module CI
|
|
@@ -19,8 +20,19 @@ module Datadog
|
|
|
19
20
|
settings :ci do
|
|
20
21
|
option :enabled do |o|
|
|
21
22
|
o.type :bool
|
|
22
|
-
o.env CI::Ext::Settings::
|
|
23
|
-
o.default
|
|
23
|
+
o.env CI::Ext::Settings::ENV_ENABLED
|
|
24
|
+
o.default do
|
|
25
|
+
env_value = ENV[CI::Ext::Settings::ENV_MODE_ENABLED]
|
|
26
|
+
if env_value && !ENV[CI::Ext::Settings::ENV_ENABLED]
|
|
27
|
+
Datadog::Core.log_deprecation do
|
|
28
|
+
"#{CI::Ext::Settings::ENV_MODE_ENABLED} environment variable is deprecated, " \
|
|
29
|
+
"use #{CI::Ext::Settings::ENV_ENABLED} instead."
|
|
30
|
+
end
|
|
31
|
+
Utils::Parsing.convert_to_bool(env_value)
|
|
32
|
+
else
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
24
36
|
end
|
|
25
37
|
|
|
26
38
|
option :test_session_name do |o|
|
|
@@ -174,6 +186,12 @@ module Datadog
|
|
|
174
186
|
o.default false
|
|
175
187
|
end
|
|
176
188
|
|
|
189
|
+
option :code_coverage_report_upload_enabled do |o|
|
|
190
|
+
o.type :bool
|
|
191
|
+
o.env CI::Ext::Settings::ENV_CODE_COVERAGE_REPORT_UPLOAD_ENABLED
|
|
192
|
+
o.default true
|
|
193
|
+
end
|
|
194
|
+
|
|
177
195
|
define_method(:instrument) do |integration_name, options = {}, &block|
|
|
178
196
|
return unless enabled
|
|
179
197
|
|
|
@@ -36,14 +36,14 @@ module Datadog
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def on_test_run_started(event)
|
|
39
|
-
|
|
39
|
+
test_tracing_component.start_test_session(
|
|
40
40
|
tags: {
|
|
41
41
|
CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
|
|
42
42
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_integration.version.to_s
|
|
43
43
|
},
|
|
44
44
|
service: datadog_configuration[:service_name]
|
|
45
45
|
)
|
|
46
|
-
|
|
46
|
+
test_tracing_component.start_test_module(Ext::FRAMEWORK)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def on_test_run_finished(event)
|
|
@@ -78,7 +78,7 @@ module Datadog
|
|
|
78
78
|
)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
test_span =
|
|
81
|
+
test_span = test_tracing_component.trace_test(
|
|
82
82
|
event.test_case.name,
|
|
83
83
|
test_suite_name,
|
|
84
84
|
tags: tags,
|
|
@@ -90,18 +90,18 @@ module Datadog
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def on_test_case_finished(event)
|
|
93
|
-
test_span =
|
|
93
|
+
test_span = test_tracing_component.active_test
|
|
94
94
|
return if test_span.nil?
|
|
95
95
|
|
|
96
96
|
finish_span(test_span, event.result)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def on_test_step_started(event)
|
|
100
|
-
|
|
100
|
+
test_tracing_component.trace(event.test_step.to_s, type: Ext::STEP_SPAN_TYPE)
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def on_test_step_finished(event)
|
|
104
|
-
current_step_span =
|
|
104
|
+
current_step_span = test_tracing_component.active_span
|
|
105
105
|
return if current_step_span.nil?
|
|
106
106
|
|
|
107
107
|
finish_span(current_step_span, event.result)
|
|
@@ -135,8 +135,8 @@ module Datadog
|
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
def finish_session(result)
|
|
138
|
-
test_session =
|
|
139
|
-
test_module =
|
|
138
|
+
test_session = test_tracing_component.active_test_session
|
|
139
|
+
test_module = test_tracing_component.active_test_module
|
|
140
140
|
|
|
141
141
|
return unless test_session && test_module
|
|
142
142
|
|
|
@@ -155,7 +155,7 @@ module Datadog
|
|
|
155
155
|
def start_test_suite(test_suite_name, tags: {})
|
|
156
156
|
finish_current_test_suite
|
|
157
157
|
|
|
158
|
-
@current_test_suite =
|
|
158
|
+
@current_test_suite = test_tracing_component.start_test_suite(test_suite_name, tags: tags)
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
def finish_current_test_suite
|
|
@@ -208,8 +208,8 @@ module Datadog
|
|
|
208
208
|
Datadog.configuration.ci[:cucumber]
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
-
def
|
|
212
|
-
Datadog.send(:components).
|
|
211
|
+
def test_tracing_component
|
|
212
|
+
Datadog.send(:components).test_tracing
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
def test_suite_source_file_tags(test_case)
|
|
@@ -20,7 +20,7 @@ module Datadog
|
|
|
20
20
|
return super unless datadog_configuration[:enabled]
|
|
21
21
|
|
|
22
22
|
# @type var test_session: Datadog::CI::TestSession?
|
|
23
|
-
test_session =
|
|
23
|
+
test_session = test_tracing_component.start_test_session(
|
|
24
24
|
tags: {
|
|
25
25
|
CI::Ext::Test::TAG_FRAMEWORK => CI::Contrib::RSpec::Ext::FRAMEWORK,
|
|
26
26
|
CI::Ext::Test::TAG_FRAMEWORK_VERSION => datadog_integration.version.to_s
|
|
@@ -29,7 +29,7 @@ module Datadog
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
# @type var test_module: Datadog::CI::TestModule?
|
|
32
|
-
test_module =
|
|
32
|
+
test_module = test_tracing_component.start_test_module(CI::Contrib::RSpec::Ext::FRAMEWORK)
|
|
33
33
|
|
|
34
34
|
result = super
|
|
35
35
|
return result unless test_module && test_session
|
|
@@ -57,8 +57,8 @@ module Datadog
|
|
|
57
57
|
Datadog.configuration.ci[:rspec]
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
def
|
|
61
|
-
Datadog.send(:components).
|
|
60
|
+
def test_tracing_component
|
|
61
|
+
Datadog.send(:components).test_tracing
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -23,8 +23,8 @@ module Datadog
|
|
|
23
23
|
{}
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
test_suite =
|
|
26
|
+
test_tracing_component = Datadog.send(:components).test_tracing
|
|
27
|
+
test_suite = test_tracing_component.start_test_suite(
|
|
28
28
|
test_suite_name,
|
|
29
29
|
tags: test_suite_tags
|
|
30
30
|
)
|
|
@@ -34,8 +34,8 @@ module Datadog
|
|
|
34
34
|
Datadog.configuration.ci[:minitest]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def
|
|
38
|
-
Datadog.send(:components).
|
|
37
|
+
def _dd_test_tracing_component
|
|
38
|
+
Datadog.send(:components).test_tracing
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def _dd_test_retries_component
|