-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from DataDog/anmarchenko/itr_settings
Remote library configuration support and ITR::Runner
- Loading branch information
Showing
39 changed files
with
1,684 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../ext/test" | ||
require_relative "../ext/transport" | ||
|
||
module Datadog | ||
module CI | ||
module ITR | ||
# Intelligent test runner implementation | ||
# Integrates with backend to provide test impact analysis data and | ||
# skip tests that are not impacted by the changes | ||
class Runner | ||
def initialize( | ||
enabled: false | ||
) | ||
@enabled = enabled | ||
@test_skipping_enabled = false | ||
@code_coverage_enabled = false | ||
|
||
Datadog.logger.debug("ITR Runner initialized with enabled: #{@enabled}") | ||
end | ||
|
||
def configure(remote_configuration, test_session) | ||
Datadog.logger.debug("Configuring ITR Runner with remote configuration: #{remote_configuration}") | ||
|
||
@enabled = convert_to_bool( | ||
remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_ITR_ENABLED_KEY, false) | ||
) | ||
@test_skipping_enabled = @enabled && convert_to_bool( | ||
remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_TESTS_SKIPPING_KEY, false) | ||
) | ||
@code_coverage_enabled = @enabled && convert_to_bool( | ||
remote_configuration.fetch(Ext::Transport::DD_API_SETTINGS_RESPONSE_CODE_COVERAGE_KEY, false) | ||
) | ||
|
||
test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_ENABLED, @test_skipping_enabled) | ||
# currently we set this tag when ITR requires collecting code coverage | ||
# this will change as soon as we implement total code coverage support in this library | ||
test_session.set_tag(Ext::Test::TAG_CODE_COVERAGE_ENABLED, @code_coverage_enabled) | ||
|
||
# we skip tests, not suites | ||
test_session.set_tag(Ext::Test::TAG_ITR_TEST_SKIPPING_TYPE, Ext::Test::ITR_TEST_SKIPPING_MODE) | ||
|
||
Datadog.logger.debug("Configured ITR Runner with enabled: #{@enabled}, skipping_tests: #{@test_skipping_enabled}, code_coverage: #{@code_coverage_enabled}") | ||
end | ||
|
||
def enabled? | ||
@enabled | ||
end | ||
|
||
def skipping_tests? | ||
@test_skipping_enabled | ||
end | ||
|
||
def code_coverage? | ||
@code_coverage_enabled | ||
end | ||
|
||
private | ||
|
||
def convert_to_bool(value) | ||
value.to_s == "true" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.