Class: Datadog::CI::Remote::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/remote/component.rb

Overview

Remote configuration component. Responsible for fetching library settings and configuring the library accordingly.

Instance Method Summary collapse

Constructor Details

#initialize(library_settings_client:) ⇒ Component

Returns a new instance of Component.



9
10
11
# File 'lib/datadog/ci/remote/component.rb', line 9

def initialize(library_settings_client:)
  @library_settings_client = library_settings_client
end

Instance Method Details

#configure(test_session) ⇒ Object

called on test session start, uses test session info to send configuration request to the backend



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/datadog/ci/remote/component.rb', line 14

def configure(test_session)
  library_configuration = @library_settings_client.fetch(test_session)
  # sometimes we can skip code coverage for default branch if there are no changes in the repository
  # backend needs git metadata uploaded for this test session to check if we can skip code coverage
  if library_configuration.require_git?
    Datadog.logger.debug { "Library configuration endpoint requires git upload to be finished, waiting..." }
    git_tree_upload_worker.wait_until_done

    Datadog.logger.debug { "Requesting library configuration again..." }
    library_configuration = @library_settings_client.fetch(test_session)

    if library_configuration.require_git?
      Datadog.logger.debug { "git metadata upload did not complete in time when configuring library" }
    end
  end

  test_optimisation.configure(library_configuration, test_session)
  test_retries.configure(library_configuration)
end