Class: Mergify::RSpec::CIInsights

Inherits:
Object
  • Object
show all
Defined in:
lib/mergify/rspec/ci_insights.rb

Overview

Central orchestrator for Mergify Test Insights: sets up OpenTelemetry tracing, manages the tracer provider, and coordinates flaky detection and quarantine. rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCIInsights

rubocop:disable Metrics/MethodLength



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mergify/rspec/ci_insights.rb', line 27

def initialize
  @token = ENV.fetch('MERGIFY_TOKEN', nil)
  @repo_name = Utils.repository_name
  @api_url = ENV.fetch('MERGIFY_API_URL', 'https://api.mergify.com')
  @test_run_id = SecureRandom.hex(8)
  @tracer_provider = nil
  @tracer = nil
  @exporter = nil
  @branch_name = nil
  @flaky_detector = nil
  @flaky_detector_error_message = nil
  @quarantined_tests = nil

  setup_tracing if Utils.in_ci?
end

Instance Attribute Details

#api_urlObject (readonly)

Returns the value of attribute api_url.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def api_url
  @api_url
end

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def branch_name
  @branch_name
end

#exporterObject (readonly)

Returns the value of attribute exporter.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def exporter
  @exporter
end

#flaky_detectorObject (readonly)

Returns the value of attribute flaky_detector.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def flaky_detector
  @flaky_detector
end

#flaky_detector_error_messageObject (readonly)

Returns the value of attribute flaky_detector_error_message.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def flaky_detector_error_message
  @flaky_detector_error_message
end

#quarantined_testsObject (readonly)

Returns the value of attribute quarantined_tests.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def quarantined_tests
  @quarantined_tests
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def repo_name
  @repo_name
end

#test_run_idObject (readonly)

Returns the value of attribute test_run_id.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def test_run_id
  @test_run_id
end

#tokenObject (readonly)

Returns the value of attribute token.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def token
  @token
end

#tracerObject (readonly)

Returns the value of attribute tracer.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def tracer
  @tracer
end

#tracer_providerObject (readonly)

Returns the value of attribute tracer_provider.



21
22
23
# File 'lib/mergify/rspec/ci_insights.rb', line 21

def tracer_provider
  @tracer_provider
end

Instance Method Details

#mark_test_as_quarantined_if_needed(example_id) ⇒ Object

rubocop:enable Metrics/MethodLength



44
45
46
47
48
49
# File 'lib/mergify/rspec/ci_insights.rb', line 44

def mark_test_as_quarantined_if_needed(example_id) # rubocop:disable Naming/PredicateMethod
  return false unless @quarantined_tests&.include?(example_id)

  @quarantined_tests.mark_as_used(example_id)
  true
end