Module: DeepThought::CIService

Defined in:
lib/deep_thought/ci_service.rb,
lib/deep_thought/ci_service/janky.rb,
lib/deep_thought/ci_service/ci_service.rb

Defined Under Namespace

Classes: CIBuildNotGreenError, CIProjectAccessError, CIService, CIServiceNotFoundError, CIServiceSetupFailedError, Janky

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adaptersObject

Returns the value of attribute adapters.



9
10
11
# File 'lib/deep_thought/ci_service.rb', line 9

def adapters
  @adapters
end

.ci_serviceObject

Returns the value of attribute ci_service.



9
10
11
# File 'lib/deep_thought/ci_service.rb', line 9

def ci_service
  @ci_service
end

Class Method Details

.is_branch_green?(app, branch, hash) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/deep_thought/ci_service.rb', line 35

def self.is_branch_green?(app, branch, hash)
  begin
    @ci_service.is_branch_green?(app, branch, hash)
  rescue
    raise CIProjectAccessError, "Something went wrong asking #{ENV['CI_SERVICE']} about commit #{hash} in #{app} on the #{branch} branch."
  end
end

.register_adapter(name, service) ⇒ Object



16
17
18
# File 'lib/deep_thought/ci_service.rb', line 16

def self.register_adapter(name, service)
  self.adapters[name] = service
end

.setup(settings) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/deep_thought/ci_service.rb', line 20

def self.setup(settings)
  if settings['CI_SERVICE']
    if @adapters.keys.include?(settings['CI_SERVICE'])
      klass = adapters[settings['CI_SERVICE']]
      @ci_service = klass.new

      if !@ci_service.setup?(settings)
        raise CIServiceSetupFailedError, "CI service setup failed - check the CI service and project settings."
      end
    else
      raise CIServiceNotFoundError, "I don't have a CI service called \"#{settings['CI_SERVICE']}\"."
    end
  end
end