diff options
Diffstat (limited to 'web/lib/repoman.rb')
-rw-r--r-- | web/lib/repoman.rb | 99 |
1 files changed, 38 insertions, 61 deletions
diff --git a/web/lib/repoman.rb b/web/lib/repoman.rb index 1185d2a..1a44177 100644 --- a/web/lib/repoman.rb +++ b/web/lib/repoman.rb @@ -1,6 +1,6 @@ def run_repoman(ci_image, num_of_packages) packages = [] - Package.order { [category, lower(name), version] }.each do |package| + Package.each do |package| target = '' target = package[:r19_target] unless package[:r19_target] == 'nil' target = package[:r20_target] unless package[:r20_target] == 'nil' @@ -14,24 +14,26 @@ def run_repoman(ci_image, num_of_packages) next_target = 'ruby22' if target == 'ruby21' next if next_target.empty? - category = package[:category] - name = package[:name] - version = package[:version] - revision = package[:revision] == 'r0' ? '' : "-#{package[:revision]}" - - packages << "#{category} #{name} #{version}#{revision} #{target} #{next_target}" + packages << "#{package[:identifier]} #{target} #{next_target}" end - if num_of_packages == :all + if num_of_packages == 'all' packages = packages - else + 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.peach(8) do |package| + package = package.split(' ') + identifier = package[0] + current_target = package[1] + next_target = package[2] ci_container = Docker::Container.create( - Cmd: %W[/ruby-tinderbox/repoman.sh #{package}], + Cmd: %W[/ruby-tinderbox/repoman.sh #{identifier} #{current_target} #{next_target}], Image: ci_image.id ) ci_container.start @@ -39,7 +41,7 @@ def run_repoman(ci_image, num_of_packages) tar = Tempfile.new('tar') File.open(tar, 'w') do |file| - ci_container.copy('/ruby-tinderbox/repo-logs') do |chunk| + ci_container.copy('/ruby-tinderbox/ci-logs') do |chunk| file.write(chunk) end end @@ -52,59 +54,34 @@ def run_repoman(ci_image, num_of_packages) end def update_repoman - Dir.glob('repo-logs/*/*/*') do |repoman| - repoman_array = repoman.split('/') - package_id = "#{repoman_array[1]}/#{repoman_array[2]}" - time = repoman_array[3] + Dir.glob('ci-logs/*/*/repomans/*') do |repoman| + begin + repoman_array = repoman.split('/') + sha1 = repoman_array[1] + timestamp = repoman_array[4] + target = repoman_array[2].sub('_target', '') - current_log = File.read("#{repoman}/current.txt") if File.exist?("#{repoman}/current.txt") - next_log = File.read("#{repoman}/next.txt") if File.exist?("#{repoman}/next.txt") + log = File.read("#{repoman}/repoman_log") - current_result = 'unknown' - if current_log.include?('If everyone were like you, I\'d be out of business!') - current_result = 'passed' - elsif current_log.include?('You\'re only giving me a partial QA payment?') - current_result = 'partial' - elsif current_log.include?('Make your QA payment on time and you\'ll never see the likes of me.') - current_result = 'failed' - end - - next_result = 'unknown' - if next_log.include?('If everyone were like you, I\'d be out of business!') - next_result = 'passed' - elsif next_log.include?('You\'re only giving me a partial QA payment?') - next_result = 'partial' - elsif next_log.include?('Make your QA payment on time and you\'ll never see the likes of me.') - next_result = 'failed' - end - - Repoman.find_or_create( - package_id: package_id, - time: time, - current_result: current_result, - current_log: current_log, - next_result: next_result, - next_log: next_log - ) - end - - Package.order { [category, lower(name), version] }.each do |package| - target = '' - target = package[:r19_target] unless package[:r19_target] == 'nil' - target = package[:r20_target] unless package[:r20_target] == 'nil' - target = package[:r21_target] unless package[:r21_target] == 'nil' - target = package[:r22_target] unless package[:r22_target] == 'nil' - if target.empty? - Repoman.where(package_id: package[:identifier]).delete - next - end + 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 - next_target = '' - next_target = 'ruby20' if target == 'ruby19' - next_target = 'ruby21' if target == 'ruby20' - next_target = 'ruby22' if target == 'ruby21' - if next_target.empty? - Repoman.where(package_id: package[:identifier]).delete + Package.where(sha1: sha1).first.add_repoman( + Repoman.find_or_create( + timestamp: timestamp, + target: target, + result: result, + log: log + ) + ) + rescue => e + puts "ERROR: #{e}" next end end |