-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.rb
72 lines (67 loc) · 2.11 KB
/
init.rb
1
2
3
4
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Travis
class FakeReporter
# Such ashamed :(
def send_log(job_id, message, last_message = false)
puts message
end
def method_missing(method_sym, *arguments, &block)
# the first argument is a Symbol, so you need to_s it if you want to pattern match
if method_sym.to_s =~ /^notify_job_(.*)$/
send_log(arguments.first, "Job #{$1}")
else
send_log(0, "Stub method: #{method_sym.to_s}")
end
end
end
module CLI
class Run < RepoCommand
description "runs a build script described by .travis.yml"
def setup
error "run command is not available on #{RUBY_VERSION}" if RUBY_VERSION < '1.9.3'
$:.unshift File.expand_path('../../travis-build/lib', __FILE__)
$:.unshift File.expand_path('../../travis-worker/lib', __FILE__)
$:.unshift File.expand_path('../lib', __FILE__)
require 'travis/build'
require 'travis/worker'
require 'travis/support/logging'
require 'travis/support/retryable'
require 'travis/worker/job/script'
require 'travis/worker/job/runner'
require 'travis/worker/virtual_machine'
end
def run(*arg)
@slug = find_slug
config = travis_config
payload = {
'config' => config,
:config => config,
:repository => {
:slug => @slug
},
'job' => {
'id' => 1
}
}
payload['script'] = Travis::Build.script(payload).compile(true)
name = 'localhost-1'
vm = Travis::Worker::VirtualMachine.provider.new(name)
vm.prepare
vm_opts = {
language: config['language'],
job_id: 1,
custom_image: config['osx_image'], #WUUT
dist: config['dist'],
groups: config['group'],
}
timeouts = {
hard_limit: 3600,
log_silence: 600,
}
vm.sandboxed(vm_opts) do
runner = Travis::Worker::Job::Runner.new(payload, vm.session, FakeReporter.new, vm.full_name, timeouts, name)
runner.run
end
end
end
end
end