From 48f786b90eb5754eacb7976dcb4a979455ca7967 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Mon, 18 Sep 2023 16:46:19 +0200 Subject: [PATCH] rename Ci::Test to CI::Recorder --- lib/datadog/ci/contrib/cucumber/formatter.rb | 19 +++++++++---------- lib/datadog/ci/contrib/minitest/hooks.rb | 13 +++++++++---- lib/datadog/ci/contrib/rspec/example.rb | 14 ++++++-------- lib/datadog/ci/{test.rb => recorder.rb} | 2 +- sig/datadog/ci/{test.rbs => recorder.rbs} | 2 +- .../ci/{test_spec.rb => recorder_spec.rb} | 2 +- 6 files changed, 27 insertions(+), 25 deletions(-) rename lib/datadog/ci/{test.rb => recorder.rb} (99%) rename sig/datadog/ci/{test.rbs => recorder.rbs} (96%) rename spec/datadog/ci/{test_spec.rb => recorder_spec.rb} (99%) diff --git a/lib/datadog/ci/contrib/cucumber/formatter.rb b/lib/datadog/ci/contrib/cucumber/formatter.rb index 150218ac..60238066 100644 --- a/lib/datadog/ci/contrib/cucumber/formatter.rb +++ b/lib/datadog/ci/contrib/cucumber/formatter.rb @@ -1,10 +1,9 @@ # frozen_string_literal: true -require_relative "../../test" -require_relative "../../ext/app_types" -require_relative "../../ext/environment" +require_relative "../../recorder" require_relative "../../ext/test" require_relative "ext" +require_relative "integration" module Datadog module CI @@ -30,7 +29,7 @@ def bind_events(config) end def on_test_case_started(event) - @current_feature_span = CI::Test.trace( + @current_feature_span = CI::Recorder.trace( configuration[:operation_name], { span_options: { @@ -50,11 +49,11 @@ def on_test_case_finished(event) return if @current_feature_span.nil? if event.result.skipped? - CI::Test.skipped!(@current_feature_span) + CI::Recorder.skipped!(@current_feature_span) elsif event.result.ok? - CI::Test.passed!(@current_feature_span) + CI::Recorder.passed!(@current_feature_span) elsif event.result.failed? - CI::Test.failed!(@current_feature_span) + CI::Recorder.failed!(@current_feature_span) end @current_feature_span.finish @@ -72,11 +71,11 @@ def on_test_step_finished(event) return if @current_step_span.nil? if event.result.skipped? - CI::Test.skipped!(@current_step_span, event.result.exception) + CI::Recorder.skipped!(@current_step_span, event.result.exception) elsif event.result.ok? - CI::Test.passed!(@current_step_span) + CI::Recorder.passed!(@current_step_span) elsif event.result.failed? - CI::Test.failed!(@current_step_span, event.result.exception) + CI::Recorder.failed!(@current_step_span, event.result.exception) end @current_step_span.finish diff --git a/lib/datadog/ci/contrib/minitest/hooks.rb b/lib/datadog/ci/contrib/minitest/hooks.rb index 0bb61195..3e72c156 100644 --- a/lib/datadog/ci/contrib/minitest/hooks.rb +++ b/lib/datadog/ci/contrib/minitest/hooks.rb @@ -1,5 +1,10 @@ # frozen_string_literal: true +require_relative "../../recorder" +require_relative "../../ext/test" +require_relative "ext" +require_relative "integration" + module Datadog module CI module Contrib @@ -15,7 +20,7 @@ def before_setup path, = method(name).source_location test_suite = Pathname.new(path.to_s).relative_path_from(Pathname.pwd).to_s - span = CI::Test.trace( + span = CI::Recorder.trace( configuration[:operation_name], { span_options: { @@ -41,11 +46,11 @@ def after_teardown case result_code when "." - CI::Test.passed!(span) + CI::Recorder.passed!(span) when "E", "F" - CI::Test.failed!(span, failure) + CI::Recorder.failed!(span, failure) when "S" - CI::Test.skipped!(span) + CI::Recorder.skipped!(span) span.set_tag(CI::Ext::Test::TAG_SKIP_REASON, failure.message) end diff --git a/lib/datadog/ci/contrib/rspec/example.rb b/lib/datadog/ci/contrib/rspec/example.rb index e45e26c6..85316b53 100644 --- a/lib/datadog/ci/contrib/rspec/example.rb +++ b/lib/datadog/ci/contrib/rspec/example.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true -require_relative "../../test" - -require_relative "../../ext/app_types" -require_relative "../../ext/environment" +require_relative "../../recorder" require_relative "../../ext/test" require_relative "ext" +require_relative "integration" module Datadog module CI @@ -28,7 +26,7 @@ def run(example_group_instance, reporter) test_name += " #{description}" end - CI::Test.trace( + CI::Recorder.trace( configuration[:operation_name], { span_options: { @@ -46,11 +44,11 @@ def run(example_group_instance, reporter) case execution_result.status when :passed - CI::Test.passed!(span) + CI::Recorder.passed!(span) when :failed - CI::Test.failed!(span, execution_result.exception) + CI::Recorder.failed!(span, execution_result.exception) else - CI::Test.skipped!(span, execution_result.exception) if execution_result.example_skipped? + CI::Recorder.skipped!(span, execution_result.exception) if execution_result.example_skipped? end result diff --git a/lib/datadog/ci/test.rb b/lib/datadog/ci/recorder.rb similarity index 99% rename from lib/datadog/ci/test.rb rename to lib/datadog/ci/recorder.rb index 04e5c132..a298f2ad 100644 --- a/lib/datadog/ci/test.rb +++ b/lib/datadog/ci/recorder.rb @@ -12,7 +12,7 @@ module Datadog module CI # Common behavior for CI tests - module Test + module Recorder # Creates a new span for a CI test def self.trace(span_name, options = {}) span_options = { diff --git a/sig/datadog/ci/test.rbs b/sig/datadog/ci/recorder.rbs similarity index 96% rename from sig/datadog/ci/test.rbs rename to sig/datadog/ci/recorder.rbs index 7943c29a..248cfe9b 100644 --- a/sig/datadog/ci/test.rbs +++ b/sig/datadog/ci/recorder.rbs @@ -1,6 +1,6 @@ module Datadog module CI - module Test + module Recorder self.@environment_tags: Hash[String, String] def self.trace: (untyped span_name, ?::Hash[untyped, untyped] options) ?{ (untyped, untyped) -> untyped } -> untyped diff --git a/spec/datadog/ci/test_spec.rb b/spec/datadog/ci/recorder_spec.rb similarity index 99% rename from spec/datadog/ci/test_spec.rb rename to spec/datadog/ci/recorder_spec.rb index fefcbcae..cee9efac 100644 --- a/spec/datadog/ci/test_spec.rb +++ b/spec/datadog/ci/recorder_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe Datadog::CI::Test do +RSpec.describe Datadog::CI::Recorder do let(:trace_op) { instance_double(Datadog::Tracing::TraceOperation) } let(:span_name) { "span name" }