diff --git a/lib/datadog/ci/configuration/settings.rb b/lib/datadog/ci/configuration/settings.rb index b47c759f..3d7f8a80 100644 --- a/lib/datadog/ci/configuration/settings.rb +++ b/lib/datadog/ci/configuration/settings.rb @@ -106,6 +106,12 @@ def self.add_settings!(base) o.default 1000 end + option :retry_new_tests_enabled do |o| + o.type :bool + o.env CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED + o.default true + end + define_method(:instrument) do |integration_name, options = {}, &block| return unless enabled diff --git a/lib/datadog/ci/ext/settings.rb b/lib/datadog/ci/ext/settings.rb index f422955f..a318ee26 100644 --- a/lib/datadog/ci/ext/settings.rb +++ b/lib/datadog/ci/ext/settings.rb @@ -18,6 +18,7 @@ module Settings ENV_RETRY_FAILED_TESTS_ENABLED = "DD_CIVISIBILITY_FLAKY_RETRY_ENABLED" ENV_RETRY_FAILED_TESTS_MAX_ATTEMPTS = "DD_CIVISIBILITY_FLAKY_RETRY_COUNT" ENV_RETRY_FAILED_TESTS_TOTAL_LIMIT = "DD_CIVISIBILITY_TOTAL_FLAKY_RETRY_COUNT" + ENV_RETRY_NEW_TESTS_ENABLED = "DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED" # Source: https://docs.datadoghq.com/getting_started/site/ DD_SITE_ALLOWLIST = %w[ diff --git a/sig/datadog/ci/ext/settings.rbs b/sig/datadog/ci/ext/settings.rbs index d60d0200..d96adf24 100644 --- a/sig/datadog/ci/ext/settings.rbs +++ b/sig/datadog/ci/ext/settings.rbs @@ -15,6 +15,7 @@ module Datadog ENV_RETRY_FAILED_TESTS_ENABLED: String ENV_RETRY_FAILED_TESTS_MAX_ATTEMPTS: String ENV_RETRY_FAILED_TESTS_TOTAL_LIMIT: String + ENV_RETRY_NEW_TESTS_ENABLED: String DD_SITE_ALLOWLIST: Array[String] end diff --git a/spec/datadog/ci/configuration/settings_spec.rb b/spec/datadog/ci/configuration/settings_spec.rb index e5b7be6b..b70eae46 100644 --- a/spec/datadog/ci/configuration/settings_spec.rb +++ b/spec/datadog/ci/configuration/settings_spec.rb @@ -501,6 +501,47 @@ def patcher end end + describe "#retry_new_tests_enabled" do + subject(:retry_new_tests_enabled) { settings.ci.retry_new_tests_enabled } + + it { is_expected.to be true } + + context "when #{Datadog::CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED}" do + around do |example| + ClimateControl.modify(Datadog::CI::Ext::Settings::ENV_RETRY_NEW_TESTS_ENABLED => enable) do + example.run + end + end + + context "is not defined" do + let(:enable) { nil } + + it { is_expected.to be true } + end + + context "is set to true" do + let(:enable) { "true" } + + it { is_expected.to be true } + end + + context "is set to false" do + let(:enable) { "false" } + + it { is_expected.to be false } + end + end + end + + describe "#retry_new_tests_enabled=" do + it "updates the #retry_failed_tests_enabled setting" do + expect { settings.ci.retry_new_tests_enabled = false } + .to change { settings.ci.retry_new_tests_enabled } + .from(true) + .to(false) + end + end + describe "#instrument" do let(:integration_name) { :fake }