From 67e60f0a1d174e4ba664b869dfe450bb43048748 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 5 Feb 2013 22:49:26 +0400 Subject: [PATCH 01/14] #756: update Observers, add TESTS_FAILED status --- app/models/build_list.rb | 9 +++- config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + lib/abf_worker/base_observer.rb | 31 +++++++++--- lib/abf_worker/iso_worker_observer.rb | 20 ++++---- lib/abf_worker/publish_observer.rb | 46 ++++++++--------- lib/abf_worker/rpm_worker_observer.rb | 67 +++++++++++++------------ 7 files changed, 105 insertions(+), 70 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 0f2f5d724..d99c38013 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -67,6 +67,7 @@ class BuildList < ActiveRecord::Base FAILED_PUBLISH = 8000 REJECTED_PUBLISH = 9000 BUILD_CANCELING = 10000 + TESTS_FAILED = 11000 STATUSES = [ WAITING_FOR_RESPONSE, BUILD_CANCELED, @@ -79,7 +80,8 @@ class BuildList < ActiveRecord::Base SUCCESS, BUILD_STARTED, BUILD_ERROR, - PROJECT_VERSION_NOT_FOUND + PROJECT_VERSION_NOT_FOUND, + TESTS_FAILED ] HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response, @@ -94,6 +96,7 @@ class BuildList < ActiveRecord::Base BUILD_STARTED => :build_started, SUCCESS => :success, PROJECT_VERSION_NOT_FOUND => :project_version_not_found, + TESTS_FAILED => :tests_failed } scope :recent, order("#{table_name}.updated_at DESC") @@ -204,6 +207,10 @@ class BuildList < ActiveRecord::Base transition [:build_started, :build_canceled, :build_canceling] => :build_error end + event :tests_failed do + transition [:build_started, :build_canceled, :build_canceling] => :tests_failed + end + HUMAN_STATUSES.each do |code,name| state name, :value => code end diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 0e0dfb81f..709d9d283 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -114,6 +114,7 @@ en: build_lists: All build_error: Build error build_published: Build has been published + tests_failed: Tests failed rejected_publish: Publishing rejected build_publish: Build is being published failed_publish: Publishing error diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index e4fdaf8f3..e42cf1306 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -113,6 +113,7 @@ ru: build_lists: Всего build_error: ошибка сборки build_published: опубликован + tests_failed: тесты не прошли rejected_publish: публикация отклонена build_publish: публикуется failed_publish: ошибка публикации diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index 86e402e18..ac9cb4f13 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -6,14 +6,33 @@ module AbfWorker STARTED = 3 CANCELED = 4 - def self.update_results(subject, options) - results = (subject.results || []) + options['results'] - sort_results_and_save(subject, results) + attr_accessor :status, :options + + protected + + def initialize(options, subject_class) + @status = options['status'].to_i + @options = options + @subject_class = subject_class end - def self.sort_results_and_save(subject, results) - subject.results = results.sort_by{ |r| r['file_name'] } - subject.save! + def subject + @subject ||= @subject_class.find options['id'] + end + + def perform + raise NotImplementedError, "You should implement this method" + end + + def update_results + results = (subject.results || []) + options['results'] + sort_results_and_save results + end + + def sort_results_and_save(results, item = nil) + item ||= subject + item.results = results.sort_by{ |r| r['file_name'] } + item.save! end end diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index b091149d7..ebce642ba 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -3,21 +3,23 @@ module AbfWorker @queue = :iso_worker_observer def self.perform(options) - status = options['status'].to_i - pbl = ProductBuildList.find options['id'] + new(options, ProductBuildList).perform + end + + protected + + def perform case status when COMPLETED - pbl.build_success + subject.build_success when FAILED - pbl.build_error + subject.build_error when STARTED - pbl.start_build + subject.start_build when CANCELED - pbl.build_canceled - end - if status != STARTED - update_results(pbl, options) + subject.build_canceled end + update_results if status != STARTED end end diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index 796f96b40..f78e389fb 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -4,53 +4,53 @@ module AbfWorker def self.perform(options) - status = options['status'].to_i + new(options, BuildList).perform + end + + protected + + def perform return if status == STARTED # do nothing when publication started if options['type'] == 'resign' AbfWorker::BuildListsPublishTaskManager.unlock_repository options['id'] else if options['extra']['create_container'] # Container has been created - bl = BuildList.find(options['id']) case status when COMPLETED - bl.published_container + subject.published_container when FAILED, CANCELED - bl.fail_publish_container + subject.fail_publish_container end - update_results(bl, options) + update_results else - update_rpm_builds options, status + update_rpm_builds end end end - def self.update_rpm_builds(options, status) + def update_rpm_builds build_lists = BuildList.where(:id => options['build_list_ids']) - build_lists.each do |bl| - update_results(bl, options) + build_lists.each do |build_list| + update_results build_list case status when COMPLETED - bl.published + build_list.published AbfWorker::BuildListsPublishTaskManager.cleanup_completed options['projects_for_cleanup'] when FAILED, CANCELED - bl.fail_publish + build_list.fail_publish AbfWorker::BuildListsPublishTaskManager.cleanup_failed options['projects_for_cleanup'] end - AbfWorker::BuildListsPublishTaskManager.unlock_build_list bl + AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list end - bl = build_lists.first || BuildList.find(options['id']) - AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform bl + build_list = build_lists.first || BuildList.find(options['id']) + AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform build_list end - class << self - protected - - def update_results(subject, options) - results = (subject.results || []). - select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-worker.*\.log$/ } - results |= options['results'] - sort_results_and_save(subject, results) - end + def update_results(build_list) + results = (build_list.results || []). + select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-worker.*\.log$/ } + results |= options['results'] + sort_results_and_save results, build_list end end end \ No newline at end of file diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index bd08098b8..1ba94da10 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -1,53 +1,58 @@ module AbfWorker class RpmWorkerObserver < AbfWorker::BaseObserver + TESTS_FAILED = 5 + @queue = :rpm_worker_observer def self.perform(options) - bl = BuildList.find options['id'] - status = options['status'].to_i - item = find_or_create_item(bl) + new(options, BuildList).perform + end - fill_container_data(bl, options) if status != STARTED + protected + + def perform + item = find_or_create_item + + fill_container_data if status != STARTED case status when COMPLETED - bl.build_success - item.update_attributes({:status => BuildList::SUCCESS}) - bl.now_publish if bl.auto_publish? + subject.build_success + subject.now_publish if subject.auto_publish? when FAILED - bl.build_error + subject.build_error item.update_attributes({:status => BuildList::BUILD_ERROR}) when STARTED - bl.start_build + subject.start_build when CANCELED - bl.build_canceled + subject.build_canceled item.update_attributes({:status => BuildList::BUILD_CANCELED}) + when TESTS_FAILED + subject.tests_failed end + + item.update_attributes({:status => BuildList::SUCCESS}) if [TESTS_FAILED, COMPLETED].include?(status) end - class << self - protected + def find_or_create_item + subject.items.first || subject.items.create({ + :version => subject.commit_hash, + :name => subject.project.name, + :status => BuildList::BUILD_STARTED, + :level => 0 + }) + end - def find_or_create_item(bl) - bl.items.first || bl.items.create({ - :version => bl.commit_hash, - :name => bl.project.name, - :status => BuildList::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 - update_results(bl, options) + def fill_container_data + packages = options['packages'] || [] + packages.each do |package| + package = subject.packages.build(package) + package.package_type = package['fullname'] =~ /.*\.src\.rpm$/ ? 'source' : 'binary' + package.project_id = subject.project_id + package.platform_id = subject.save_to_platform_id + package.save! end + update_results end end From 7906ca6dfb12eaf4af3c5d7f6386ec5980dfa558 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 5 Feb 2013 22:51:27 +0400 Subject: [PATCH 02/14] #756: small refactoring --- lib/abf_worker/publish_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index f78e389fb..927e48115 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -42,7 +42,7 @@ module AbfWorker end AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list end - build_list = build_lists.first || BuildList.find(options['id']) + build_list = build_lists.first || subject AbfWorker::BuildListsPublishTaskManager.unlock_rep_and_platform build_list end From 8629ae8ca3e8497609478cce1677e8993812ab94 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 13:42:34 +0400 Subject: [PATCH 03/14] #756: update UI --- app/assets/stylesheets/design/custom.scss | 39 ++++++++----------- app/assets/stylesheets/design/main.scss | 11 ++---- app/helpers/build_lists_helper.rb | 31 ++++++++------- app/models/ability.rb | 1 + app/models/build_list.rb | 6 +-- app/views/projects/build_lists/show.html.haml | 3 +- config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + 8 files changed, 44 insertions(+), 49 deletions(-) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 4ee8835b2..6a22fbd3b 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -496,29 +496,22 @@ span.delete { #fork-and-edit {display:block;} -.notify.blue div.success { - border: 1px solid #bad099; - background: #d7e599; - float: left; -} - -div.notify.blue div.error { - float: left; - border: 1px solid #ddd; - background-color: #FBE3E4; - border-color: #FBC2C4; -} - -div.notify.blue div.nocolor { - float: left; - border: 1px solid #a9c6dd; -} - -div.notify.blue div.red { - float: left; - border: 1px solid #ddd; - background-color: #FBE3E4; - border-color: #FBC2C4; +.notify.blue { + .error, .red, .nocolor, .warning, .success { float: left; } + .error, .red { + border: 1px solid #ddd; + background-color: #FBE3E4; + border-color: #FBC2C4; + } + .success { + border: 1px solid #bad099; + background: #d7e599; + } + .nocolor { border: 1px solid #a9c6dd; } + .warning { + border: 1px solid #FBEED5; + background-color: #FCF8E3; + } } a.button.left_floated { diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index a0e76e21f..c329a712d 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -1990,13 +1990,10 @@ div.right.slim { img.delete-row { cursor: pointer; } - -table tbody tr.error td { - background: #fedede; -} - -table tbody tr.success td { - background: #e3edb7; +table tbody { + .error td { background: #fedede; } + .success td { background: #e3edb7; } + .warning td { background: #FCF8E3; } } /* Create group */ diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index 66e89a0dd..74a909893 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -1,15 +1,16 @@ # -*- encoding : utf-8 -*- module BuildListsHelper def build_list_status_color(status) - if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS].include? status - return 'success' + case status + when BuildList::BUILD_PUBLISHED, BuildList::SUCCESS + 'success' + when BuildList::BUILD_ERROR, BuildList::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH + 'error' + when BuildList::TESTS_FAILED + 'warning' + else + 'nocolor' end - if [BuildList::BUILD_ERROR, BuildList::PROJECT_VERSION_NOT_FOUND, - BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH].include? status - return 'error' - end - - 'nocolor' end def build_list_options_for_new_core @@ -20,14 +21,14 @@ module BuildListsHelper end def build_list_item_status_color(status) - if BuildList::SUCCESS == status - return 'success' + case status + when BuildList::SUCCESS + 'success' + when BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR + 'error' + else + '' end - if [BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR].include? status - return 'error' - end - - '' end def build_list_classified_update_types diff --git a/app/models/ability.rb b/app/models/ability.rb index faf5f8f26..b517f0d3f 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -154,6 +154,7 @@ class Ability cannot [:clone], Platform, :platform_type => 'personal' cannot :publish, BuildList, :new_core => false + cannot :create_container, BuildList, :new_core => false cannot([:get_list, :create], MassBuild) {|mass_build| mass_build.platform.personal?} cannot(:cancel, MassBuild) {|mass_build| mass_build.platform.personal? || mass_build.stop_build} diff --git a/app/models/build_list.rb b/app/models/build_list.rb index d99c38013..9eb36a1cb 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -191,7 +191,7 @@ class BuildList < ActiveRecord::Base end event :publish do - transition [:success, :failed_publish, :build_published] => :build_publish + transition [:success, :failed_publish, :build_published, :tests_failed] => :build_publish transition [:success, :failed_publish] => :failed_publish end @@ -270,7 +270,7 @@ class BuildList < ActiveRecord::Base end def can_create_container? - success? && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status) + (success? || tests_failed?) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status) end #TODO: Share this checking on product owner. @@ -279,7 +279,7 @@ class BuildList < ActiveRecord::Base end def can_publish? - [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED].include? status + [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include? status end def can_reject_publish? diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index ffde37903..1a6780224 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -140,7 +140,8 @@ - if @build_list.build_published? = submit_tag t("layout.publish_again"), :confirm => t("layout.publish_again_warning"), :name => 'publish' - elsif @build_list.can_publish? - = submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' + - confirm = @build_list.tests_failed? ? t('layout.build_lists.tests_failed') : t('layout.confirm') + = submit_tag t("layout.publish"), :confirm => confirm, :name => 'publish' - if @build_list.can_reject_publish? && can?(:reject_publish, @build_list) = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' - if @build_list.can_create_container? && can?(:create_container, @build_list) diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 709d9d283..be882a1fe 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -78,6 +78,7 @@ en: action: Action new_header: New build main_data: Main data + tests_failed: Some tests failed. Be careful! human_current_duration: Build currently takes %{hours} h. %{minutes} min. human_duration: Built in %{hours} h. %{minutes} min. diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index e42cf1306..40ce16dc3 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -77,6 +77,7 @@ ru: action: Действие new_header: Новая сборка main_data: Основные данные + tests_failed: Некоторые тесты провалились. Будьте осторожны! human_current_duration: Сборка длится уже %{hours} ч. %{minutes} мин. human_duration: Собрано за %{hours} ч. %{minutes} мин. From a86ee3ebf0b9ff7d1b03734d005748c257bdf4b0 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 14:06:37 +0400 Subject: [PATCH 04/14] #756: update path to repo for tests --- app/models/build_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 9eb36a1cb..cf3264369 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -394,7 +394,7 @@ class BuildList < ActiveRecord::Base include_repos.each do |r| repo = Repository.find r path = repo.platform.public_downloads_url(nil, arch.name, repo.name) - # path = path.gsub(/^http:\/\/0\.0\.0\.0\:3000/, 'https://abf.rosalinux.ru') + path.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? # Path looks like: # http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/ # so, we should append: From ce9c425ba1bb0ce9bcf321045abef36a6701e5a3 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 14:14:36 +0400 Subject: [PATCH 05/14] #756: fixed "NoMethodError: protected method `perform' " --- lib/abf_worker/base_observer.rb | 12 ++++++------ lib/abf_worker/iso_worker_observer.rb | 2 -- lib/abf_worker/publish_observer.rb | 4 ++-- lib/abf_worker/rpm_worker_observer.rb | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index ac9cb4f13..b4ef98ff8 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -8,22 +8,22 @@ module AbfWorker attr_accessor :status, :options - protected - def initialize(options, subject_class) @status = options['status'].to_i @options = options @subject_class = subject_class end - def subject - @subject ||= @subject_class.find options['id'] - end - def perform raise NotImplementedError, "You should implement this method" end + protected + + def subject + @subject ||= @subject_class.find options['id'] + end + def update_results results = (subject.results || []) + options['results'] sort_results_and_save results diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index ebce642ba..b8e5fc142 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -6,8 +6,6 @@ module AbfWorker new(options, ProductBuildList).perform end - protected - def perform case status when COMPLETED diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index 927e48115..3b9f4f5bc 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -7,8 +7,6 @@ module AbfWorker new(options, BuildList).perform end - protected - def perform return if status == STARTED # do nothing when publication started if options['type'] == 'resign' @@ -28,6 +26,8 @@ module AbfWorker end end + protected + def update_rpm_builds build_lists = BuildList.where(:id => options['build_list_ids']) build_lists.each do |build_list| diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 1ba94da10..e8cf2b6b7 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -8,8 +8,6 @@ module AbfWorker new(options, BuildList).perform end - protected - def perform item = find_or_create_item @@ -34,6 +32,8 @@ module AbfWorker item.update_attributes({:status => BuildList::SUCCESS}) if [TESTS_FAILED, COMPLETED].include?(status) end + protected + def find_or_create_item subject.items.first || subject.items.create({ :version => subject.commit_hash, From 3b4506354a75c1f450174597eddec2ac00c0d6a5 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 14:18:51 +0400 Subject: [PATCH 06/14] #756: small refactoring --- app/models/build_list.rb | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index cf3264369..d3d00f545 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -408,26 +408,19 @@ class BuildList < ActiveRecord::Base include_repos_hash["#{save_to_platform.name}_release"] = save_to_platform. urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"] end - # mdv example: - # https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git - # bfe6d68cc607238011a6108014bdcfe86c69456a - - # rhel example: - # https://abf.rosalinux.ru/server/gnome-settings-daemon.git - # fbb2549e44d97226fea6748a4f95d1d82ffb8726 + git_project_address = project.git_project_address(user) + git_project_address.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? { - :id => id, - :arch => arch.name, - :time_living => 43200, # 12 hours - :distrib_type => build_for_platform.distrib_type, - # :git_project_address => 'https://abf.rosalinux.ru/server/gnome-settings-daemon.git', - :git_project_address => project.git_project_address(user), - # :commit_hash => 'fbb2549e44d97226fea6748a4f95d1d82ffb8726', - :commit_hash => commit_hash, - :include_repos => include_repos_hash, - :bplname => build_for_platform.name, - :user => {:uname => user.uname, :email => user.email} + :id => id, + :arch => arch.name, + :time_living => 43200, # 12 hours + :distrib_type => build_for_platform.distrib_type, + :git_project_address => git_project_address, + :commit_hash => commit_hash, + :include_repos => include_repos_hash, + :bplname => build_for_platform.name, + :user => {:uname => user.uname, :email => user.email} } end From 376d50c8fb95b625fa15c31c5228b75f9202725c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 14:59:36 +0400 Subject: [PATCH 07/14] #756: remove 'build_canceled' status from transitions "tests_failed" and "build_error" --- app/models/build_list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index d3d00f545..191741259 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -204,11 +204,11 @@ class BuildList < ActiveRecord::Base end event :build_error do - transition [:build_started, :build_canceled, :build_canceling] => :build_error + transition [:build_started, :build_canceling] => :build_error end event :tests_failed do - transition [:build_started, :build_canceled, :build_canceling] => :tests_failed + transition [:build_started, :build_canceling] => :tests_failed end HUMAN_STATUSES.each do |code,name| From 9583b640a35c2b14f0c1bdc739174f852ab548cc Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 15:12:37 +0400 Subject: [PATCH 08/14] #756: rollback some changes --- app/models/build_list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 191741259..faae1ece9 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -394,7 +394,7 @@ class BuildList < ActiveRecord::Base include_repos.each do |r| repo = Repository.find r path = repo.platform.public_downloads_url(nil, arch.name, repo.name) - path.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? + # path.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? # Path looks like: # http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/ # so, we should append: @@ -410,7 +410,7 @@ class BuildList < ActiveRecord::Base end git_project_address = project.git_project_address(user) - git_project_address.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? + # git_project_address.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? { :id => id, :arch => arch.name, From 7dba0c306813da1eca6e8ce337650fa3e42567ad Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 15:18:29 +0400 Subject: [PATCH 09/14] #756: move TESTS_FAILED constant --- lib/abf_worker/base_observer.rb | 11 ++++++----- lib/abf_worker/rpm_worker_observer.rb | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index b4ef98ff8..6f2befd2d 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -1,10 +1,11 @@ module AbfWorker class BaseObserver - COMPLETED = 0 - FAILED = 1 - PENDING = 2 - STARTED = 3 - CANCELED = 4 + COMPLETED = 0 + FAILED = 1 + PENDING = 2 + STARTED = 3 + CANCELED = 4 + TESTS_FAILED = 5 attr_accessor :status, :options diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 2c9117000..0330f0358 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -1,7 +1,6 @@ module AbfWorker class RpmWorkerObserver < AbfWorker::BaseObserver RESTARTED_BUILD_LISTS = 'abf-worker::rpm-worker-observer::restarted-build-lists' - TESTS_FAILED = 5 @queue = :rpm_worker_observer From 6694dc0cd143b9008eb98d37fd3982c60ea0d32b Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 17:14:59 +0400 Subject: [PATCH 10/14] #756: observers have been updated --- app/models/activity_feed_observer.rb | 9 +++++++-- app/models/build_list_observer.rb | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/activity_feed_observer.rb b/app/models/activity_feed_observer.rb index 881e16773..80b497721 100644 --- a/app/models/activity_feed_observer.rb +++ b/app/models/activity_feed_observer.rb @@ -130,8 +130,13 @@ class ActivityFeedObserver < ActiveRecord::Observer end when 'BuildList' - if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS, BuildList::BUILD_ERROR, - BuildList::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH].include? record.status or + if [BuildList::BUILD_PUBLISHED, + BuildList::SUCCESS, + BuildList::BUILD_ERROR, + BuildList::PROJECT_VERSION_NOT_FOUND, + BuildList::FAILED_PUBLISH, + BuildList::TESTS_FAILED + ].include? record.status or (record.status == BuildList::BUILD_PENDING && record.bs_id_changed?) record.project.admins.each do |recipient| ActivityFeed.create( diff --git a/app/models/build_list_observer.rb b/app/models/build_list_observer.rb index 6c2ddb8c8..dc1921ecf 100644 --- a/app/models/build_list_observer.rb +++ b/app/models/build_list_observer.rb @@ -7,6 +7,7 @@ class BuildListObserver < ActiveRecord::Observer if [BuildList::BUILD_ERROR, BuildList::SUCCESS, BuildList::BUILD_CANCELING, + BuildList::TESTS_FAILED, BuildList::BUILD_CANCELED].include? record.status # stores time interval beetwin build start and finish in seconds record.duration = record.current_duration if record.started_at From 61a60a419e414d347b8ec49f15673c9785a2ccf2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 17:21:47 +0400 Subject: [PATCH 11/14] #756: update #publish_container event --- app/models/build_list.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index faae1ece9..f72deea75 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -232,7 +232,8 @@ class BuildList < ActiveRecord::Base :do => :remove_container event :publish_container do - transition [:waiting_for_publish, :container_failed_publish] => :container_publish, :if => :success? + transition [:waiting_for_publish, :container_failed_publish] => :container_publish, + :if => :can_create_container? end event :published_container do @@ -394,7 +395,7 @@ class BuildList < ActiveRecord::Base include_repos.each do |r| repo = Repository.find r path = repo.platform.public_downloads_url(nil, arch.name, repo.name) - # path.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? + # path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? # Path looks like: # http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/ # so, we should append: @@ -410,7 +411,7 @@ class BuildList < ActiveRecord::Base end git_project_address = project.git_project_address(user) - # git_project_address.gsub!(/^http:\/\/0\.0\.0\.0\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? + # git_project_address.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production? { :id => id, :arch => arch.name, From 705e60bbbc484473d9b3bb6be98fbca16f7e2c76 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 17:50:49 +0400 Subject: [PATCH 12/14] #756: small refactoring according to Alexander's comment --- app/models/build_list.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index f72deea75..78e524ae9 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -203,12 +203,10 @@ class BuildList < ActiveRecord::Base transition [:build_started, :build_canceled] => :success end - event :build_error do - transition [:build_started, :build_canceling] => :build_error - end - - event :tests_failed do - transition [:build_started, :build_canceling] => :tests_failed + [:build_error, :tests_failed].each do |kind| + event kind do + transition [:build_started, :build_canceling] => kind + end end HUMAN_STATUSES.each do |code,name| From 44663efa1fc884416b9c656375c27a51b6cd3b0b Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 18:23:40 +0400 Subject: [PATCH 13/14] #756: refactoring #fill_container_data --- lib/abf_worker/rpm_worker_observer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 0330f0358..1fc31dd26 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -57,8 +57,7 @@ module AbfWorker end def fill_container_data - packages = options['packages'] || [] - packages.each do |package| + (options['packages'] || []).each do |package| package = subject.packages.build(package) package.package_type = package['fullname'] =~ /.*\.src\.rpm$/ ? 'source' : 'binary' package.project_id = subject.project_id From 453d3cab1916ee2788db1adea2ff54a1fced8b86 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 6 Feb 2013 19:28:03 +0400 Subject: [PATCH 14/14] #756: refactoring according to Alexander's comment --- lib/abf_worker/base_observer.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index 6f2befd2d..45151da79 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -30,8 +30,7 @@ module AbfWorker sort_results_and_save results end - def sort_results_and_save(results, item = nil) - item ||= subject + def sort_results_and_save(results, item = subject) item.results = results.sort_by{ |r| r['file_name'] } item.save! end