Module: OmgPullRequest::TestRunner

Defined in:
lib/omg_pull_request/test_runner.rb,
lib/omg_pull_request/test_runner/base.rb,
lib/omg_pull_request/test_runner/ruby.rb,
lib/omg_pull_request/test_runner/rails.rb,
lib/omg_pull_request/test_runner/rails_test_fast.rb

Defined Under Namespace

Classes: Base, Rails, RailsTestFast, Ruby

Class Method Summary collapse

Class Method Details

.start_daemon(configuration = Configuration.new, daemonize = true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
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
44
45
46
47
48
49
50
51
52
# File 'lib/omg_pull_request/test_runner.rb', line 5

def self.start_daemon(configuration=Configuration.new, daemonize=true)
  github_wrapper    = GithubWrapper.new(
    :configuration => configuration
  )

  store = configuration.storage_class.new(
    :configuration => configuration,
    :github_wrapper => github_wrapper
  )

  Plugin.instrument("initialize", 
    :configuration  => configuration,
    :github_wrapper => github_wrapper
  )

  while(true)
    begin
      Plugin.instrument("execute", {})
      pull_requests = github_wrapper.pull_requests

      CONTEXT.get_recently_closed(pull_requests).each do |closed|
        pr = github_wrapper.find_pull_request(closed)
        event = pr.merged ? 'merged' : 'closed'
        Plugin.instrument(event, :pull_request => pr)
      end

      pull_requests.each do |pr|
        runner = configuration.runner_class.new(
          :configuration  => configuration, 
          :pull_request   => pr, 
          :github_wrapper => github_wrapper,
          :store          => store
        )
        next if CONTEXT.ran?(runner.request_sha)
        CONTEXT.ran(runner.request_sha)
        
        Plugin.instrument("run", :pull_request => pr)
        runner.run
      end

    rescue => ex
      puts "An Error Occured: #{ex.inspect}\n#{ex.backtrace}"
    end

    return if daemonize == false
    sleep(60)
  end
end