From 3ef841184c9974db68b46694b8f5e8840a2b9c85 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 3 Dec 2012 21:17:20 +0400 Subject: [PATCH] fill packages of BuildList when use new_core --- app/helpers/build_lists_helper.rb | 6 +- app/views/projects/build_lists/show.html.haml | 73 ++++++++++--------- lib/abf_worker/rpm_worker_observer.rb | 37 +++++++++- 3 files changed, 77 insertions(+), 39 deletions(-) diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index 2f4cae2fa..43ee8cbff 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -45,7 +45,11 @@ module BuildListsHelper end def container_url - "http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe + if @build_list.new_core? + @build_list.container_path + else + "http://#{request.host_with_port}/downloads#{@build_list.container_path}".html_safe + end end def build_list_log_url(log_type) diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 7ab528944..00b444b2a 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -138,46 +138,47 @@ = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' .hr -- if @build_list.new_core? - = render 'platforms/product_build_lists/results', :pbl => @build_list -- else - %h3= t("layout.build_lists.items_header") - - if @item_groups.blank? - %h4.nomargin= t("layout.build_lists.no_items_data") - - @item_groups.each_with_index do |group, level| - - group.each do |item| - %h4.nomargin= "#{item.name} ##{level}" - %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} - %thead - %tr - %th= t("activerecord.attributes.build_list/item.name") - %th= t("activerecord.attributes.build_list/item.version") - %th= t("activerecord.attributes.build_list/item.status") - %tbody - %tr{:class => build_list_item_status_color(item.status)} - %td= item.name - %td= item.version - %td= item.human_status - .both - - - if @build_list.packages.present? - .hr - %h3= t("layout.build_lists.packages_header") +%h3= t("layout.build_lists.items_header") +- if @item_groups.blank? + %h4.nomargin= t("layout.build_lists.no_items_data") +- @item_groups.each_with_index do |group, level| + - group.each do |item| + %h4.nomargin= "#{item.name} ##{level}" %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} %thead %tr - %th= t("activerecord.attributes.build_list/package.fullname") - %th= t("activerecord.attributes.build_list/package.name") - %th= t("activerecord.attributes.build_list/package.version") - %th= t("activerecord.attributes.build_list/package.release") + %th= t("activerecord.attributes.build_list/item.name") + %th= t("activerecord.attributes.build_list/item.version") + %th= t("activerecord.attributes.build_list/item.status") %tbody - - @build_list.packages.each do |package| - %tr - %td= package.fullname - %td= package.name - %td= package.version - %td= package.release - .both + %tr{:class => build_list_item_status_color(item.status)} + %td= item.name + %td= item.version + %td= item.human_status +.both + +- if @build_list.packages.present? + .hr + %h3= t("layout.build_lists.packages_header") + %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th= t("activerecord.attributes.build_list/package.fullname") + %th= t("activerecord.attributes.build_list/package.name") + %th= t("activerecord.attributes.build_list/package.version") + %th= t("activerecord.attributes.build_list/package.release") + %tbody + - @build_list.packages.each do |package| + %tr + %td= package.fullname + %td= package.name + %td= package.version + %td= package.release + .both + +- if @build_list.new_core? + .hr + = render 'platforms/product_build_lists/results', :pbl => @build_list :javascript $('article .all').addClass('bigpadding'); diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 97ab4703e..bbc944f9a 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -5,19 +5,52 @@ module AbfWorker def self.perform(options) bl = BuildList.find options['id'] status = options['status'].to_i + item = find_or_create_item(bl) case status when 0 bl.build_success + item.update_attributes({:status => BuildServer::SUCCESS}) when 1 bl.build_error + item.update_attributes({:status => BuildServer::BUILD_ERROR}) when 3 bl.bs_id = bl.id - bl.save + bl.save! bl.start_build end if status != 3 + fill_container_data bl, options + end + end + + class << self + protected + + def find_or_create_item(bl) + bl.items.first || bl.items.create({ + :version => bl.project_version, + :name => bl.project.name, + :status => BuildServer::BUILD_STARTED, + :level => 0 + }) + end + + def fill_container_data(bl, options) + packages = options['packages'] || [] + packages.each do |package| + package = bl.packages.build(package) + package.package_type = package['fullname'] =~ /.*\.src\.rpm$/ ? 'source' : 'binary' + package.project_id = bl.project_id + package.platform_id = bl.save_to_platform_id + package.save! + end + + container = (options['results'] || []). + select{ |r| r['file_name'] !~ /.*\.log$/ }.first + sha1 = container ? container['sha1'] : nil bl.results = options['results'] - bl.save + bl.container_path = "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" if sha1 + bl.save! end end