#316: added new statuses for BuildList

This commit is contained in:
Vokhmin Alexey V 2013-11-01 21:11:59 +04:00
parent fd73447098
commit 0cbd5b21e5
11 changed files with 102 additions and 60 deletions

View File

@ -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'

View File

@ -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
''

View File

@ -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}

View File

@ -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?

View File

@ -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,

View File

@ -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"),

View File

@ -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

View File

@ -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

View File

@ -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: Лог сборки

View File

@ -40,6 +40,7 @@ ru:
publish: Опубликовать
publish_again: Опубликовать снова
publish_again_warning: Повторная публикация может привести к нарушению зависимостей в репозитории. Будьте осторожны!
publish_into_testing: '[testing] Опубликовать'
reject_publish: Отклонить
add: Добавить
upload: Загрузить

View File

@ -277,6 +277,7 @@ Rosa::Application.routes.draw do
get :log
put :publish
put :reject_publish
put :publish_into_testing
end
end