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
74
75
76
77
78
79
80
81
82
83
84
85
|
def run_ci(num_of_packages, provisioner)
packages = []
Package.order { [category, lower(name), version] }.each do |package|
packages << package[:identifier]
end
if num_of_packages == :all
packages = packages
elsif num_of_packages == 0
packages = packages.sample(5)
elsif num_of_packages == :untested
packages = []
Package.exclude(tested: true).order { [category, lower(name), version] }.each do |package|
packages << package[:identifier]
next if [
'virtual/rubygems',
'dev-ruby/rake',
'dev-ruby/rspec',
'dev-ruby/rspec-core',
'dev-ruby/rdoc'
].include?("#{package[:category]}/#{package[:name]}")
Package.where(Sequel.like(
:dependencies,
"#{package[:category]}/#{package[:name]} %",
"% #{package[:category]}/#{package[:name]} %",
"% #{package[:category]}/#{package[:name]}"
)).each do |rdep|
packages << rdep[:identifier]
end
end
else
packages = packages.sample(num_of_packages)
end
exit if packages.empty?
begin
vagrant_path = File.dirname(File.dirname(File.expand_path(File.dirname(__FILE__))))
vagrant = Vagrant_Rbapi.new(vagrant_path)
vagrant.up(provisioner)
sleep 5 while vagrant.status != 'running'
vagrant.ssh('sudo /vagrant/tinder.sh ' + packages.join(' '))
vagrant.scp(:download, true, '/vagrant/ci-logs', 'web')
ensure
vagrant.destroy
end
end
def update_ci
Dir.glob('ci-logs/*/*/*') do |build|
build_array = build.split('/')
package_id = "#{build_array[1]}/#{build_array[2]}"
time = build_array[3]
if File.exist?("#{build}/succeeded")
result = 'succeeded'
elsif File.exist?("#{build}/failed")
result = 'failed'
elsif File.exist?("#{build}/timedout")
result = 'timed out'
end
emerge_info = File.read("#{build}/emerge-info") if File.exist?("#{build}/emerge-info")
emerge_pqv = File.read("#{build}/emerge-pqv") if File.exist?("#{build}/emerge-pqv")
build_log = File.read("#{build}/build.log") if File.exist?("#{build}/build.log")
gem_list = File.read("#{build}/gem-list") if File.exist?("#{build}/gem-list")
Build.find_or_create(
package_id: package_id,
time: time,
result: result,
emerge_info: emerge_info,
emerge_pqv: emerge_pqv,
build_log: build_log,
gem_list: gem_list
)
end
Build.each do |build|
Package.where(identifier: build[:package_id]).update(tested: true)
end
end
def clear_ci
Build.map(&:delete)
end
|