Class: Gitlab::RSpecMetricsExporter::ConfigHelper
- Inherits:
-
Object
- Object
- Gitlab::RSpecMetricsExporter::ConfigHelper
- Defined in:
- lib/gitlab/rspec_metrics_exporter/config_helper.rb
Overview
Optional convenience helper that wires up the formatter using GitLab CI environment variables.
Usage in spec_helper.rb:
require "gitlab/rspec_metrics_exporter/config_helper"
Gitlab::RSpecMetricsExporter::ConfigHelper.configure!("backend_unit")
Constant Summary collapse
- STABLE_EE_BRANCH_REGEX =
/^[\d-]+-stable-ee$/
Class Method Summary collapse
Class Method Details
.configure!(run_type = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/rspec_metrics_exporter/config_helper.rb', line 20 def configure!(run_type = nil) return unless ENV.fetch("CI", nil) && ENV.fetch("GLCI_EXPORT_TEST_METRICS", "true") == "true" ::RSpec.configure do |rspec_config| next if rspec_config.dry_run? Config.configure do |exporter_config| self.logger = exporter_config.logger yield(exporter_config) if block_given? configure_exporter!(exporter_config, run_type) next if observer_not_fully_configured?(exporter_config) rspec_config.add_formatter Formatter logger.info("Test metrics export is enabled for run type: #{exporter_config.run_type}") end end end |