forked from rubygems/rubygems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci
executable file
·73 lines (65 loc) · 1.58 KB
/
ci
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
73
#!/usr/bin/env ruby
class Tool
def initialize(name)
@name = name
end
def bundler?
@name == 'bundler'
end
def rubygems?
@name == 'rubygems'
end
def dir
if rubygems?
File.expand_path('../..', __FILE__)
else
File.expand_path('../../bundler', __FILE__)
end
end
end
TOOL = Tool.new(ENV.fetch("TEST_TOOL") { abort "must specify a TEST_TOOL" })
def run(command, args = [])
Dir.chdir(TOOL.dir) do
unless system(command, *args)
abort "running `#{command} #{args.join(" ")}` failed"
end
end
end
def with_retries(attempts = 3)
yield
rescue StandardError, SystemExit => e
attempts -= 1
if attempts > 0
warn "Command failed (#{e}). Retrying #{attempts -= 1} more times."
retry
else
raise
end
end
case ARGV
when %w(before_script)
if TOOL.rubygems?
run('gem', %W(uninstall executable-hooks gem-wrappers -x --force -i #{`gem env home`.strip}@global))
run('gem', %W(install rake -v #{'~> 10.5'} --no-document))
run('gem', %W(install hoe -v #{'3.15.0'} --no-document))
run('gem', %w(install hoe-travis --no-document))
run('gem', %W(install minitest -v #{'~> 4.7'} --no-document))
run('rake', %w(_10.5.0_ travis:before -t))
run('gem', %w(list --details))
run('gem', %w(env))
else
with_retries { run('rake', %w(spec:travis:deps)) }
end
when %w(after_script)
if TOOL.rubygems?
run('rake', %w(_10.5.0_ travis:after -t))
end
when %w(script)
if TOOL.rubygems?
run('rake', %w(_10.5.0_ travis))
else
run('rake', %w(spec:travis -t))
end
else
abort "unknown args #{ARGV.inspect}"
end