Class: GitlabQuality::TestTooling::TestMetricsExporter::ConfigHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_quality/test_tooling/test_metrics_exporter/config_helper.rb

Constant Summary collapse

REQUIRED_CLICKHOUSE_ENV_VARS =
%w[
  GLCI_DA_CLICKHOUSE_URL
  GLCI_CLICKHOUSE_METRICS_USERNAME
  GLCI_CLICKHOUSE_METRICS_PASSWORD
  GLCI_CLICKHOUSE_METRICS_DB
  GLCI_CLICKHOUSE_METRICS_TABLE
  GLCI_CLICKHOUSE_SHARED_DB
].freeze

Class Method Summary collapse

Class Method Details

.configure!(run_type = test_run_type) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gitlab_quality/test_tooling/test_metrics_exporter/config_helper.rb', line 19

def configure!(run_type = test_run_type)
  return unless ENV.fetch("CI", nil) && ENV["GLCI_EXPORT_TEST_METRICS"] == "true" && run_type

  RSpec.configure do |rspec_config|
    next if rspec_config.dry_run?

    Config.configure do |exporter_config|
      self.logger = exporter_config.logger
      next warn_missing_clickhouse_variables unless clickhouse_env_vars_present?

      yield(exporter_config) if block_given?
      configure_exporter!(exporter_config, run_type)

      rspec_config.add_formatter Formatter
    end
  end
end