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
86
87
88
89
90
91
92
93
94
95
96
|
def run_ci(volume_container, ci_image, num_of_packages)
packages = []
Package.each do |package|
packages << package[:identifier]
end
if num_of_packages == 'all'
packages = packages
elsif num_of_packages == 'untested'
packages = []
Package.each do |package|
next if package.build.count > 0
next if "#{package[:category]}/#{package[:name]}" == 'virtual/rubygems'
next if "#{package[:category]}/#{package[:name]}" == 'dev-ruby/rake'
next if "#{package[:category]}/#{package[:name]}" == 'dev-ruby/rspec'
next if "#{package[:category]}/#{package[:name]}" == 'dev-ruby/rspec-core'
next if "#{package[:category]}/#{package[:name]}" == 'dev-ruby/rdoc'
packages << package[:identifier]
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
elsif num_of_packages.is_a?(Integer)
packages = packages.sample(num_of_packages)
else
puts 'ERROR: Invalid value for NUM_OF_PACKAGES'
exit
end
packages = packages.uniq
packages.each do |package|
ci_container = Docker::Container.create(
Cmd: %W[/ruby-tinderbox/tinder.sh #{package}],
Image: ci_image.id
)
ci_container.start(VolumesFrom: volume_container.id)
ci_container.wait(36_000)
tar = Tempfile.new('tar')
File.open(tar, 'w') do |file|
ci_container.copy('/ruby-tinderbox/ci-logs') do |chunk|
file.write(chunk)
end
end
Archive::Tar::Minitar.unpack(tar, File.dirname(File.expand_path(File.dirname(__FILE__))))
tar.close
tar.unlink
ci_container.delete
end
end
def update_ci
Dir.glob('ci-logs/*/*/builds/*') do |build|
begin
build_array = build.split('/')
sha1 = build_array[1]
timestamp = build_array[4]
target = build_array[2].sub('_target', '')
result = File.read("#{build}/result")
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")
package = Package.where(sha1: sha1).first
unless package.nil?
package.add_build(
Build.find_or_create(
timestamp: timestamp,
target: target,
result: result,
emerge_info: emerge_info,
emerge_pqv: emerge_pqv,
build_log: build_log,
gem_list: gem_list
)
)
end
rescue => e
puts "ERROR: #{e}"
next
end
end
end
def clear_ci
Build.map(&:delete)
end
|