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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
def run_ci(volume_container, ci_image, ci_type, num_of_packages)
packages = generate_package_list(ci_type, num_of_packages)
packages.peach(8) do |package|
package = package.split(' ')
identifier = package[0]
next_target = package[1]
if ci_type == 'build'
cmd = %W(/ruby-tinderbox/tinder.sh #{identifier} #{next_target})
elsif ci_type == 'repoman'
cmd = %W(/ruby-tinderbox/repoman.sh #{identifier} #{next_target})
end
ci_container = Docker::Container.create(
Cmd: cmd,
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 generate_package_list(ci_type, num_of_packages)
packages = []
Package.each do |package|
packages << package[:identifier]
end
if num_of_packages == 'all'
packages = packages
elsif num_of_packages == 'untested' && ci_type == 'repoman'
packages = packages
elsif num_of_packages == 'untested' && ci_type == 'build'
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)
puts packages.count
packages = packages[25..(25 + num_of_packages)]
else
puts 'ERROR: Invalid value for NUM_OF_PACKAGES'
puts ci_type
puts num_of_packages
exit
end
packages_with_targets = []
packages.uniq.each do |package|
package = Package.where(identifier: package).first
packages_with_targets << "#{package[:identifier]} #{package[:next_target]}"
end
packages_with_targets
end
def update_build(log_path)
Dir.glob(log_path) do |build|
begin
build_array = build.split('/')
build_array.shift(1) if build_array[1] == 'test-logs'
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 update_repoman(log_path)
Dir.glob(log_path) do |repoman|
begin
repoman_array = repoman.split('/')
repoman_array.shift(1) if repoman_array[1] == 'test-logs'
sha1 = repoman_array[1]
timestamp = repoman_array[4]
target = repoman_array[2].sub('_target', '')
log = File.read("#{repoman}/repoman_log")
result = 'unknown'
if log.include?('If everyone were like you, I\'d be out of business!')
result = 'passed'
elsif log.include?('You\'re only giving me a partial QA payment?')
result = 'partial'
elsif log.include?('Make your QA payment on time and you\'ll never see the likes of me.')
result = 'failed'
end
package = Package.where(sha1: sha1).first
unless package.nil?
package.add_repoman(
Repoman.find_or_create(
timestamp: timestamp,
target: target,
result: result,
log: log
)
)
end
rescue => e
puts "ERROR: #{e}"
next
end
end
end
def clear_build
Build.map(&:delete)
end
def clear_repoman
Repoman.map(&:delete)
end
|