From 0cbd5b21e5ac8c5bf43eb361ce9801ea48115074 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 1 Nov 2013 21:11:59 +0400 Subject: [PATCH 1/4] #316: added new statuses for BuildList --- .../projects/build_lists_controller.rb | 6 + app/helpers/build_lists_helper.rb | 3 +- app/models/ability.rb | 6 +- app/models/build_list.rb | 128 ++++++++++-------- app/models/build_list/item.rb | 5 +- app/views/projects/build_lists/show.html.haml | 4 + config/locales/en.yml | 1 + config/locales/models/build_list.en.yml | 3 + config/locales/models/build_list.ru.yml | 4 + config/locales/ru.yml | 1 + config/routes.rb | 1 + 11 files changed, 102 insertions(+), 60 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index e6f39d222..eac270e9c 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -123,6 +123,12 @@ class Projects::BuildListsController < Projects::BaseController redirect_to :back, :notice => t("layout.build_lists.publish_#{message}") end + def publish_into_testing + @build_list.publisher = current_user + message = @build_list.publish_into_testing ? 'success' : 'fail' + redirect_to :back, :notice => t("layout.build_lists.publish_#{message}") + end + def reject_publish @build_list.publisher = current_user message = @build_list.reject_publish ? 'success' : 'fail' diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index e58bc204f..ff1702d97 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -60,7 +60,8 @@ module BuildListsHelper case status when BuildList::SUCCESS 'success' - when BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR + # when BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR + when BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR 'error' else '' diff --git a/app/models/ability.rb b/app/models/ability.rb index ae81521ab..0b4a38d94 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -82,7 +82,7 @@ class Ability can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :log, :everything, :list], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} - can(:create, BuildList) {|build_list| + can([:create, :publish_into_testing], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project) && (build_list.build_for_platform.blank? || can?(:show, build_list.build_for_platform)) @@ -175,9 +175,9 @@ class Ability cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'} cannot [:clone], Platform, :platform_type => 'personal' - cannot :publish, BuildList, :new_core => false + cannot [:publish, :publish_into_testing], BuildList, :new_core => false cannot :create_container, BuildList, :new_core => false - cannot(:publish, BuildList) {|build_list| !build_list.can_publish? } + cannot([:publish, :publish_into_testing], BuildList) {|build_list| !build_list.can_publish? } cannot(:cancel, MassBuild) {|mass_build| mass_build.stop_build} diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 2f107ad98..50ceccc24 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -15,9 +15,9 @@ class BuildList < ActiveRecord::Base belongs_to :publisher, :class_name => 'User' belongs_to :advisory belongs_to :mass_build, :counter_cache => true - has_many :items, :class_name => "BuildList::Item", :dependent => :destroy - has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy - has_many :source_packages, :class_name => "BuildList::Package", :conditions => {:package_type => 'source'} + has_many :items, :class_name => '::BuildList::Item', :dependent => :destroy + has_many :packages, :class_name => '::BuildList::Package', :dependent => :destroy + has_many :source_packages, :class_name => '::BuildList::Package', :conditions => {:package_type => 'source'} UPDATE_TYPES = %w[bugfix security enhancement recommended newpackage] RELEASE_UPDATE_TYPES = %w[bugfix security] @@ -57,53 +57,37 @@ class BuildList < ActiveRecord::Base :arch_id, :project_id, :save_to_repository_id, :update_type, :save_to_platform_id, :project_version, :auto_create_container, :extra_repositories, :extra_build_lists, :extra_params, :external_nodes - LIVE_TIME = 4.week # for unpublished + + LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published - - SUCCESS = 0 - ERROR = 1 - - PROJECT_SOURCE_ERROR = 6 - DEPENDENCIES_ERROR = 555 - BUILD_ERROR = 666 - BUILD_STARTED = 3000 - BUILD_CANCELED = 5000 - WAITING_FOR_RESPONSE = 4000 - BUILD_PENDING = 2000 - BUILD_PUBLISHED = 6000 - BUILD_PUBLISH = 7000 - FAILED_PUBLISH = 8000 - REJECTED_PUBLISH = 9000 - BUILD_CANCELING = 10000 - TESTS_FAILED = 11000 - - STATUSES = [ WAITING_FOR_RESPONSE, - BUILD_CANCELED, - BUILD_PENDING, - BUILD_PUBLISHED, - BUILD_CANCELING, - BUILD_PUBLISH, - FAILED_PUBLISH, - REJECTED_PUBLISH, - SUCCESS, - BUILD_STARTED, - BUILD_ERROR, - TESTS_FAILED - ].freeze - - HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response, - BUILD_CANCELED => :build_canceled, - BUILD_CANCELING => :build_canceling, - BUILD_PENDING => :build_pending, - BUILD_PUBLISHED => :build_published, - BUILD_PUBLISH => :build_publish, - FAILED_PUBLISH => :failed_publish, - REJECTED_PUBLISH => :rejected_publish, - BUILD_ERROR => :build_error, - BUILD_STARTED => :build_started, - SUCCESS => :success, - TESTS_FAILED => :tests_failed - }.freeze + STATUSES, HUMAN_STATUSES = [], {} + [ + %w(SUCCESS 0), + # %w(ERROR 1), + # %w(PROJECT_SOURCE_ERROR 6), + # %w(DEPENDENCIES_ERROR 555), + %w(BUILD_ERROR 666), + %w(BUILD_STARTED 3000), + %w(BUILD_CANCELED 5000), + %w(WAITING_FOR_RESPONSE 4000), + %w(BUILD_PENDING 2000), + %w(BUILD_PUBLISHED 6000), + %w(BUILD_PUBLISH 7000), + %w(FAILED_PUBLISH 8000), + %w(REJECTED_PUBLISH 9000), + %w(BUILD_CANCELING 10000), + %w(TESTS_FAILED 11000), + %w(BUILD_PUBLISHED_INTO_TESTING 12000), + %w(BUILD_PUBLISH_INTO_TESTING 13000), + %w(FAILED_PUBLISH_INTO_TESTING 14000) + ].each do |kind, value| + value = value.to_i + const_set kind, value + STATUSES << value + HUMAN_STATUSES[value] = kind.downcase.to_sym + end + STATUSES.freeze + HUMAN_STATUSES.freeze scope :recent, order("#{table_name}.updated_at DESC") scope :for_extra_build_lists, lambda {|ids, current_ability, save_to_platform| @@ -205,14 +189,50 @@ class BuildList < ActiveRecord::Base end event :publish do - transition [:success, :failed_publish, :build_published, :tests_failed] => :build_publish - transition [:success, :failed_publish] => :failed_publish + transition [ + :success, + :failed_publish, + :build_published, + :tests_failed, + :failed_publish_into_testing, + :build_published_into_testing + ] => :build_publish + transition [:success, :failed_publish, :failed_publish_into_testing] => :failed_publish end event :reject_publish do - transition [:success, :failed_publish, :tests_failed] => :rejected_publish + transition [ + :success, + :failed_publish, + :tests_failed, + :failed_publish_into_testing, + :build_published_into_testing + ] => :rejected_publish end + # ===== into testing - start + + event :published_into_testing do + transition [:build_publish_into_testing, :rejected_publish] => :build_published_into_testing + end + + event :fail_publish_into_testing do + transition [:build_publish_into_testing, :rejected_publish] => :failed_publish_into_testing + end + + event :publish_into_testing do + transition [ + :success, + :failed_publish, + :tests_failed, + :failed_publish_into_testing, + :build_published_into_testing + ] => :build_publish_into_testing + transition [:success, :failed_publish, :failed_publish_into_testing] => :failed_publish_into_testing + end + + # ===== into testing - end + event :build_success do transition [:build_started, :build_canceled] => :success end @@ -283,7 +303,7 @@ class BuildList < ActiveRecord::Base end def can_create_container? - [SUCCESS, BUILD_PUBLISH, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status) + [SUCCESS, BUILD_PUBLISH, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status) end #TODO: Share this checking on product owner. @@ -316,7 +336,7 @@ class BuildList < ActiveRecord::Base end def can_publish? - [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id) + [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id) end def extra_build_lists_published? diff --git a/app/models/build_list/item.rb b/app/models/build_list/item.rb index 896f36592..0d3d429be 100644 --- a/app/models/build_list/item.rb +++ b/app/models/build_list/item.rb @@ -7,11 +7,12 @@ class BuildList::Item < ActiveRecord::Base GIT_ERROR = 5 - STATUSES = [BuildList::SUCCESS, BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] + # STATUSES = [BuildList::SUCCESS, BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] + STATUSES = [BuildList::SUCCESS, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] HUMAN_STATUSES = { nil => :unknown, GIT_ERROR => :git_error, - BuildList::DEPENDENCIES_ERROR => :dependencies_error, + # BuildList::DEPENDENCIES_ERROR => :dependencies_error, BuildList::SUCCESS => :success, BuildList::BUILD_STARTED => :build_started, BuildList::BUILD_ERROR => :build_error, diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 1cd894726..6d648c472 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -172,6 +172,10 @@ = submit_tag t("layout.publish"), :confirm => t('layout.confirm'), :name => 'publish', 'ng-show' => "build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status != #{BuildList::TESTS_FAILED} && build_list.status != #{BuildList::BUILD_PUBLISHED}" + = link_to t('layout.publish_into_testing'), publish_into_testing_build_list_path(@build_list), + :method => :put, :confirm => t("layout.confirm"), + :class => 'button reject_publish', + 'ng-show' => 'build_list.can_publish && build_list.can_publish_in_future' - if can?(:reject_publish, @build_list) = link_to t('layout.reject_publish'), reject_publish_build_list_path(@build_list), :method => :put, :confirm => t("layout.confirm"), diff --git a/config/locales/en.yml b/config/locales/en.yml index 1ba225ab4..e5176f2fc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,6 +40,7 @@ en: publish: Publish publish_again: Publish again publish_again_warning: Secondary publication will be able to break relationships in the repository. Be careful! + publish_into_testing: '[testing] Publish' reject_publish: Reject add: Add upload: Upload diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 938394637..1374d44fb 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -146,6 +146,9 @@ en: success: Build complete build_started: Build started platform_pending: Platform pending + build_published_into_testing: '[testing] Build has been published' + build_publish_into_testing: '[testing] Build is being published' + failed_publish_into_testing: '[testing] Publishing error' log: build_log: Build Log diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 6a4caceaa..0b26c214b 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -145,6 +145,10 @@ ru: success: собран build_started: собирается platform_pending: платформа в процессе создания + build_published_into_testing: '[testing] опубликован' + build_publish_into_testing: '[testing] публикуется' + failed_publish_into_testing: '[testing] ошибка публикации' + log: build_log: Лог сборки diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 4aa7c46b8..7781cf2f3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -40,6 +40,7 @@ ru: publish: Опубликовать publish_again: Опубликовать снова publish_again_warning: Повторная публикация может привести к нарушению зависимостей в репозитории. Будьте осторожны! + publish_into_testing: '[testing] Опубликовать' reject_publish: Отклонить add: Добавить upload: Загрузить diff --git a/config/routes.rb b/config/routes.rb index ec08bf7b7..44ee73bcb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -277,6 +277,7 @@ Rosa::Application.routes.draw do get :log put :publish put :reject_publish + put :publish_into_testing end end From 25e39587c2a617f7b4d1a3a9a756e173348dfb49 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 5 Nov 2013 22:25:20 +0400 Subject: [PATCH 2/4] #316: updated UI && BuildListsPublishTaskManager --- app/models/ability.rb | 3 +- app/views/projects/build_lists/show.html.haml | 4 +- .../projects/build_lists/show.json.jbuilder | 1 + .../build_lists_publish_task_manager.rb | 48 ++++++++++++------- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 0b4a38d94..463fe1890 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -82,7 +82,8 @@ class Ability can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :log, :everything, :list], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} - can([:create, :publish_into_testing], BuildList) {|build_list| + can(:publish_into_testing, BuildList) { |build_list| can?(:write, build_list.project) && can?(:show, build_list.build_for_platform) } + can(:create, BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project) && (build_list.build_for_platform.blank? || can?(:show, build_list.build_for_platform)) diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 6d648c472..0336790db 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -174,8 +174,8 @@ 'ng-show' => "build_list.can_publish && build_list.can_publish_in_future && build_list.extra_build_lists_published && build_list.status != #{BuildList::TESTS_FAILED} && build_list.status != #{BuildList::BUILD_PUBLISHED}" = link_to t('layout.publish_into_testing'), publish_into_testing_build_list_path(@build_list), :method => :put, :confirm => t("layout.confirm"), - :class => 'button reject_publish', - 'ng-show' => 'build_list.can_publish && build_list.can_publish_in_future' + :class => 'button', + 'ng-show' => 'build_list.can_publish_into_testing' - if can?(:reject_publish, @build_list) = link_to t('layout.reject_publish'), reject_publish_build_list_path(@build_list), :method => :put, :confirm => t("layout.confirm"), diff --git a/app/views/projects/build_lists/show.json.jbuilder b/app/views/projects/build_lists/show.json.jbuilder index 8c56365d3..73823350f 100644 --- a/app/views/projects/build_lists/show.json.jbuilder +++ b/app/views/projects/build_lists/show.json.jbuilder @@ -11,6 +11,7 @@ json.build_list do end json.can_publish can?(:publish, @build_list) + json.can_publish_into_testing can?(:can_publish_into_testing, @build_list) && @build_list.can_publish_into_testing? json.can_cancel @build_list.can_cancel? json.can_create_container @build_list.can_create_container? json.can_reject_publish @build_list.can_reject_publish? diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 1460a3b6b..639246416 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -20,18 +20,27 @@ module AbfWorker create_tasks_for_resign_repositories create_tasks_for_repository_regenerate_metadata create_tasks_for_build_rpms + create_tasks_for_build_rpms true end class << self def destroy_project_from_repository(project, repository) if repository.platform.personal? Platform.main.each do |main_platform| - redis.lpush PROJECTS_FOR_CLEANUP, "#{project.id}-#{repository.id}-#{main_platform.id}" + key = "#{project.id}-#{repository.id}-#{main_platform.id}" + redis.lpush PROJECTS_FOR_CLEANUP, key gather_old_packages project.id, repository.id, main_platform.id + + redis.lpush PROJECTS_FOR_CLEANUP, ('testing-' << key) + gather_old_packages project.id, repository.id, main_platform.id, true end else - redis.lpush PROJECTS_FOR_CLEANUP, "#{project.id}-#{repository.id}-#{repository.platform.id}" + key = "#{project.id}-#{repository.id}-#{repository.platform.id}" + redis.lpush PROJECTS_FOR_CLEANUP, key gather_old_packages project.id, repository.id, repository.platform.id + + redis.lpush PROJECTS_FOR_CLEANUP, ('testing-' << key) + gather_old_packages project.id, repository.id, repository.platform.id, true end end @@ -108,11 +117,12 @@ module AbfWorker ) end - def gather_old_packages(project_id, repository_id, platform_id) + def gather_old_packages(project_id, repository_id, platform_id, testing = false) build_lists_for_cleanup = [] + status = testing ? BuildList::BUILD_PUBLISHED : BuildList::BUILD_PUBLISHED_INTO_TESTING Arch.pluck(:id).each do |arch_id| bl = BuildList.where(:project_id => project_id). - where(:new_core => true, :status => BuildList::BUILD_PUBLISHED). + where(:new_core => true, :status => status). where(:save_to_repository_id => repository_id). where(:build_for_platform_id => platform_id). where(:arch_id => arch_id). @@ -126,8 +136,8 @@ module AbfWorker fill_packages(old_bl, old_packages, :fullname) } end - - redis.hset PACKAGES_FOR_CLEANUP, "#{project_id}-#{repository_id}-#{platform_id}", old_packages.to_json + key = (testing ? 'testing-' : '') << "#{project_id}-#{repository_id}-#{platform_id}" + redis.hset PACKAGES_FOR_CLEANUP, key, old_packages.to_json end def fill_packages(bl, results_map, field = :sha1) @@ -185,10 +195,10 @@ module AbfWorker end end - def create_tasks_for_build_rpms + def create_tasks_for_build_rpms(testing = false) available_repos = BuildList. select('MIN(updated_at) as min_updated_at, save_to_repository_id, build_for_platform_id'). - where(:new_core => true, :status => BuildList::BUILD_PUBLISH). + where(:new_core => true, :status => (testing ? BuildList::BUILD_PUBLISH_INTO_TESTING : BuildList::BUILD_PUBLISH)). group(:save_to_repository_id, :build_for_platform_id). order(:min_updated_at). limit(@workers_count * 2) # because some repos may be locked @@ -198,7 +208,8 @@ module AbfWorker available_repos = available_repos.where('save_to_repository_id NOT IN (?)', locked_rep) unless locked_rep.empty? for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1).map do |key| - pr, rep, pl = *key.split('-') + next if testing && key !~ /^testing-/ + rep, pl = *key.split('-').last(2) locked_rep.present? && locked_rep.include?(rep.to_i) ? nil : [rep.to_i, pl.to_i] end.compact @@ -207,24 +218,26 @@ module AbfWorker available_repos.each do |save_to_repository_id, build_for_platform_id| next if RepositoryStatus.not_ready.where(:repository_id => save_to_repository_id, :platform_id => build_for_platform_id).exists? break if counter > @workers_count - counter += 1 if create_rpm_build_task(save_to_repository_id, build_for_platform_id) + counter += 1 if create_rpm_build_task(save_to_repository_id, build_for_platform_id, testing) end end - def create_rpm_build_task(save_to_repository_id, build_for_platform_id) - projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). - select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ } + def create_rpm_build_task(save_to_repository_id, build_for_platform_id, testing) + key = "#{save_to_repository_id}-#{build_for_platform_id}" + projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1).select do |k| + (testing && k =~ /^testing-#{key}$/) || (!testing && k =~ /^[\d]+-#{key}$/) + end # We should not to publish new builds into repository # if project of builds has been removed from repository. BuildList.where( - :project_id => projects_for_cleanup.map{ |k| k.split('-')[0] }.uniq, + :project_id => projects_for_cleanup.map{ |k| k.split('-')[testing ? 1 : 0] }.uniq, :save_to_repository_id => save_to_repository_id, - :status => BuildList::BUILD_PUBLISH + :status => [BuildList::BUILD_PUBLISH, BuildList::BUILD_PUBLISH_INTO_TESTING] ).update_all(:status => BuildList::FAILED_PUBLISH) build_lists = BuildList. - where(:new_core => true, :status => BuildList::BUILD_PUBLISH). + where(:new_core => true, :status => (testing ? BuildList::BUILD_PUBLISH_INTO_TESTING : BuildList::BUILD_PUBLISH)). where(:save_to_repository_id => save_to_repository_id). where(:build_for_platform_id => build_for_platform_id). order(:updated_at) @@ -271,7 +284,8 @@ module AbfWorker 'REPOSITORY_NAME' => save_to_repository.name, 'TYPE' => distrib_type, 'SAVE_TO_PLATFORM' => save_to_platform.name, - 'BUILD_FOR_PLATFORM' => build_for_platform.name + 'BUILD_FOR_PLATFORM' => build_for_platform.name, + 'TESTING' => testing }.map{ |k, v| "#{k}=#{v}" }.join(' ') options = { From 3395bb683f7de33f5cc852a3adf28cc51de521a2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 5 Nov 2013 22:33:28 +0400 Subject: [PATCH 3/4] #316: updated publish_observer --- lib/abf_worker/publish_observer.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index 99a301459..7ad128c9a 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -52,10 +52,18 @@ module AbfWorker update_results build_list case status when COMPLETED - # 'update_column' - when project of build_list has been removed from repository - build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) + if build_list.build_publish? + # 'update_column' - when project of build_list has been removed from repository + build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) + elsif build_list.build_publish_into_testing? + build_list.published_into_testing || build_list.update_column(:status, BuildList::BUILD_PUBLISHED_INTO_TESTING) + end when FAILED, CANCELED - build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH) + if build_list.build_publish? + build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH) + elsif build_list.build_publish_into_testing? + build_list.fail_publish_into_testing || build_list.update_column(:status, BuildList::FAILED_PUBLISH_INTO_TESTING) + end end AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list end From cac6ba16482e3ead4e09d654e9f27d9cabbe6594 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 5 Nov 2013 22:41:46 +0400 Subject: [PATCH 4/4] #316: updated JS and small refactoring --- app/assets/javascripts/angularjs/models/build_list.js.erb | 2 ++ app/helpers/build_lists_helper.rb | 7 +++---- app/models/ability.rb | 3 ++- app/models/build_list/item.rb | 3 +-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/angularjs/models/build_list.js.erb b/app/assets/javascripts/angularjs/models/build_list.js.erb index 020ca7ca9..8e86477b4 100644 --- a/app/assets/javascripts/angularjs/models/build_list.js.erb +++ b/app/assets/javascripts/angularjs/models/build_list.js.erb @@ -45,9 +45,11 @@ var BuildList = function(atts, dictionary) { switch (self.status) { // See: app/helpers/build_lists_helper.rb case <%=BuildList::BUILD_PUBLISHED%>: + case <%=BuildList::BUILD_PUBLISHED_INTO_TESTING%>: case <%=BuildList::SUCCESS%>: self.status_color = 'success'; break case <%=BuildList::BUILD_ERROR%>: case <%=BuildList::FAILED_PUBLISH%>: + case <%=BuildList::FAILED_PUBLISH_INTO_TESTING%>: case <%=BuildList::REJECTED_PUBLISH%>: self.status_color = 'error'; break case <%=BuildList::TESTS_FAILED%>: self.status_color = 'warning'; break default: self.status_color = 'nocolor'; diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index ff1702d97..1c7058fc4 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -4,9 +4,9 @@ module BuildListsHelper # See: app/assets/javascripts/angularjs/models/build_list.js.erb def build_list_status_color(status) case status - when BuildList::BUILD_PUBLISHED, BuildList::SUCCESS + when BuildList::BUILD_PUBLISHED, BuildList::SUCCESS, BuildList::BUILD_PUBLISHED_INTO_TESTING 'success' - when BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH + when BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH, BuildList::FAILED_PUBLISH_INTO_TESTING 'error' when BuildList::TESTS_FAILED 'warning' @@ -60,8 +60,7 @@ module BuildListsHelper case status when BuildList::SUCCESS 'success' - # when BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR - when BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR + when BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR #, BuildList::DEPENDENCIES_ERROR 'error' else '' diff --git a/app/models/ability.rb b/app/models/ability.rb index 463fe1890..303936d8e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -178,7 +178,8 @@ class Ability cannot [:publish, :publish_into_testing], BuildList, :new_core => false cannot :create_container, BuildList, :new_core => false - cannot([:publish, :publish_into_testing], BuildList) {|build_list| !build_list.can_publish? } + cannot(:publish, BuildList) {|build_list| !build_list.can_publish? } + cannot(:publish_into_testing, BuildList) {|build_list| !build_list.can_publish_into_testing? } cannot(:cancel, MassBuild) {|mass_build| mass_build.stop_build} diff --git a/app/models/build_list/item.rb b/app/models/build_list/item.rb index 0d3d429be..3c032d5f5 100644 --- a/app/models/build_list/item.rb +++ b/app/models/build_list/item.rb @@ -7,8 +7,7 @@ class BuildList::Item < ActiveRecord::Base GIT_ERROR = 5 - # STATUSES = [BuildList::SUCCESS, BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] - STATUSES = [BuildList::SUCCESS, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] + STATUSES = [BuildList::SUCCESS, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED] # BuildList::DEPENDENCIES_ERROR HUMAN_STATUSES = { nil => :unknown, GIT_ERROR => :git_error,