Class: OmgPullRequest::TestRunner::Base

Inherits:
Object
  • Object
show all
Extended by:
Configuration::Helpers
Includes:
Notifications
Defined in:
lib/omg_pull_request/test_runner/base.rb

Direct Known Subclasses

Rails, RailsTestFast, Ruby

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Helpers

delegate_config_to

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
# File 'lib/omg_pull_request/test_runner/base.rb', line 7

def initialize(attributes={})
  attributes.each do |attr, value|
    self.send("#{attr}=", value)
  end
  self.success = false
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def configuration
  @configuration
end

#github_wrapperObject

Returns the value of attribute github_wrapper.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def github_wrapper
  @github_wrapper
end

#pull_requestObject

Returns the value of attribute pull_request.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def pull_request
  @pull_request
end

#runtimeObject

Returns the value of attribute runtime.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def runtime
  @runtime
end

#storeObject

Returns the value of attribute store.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def store
  @store
end

#successObject

Returns the value of attribute success.



4
5
6
# File 'lib/omg_pull_request/test_runner/base.rb', line 4

def success
  @success
end

Instance Method Details

#abbr_from_shaObject



69
70
71
# File 'lib/omg_pull_request/test_runner/base.rb', line 69

def abbr_from_sha
  self.from_sha[0, 8]
end

#abbr_to_shaObject



73
74
75
# File 'lib/omg_pull_request/test_runner/base.rb', line 73

def abbr_to_sha
  self.to_sha[0, 8]
end

#from_shaObject



57
58
59
# File 'lib/omg_pull_request/test_runner/base.rb', line 57

def from_sha
  pull_request.base.sha
end

#git_clientObject



93
94
95
# File 'lib/omg_pull_request/test_runner/base.rb', line 93

def git_client
  @git_client ||= GitClient.new(:logger => logger, :configuration => self.configuration)
end

#issue_numberObject



77
78
79
# File 'lib/omg_pull_request/test_runner/base.rb', line 77

def issue_number
  pull_request.number
end

#log(message) ⇒ Object



101
102
103
# File 'lib/omg_pull_request/test_runner/base.rb', line 101

def log(message)
  logger.log(message)
end

#loggerObject



81
82
83
# File 'lib/omg_pull_request/test_runner/base.rb', line 81

def logger
  @logger ||= TestLogger.new(:store => self.store)
end

#lolcommits_clientObject



89
90
91
# File 'lib/omg_pull_request/test_runner/base.rb', line 89

def lolcommits_client
  @lolcommits ||= Lolcommits.new(:configuration => self.configuration, :github_wrapper => self.github_wrapper, :runner => self, :context => CONTEXT)
end

#notifierObject



97
98
99
# File 'lib/omg_pull_request/test_runner/base.rb', line 97

def notifier
  @notifier ||= Notifier.new(:runner => self, :github_wrapper => self.configuration)
end

#prowl_clientObject



85
86
87
# File 'lib/omg_pull_request/test_runner/base.rb', line 85

def prowl_client
  @prowl_client ||= Prowl.new(:configuration => self.configuration, :logger => logger, :runner => self, :github_wrapper => self.github_wrapper)
end

#request_shaObject



65
66
67
# File 'lib/omg_pull_request/test_runner/base.rb', line 65

def request_sha
  "#{self.from_sha}:#{self.to_sha}"
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/omg_pull_request/test_runner/base.rb', line 18

def run
  log_test_details!
  make_comment_test_running!
  make_status_test_running!

  git_client.checkout!(from_sha)
  merge_response = git_client.merge!(to_sha)

  if merge_response == :conflict
    make_comment_conflict!
    make_status_conflict!
    return
  end

  Bundler.with_clean_env do
    setup

    t = Time.now
    self.success = execute_tests
    self.runtime =  Time.now - t

    teardown
  end

  process_output!
end

#runtime_minutesObject



49
50
51
# File 'lib/omg_pull_request/test_runner/base.rb', line 49

def runtime_minutes
  (runtime.to_f / 60).to_i
end

#runtime_secondsObject



53
54
55
# File 'lib/omg_pull_request/test_runner/base.rb', line 53

def runtime_seconds
  (runtime.to_f % 60).round(3)
end

#success?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/omg_pull_request/test_runner/base.rb', line 45

def success?
  self.success
end

#to_shaObject



61
62
63
# File 'lib/omg_pull_request/test_runner/base.rb', line 61

def to_sha
  pull_request.head.sha
end