Merge pull request #849 from warpc/847-remove_old_code
[refs #847] Remove old core code
This commit is contained in:
commit
f380cd8399
|
@ -1,18 +1,15 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class Projects::BuildListsController < Projects::BaseController
|
class Projects::BuildListsController < Projects::BaseController
|
||||||
CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
|
|
||||||
NESTED_ACTIONS = [:search, :index, :new, :create]
|
NESTED_ACTIONS = [:search, :index, :new, :create]
|
||||||
|
|
||||||
before_filter :authenticate_user!, :except => CALLBACK_ACTIONS
|
before_filter :authenticate_user!
|
||||||
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
|
|
||||||
skip_before_filter :authenticate_user!, :only => [:show, :index, :search, :log] if APP_CONFIG['anonymous_access']
|
skip_before_filter :authenticate_user!, :only => [:show, :index, :search, :log] if APP_CONFIG['anonymous_access']
|
||||||
|
|
||||||
before_filter :find_build_list, :only => [:show, :publish, :cancel, :update, :log]
|
before_filter :find_build_list, :only => [:show, :publish, :cancel, :update, :log]
|
||||||
before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build, :circle_build]
|
|
||||||
|
|
||||||
load_and_authorize_resource :project, :only => NESTED_ACTIONS
|
load_and_authorize_resource :project, :only => NESTED_ACTIONS
|
||||||
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
|
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
|
||||||
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
|
load_and_authorize_resource :except => NESTED_ACTIONS
|
||||||
|
|
||||||
def search
|
def search
|
||||||
new_params = {:filter => {}}
|
new_params = {:filter => {}}
|
||||||
|
@ -93,12 +90,10 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancel
|
def cancel
|
||||||
if @build_list.cancel
|
notice = if @build_list.cancel
|
||||||
notice = @build_list.new_core? ?
|
t('layout.build_lists.will_be_canceled')
|
||||||
t('layout.build_lists.will_be_canceled') :
|
|
||||||
t('layout.build_lists.cancel_success')
|
|
||||||
else
|
else
|
||||||
notice = t('layout.build_lists.cancel_fail')
|
t('layout.build_lists.cancel_fail')
|
||||||
end
|
end
|
||||||
redirect_to :back, :notice => notice
|
redirect_to :back, :notice => notice
|
||||||
end
|
end
|
||||||
|
@ -110,87 +105,19 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_build
|
|
||||||
if params[:status].to_i == 0 # ok
|
|
||||||
@build_list.published
|
|
||||||
else
|
|
||||||
@build_list.fail_publish
|
|
||||||
end
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
end
|
|
||||||
|
|
||||||
def status_build
|
|
||||||
@item = @build_list.items.find_by_name!(params[:package_name])
|
|
||||||
@item.status = params[:status]
|
|
||||||
@item.save
|
|
||||||
|
|
||||||
@build_list.container_path = params[:container_path]
|
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
@build_list.set_packages(ActiveSupport::JSON.decode(params[:pkg_info]), params[:package_name]) if params[:status].to_i == BuildServer::SUCCESS and params[:pkg_info].present?
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
end
|
|
||||||
|
|
||||||
def pre_build
|
|
||||||
@build_list.start_build
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
end
|
|
||||||
|
|
||||||
def post_build
|
|
||||||
params[:status].to_i == BuildServer::SUCCESS ? @build_list.build_success : @build_list.build_error
|
|
||||||
@build_list.container_path = params[:container_path]
|
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
|
|
||||||
@build_list.publish if @build_list.auto_publish # && @build_list.can_publish? # later with resque
|
|
||||||
end
|
|
||||||
|
|
||||||
def circle_build
|
|
||||||
@build_list.is_circle = true
|
|
||||||
@build_list.container_path = params[:container_path]
|
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
end
|
|
||||||
|
|
||||||
def new_bbdt
|
|
||||||
@build_list = BuildList.find_by_id!(params[:web_id])
|
|
||||||
@build_list.name = params[:name]
|
|
||||||
@build_list.additional_repos = ActiveSupport::JSON.decode(params[:additional_repos])
|
|
||||||
@build_list.set_items(ActiveSupport::JSON.decode(params[:items]))
|
|
||||||
@build_list.is_circle = (params[:is_circular].to_i != 0)
|
|
||||||
@build_list.bs_id = params[:id]
|
|
||||||
@build_list.save
|
|
||||||
|
|
||||||
render :nothing => true, :status => 200
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def find_build_list
|
def find_build_list
|
||||||
@build_list = BuildList.find(params[:id])
|
@build_list = BuildList.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_build_list_by_bs
|
|
||||||
@build_list = BuildList.find_by_bs_id!(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
def authenticate_build_service!
|
|
||||||
if request.remote_ip != APP_CONFIG['build_server_ip']
|
|
||||||
render :nothing => true, :status => 403
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
@build_list.update_type = params[:build_list][:update_type] if params[:build_list][:update_type].present?
|
@build_list.update_type = params[:build_list][:update_type] if params[:build_list][:update_type].present?
|
||||||
|
|
||||||
if params[:attach_advisory].present? and params[:attach_advisory] != 'no' and !@build_list.advisory
|
if params[:attach_advisory].present? and params[:attach_advisory] != 'no' and !@build_list.advisory
|
||||||
|
|
||||||
unless @build_list.update_type.in? BuildList::RELEASE_UPDATE_TYPES
|
unless @build_list.update_type.in? BuildList::RELEASE_UPDATE_TYPES
|
||||||
redirect_to :back, :notice => t('lyout.build_lists.publish_fail') and return
|
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:attach_advisory] == 'new'
|
if params[:attach_advisory] == 'new'
|
||||||
|
@ -222,5 +149,4 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail')
|
redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
module BuildListsHelper
|
module BuildListsHelper
|
||||||
def build_list_status_color(status)
|
def build_list_status_color(status)
|
||||||
if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS].include? status
|
if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS].include? status
|
||||||
return 'success'
|
return 'success'
|
||||||
end
|
end
|
||||||
if [BuildServer::BUILD_ERROR, BuildServer::PLATFORM_NOT_FOUND,
|
if [BuildList::BUILD_ERROR, BuildList::PROJECT_VERSION_NOT_FOUND,
|
||||||
BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND,
|
|
||||||
BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH].include? status
|
BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH].include? status
|
||||||
return 'error'
|
return 'error'
|
||||||
end
|
end
|
||||||
|
@ -21,10 +20,10 @@ module BuildListsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_list_item_status_color(status)
|
def build_list_item_status_color(status)
|
||||||
if BuildServer::SUCCESS == status
|
if BuildList::SUCCESS == status
|
||||||
return 'success'
|
return 'success'
|
||||||
end
|
end
|
||||||
if [BuildServer::DEPENDENCIES_ERROR, BuildServer::BUILD_ERROR, BuildList::Item::GIT_ERROR].include? status
|
if [BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::Item::GIT_ERROR].include? status
|
||||||
return 'error'
|
return 'error'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,8 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
|
|
||||||
when 'BuildList'
|
when 'BuildList'
|
||||||
if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS, BuildServer::BUILD_ERROR, BuildServer::PLATFORM_NOT_FOUND,
|
if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS, BuildList::BUILD_ERROR,
|
||||||
BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH].include? record.status or
|
BuildList::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH].include? record.status or
|
||||||
(record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
(record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
||||||
record.project.admins.each do |recipient|
|
record.project.admins.each do |recipient|
|
||||||
ActivityFeed.create(
|
ActivityFeed.create(
|
||||||
|
|
|
@ -39,7 +39,6 @@ class BuildList < ActiveRecord::Base
|
||||||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) unless build_for_platform.repository_ids.include? ir.to_i
|
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) unless build_for_platform.repository_ids.include? ir.to_i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
validate lambda {
|
validate lambda {
|
||||||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
|
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
|
||||||
}
|
}
|
||||||
|
@ -50,7 +49,14 @@ class BuildList < ActiveRecord::Base
|
||||||
LIVE_TIME = 4.week # for unpublished
|
LIVE_TIME = 4.week # for unpublished
|
||||||
MAX_LIVE_TIME = 3.month # for published
|
MAX_LIVE_TIME = 3.month # for published
|
||||||
|
|
||||||
# The kernel does not send these statuses directly
|
SUCCESS = 0
|
||||||
|
ERROR = 1
|
||||||
|
|
||||||
|
PROJECT_VERSION_NOT_FOUND = 4
|
||||||
|
PROJECT_SOURCE_ERROR = 6
|
||||||
|
DEPENDENCIES_ERROR = 555
|
||||||
|
BUILD_ERROR = 666
|
||||||
|
BUILD_STARTED = 3000
|
||||||
BUILD_CANCELED = 5000
|
BUILD_CANCELED = 5000
|
||||||
WAITING_FOR_RESPONSE = 4000
|
WAITING_FOR_RESPONSE = 4000
|
||||||
BUILD_PENDING = 2000
|
BUILD_PENDING = 2000
|
||||||
|
@ -68,15 +74,10 @@ class BuildList < ActiveRecord::Base
|
||||||
BUILD_PUBLISH,
|
BUILD_PUBLISH,
|
||||||
FAILED_PUBLISH,
|
FAILED_PUBLISH,
|
||||||
REJECTED_PUBLISH,
|
REJECTED_PUBLISH,
|
||||||
BuildServer::SUCCESS,
|
SUCCESS,
|
||||||
BuildServer::BUILD_STARTED,
|
BUILD_STARTED,
|
||||||
BuildServer::BUILD_ERROR,
|
BUILD_ERROR,
|
||||||
BuildServer::PLATFORM_NOT_FOUND,
|
PROJECT_VERSION_NOT_FOUND
|
||||||
BuildServer::PLATFORM_PENDING,
|
|
||||||
BuildServer::PROJECT_NOT_FOUND,
|
|
||||||
BuildServer::PROJECT_VERSION_NOT_FOUND,
|
|
||||||
# BuildServer::BINARY_TEST_FAILED,
|
|
||||||
# BuildServer::DEPENDENCY_TEST_FAILED
|
|
||||||
]
|
]
|
||||||
|
|
||||||
HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response,
|
HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response,
|
||||||
|
@ -87,15 +88,10 @@ class BuildList < ActiveRecord::Base
|
||||||
BUILD_PUBLISH => :build_publish,
|
BUILD_PUBLISH => :build_publish,
|
||||||
FAILED_PUBLISH => :failed_publish,
|
FAILED_PUBLISH => :failed_publish,
|
||||||
REJECTED_PUBLISH => :rejected_publish,
|
REJECTED_PUBLISH => :rejected_publish,
|
||||||
BuildServer::BUILD_ERROR => :build_error,
|
BUILD_ERROR => :build_error,
|
||||||
BuildServer::BUILD_STARTED => :build_started,
|
BUILD_STARTED => :build_started,
|
||||||
BuildServer::SUCCESS => :success,
|
SUCCESS => :success,
|
||||||
BuildServer::PLATFORM_NOT_FOUND => :platform_not_found,
|
PROJECT_VERSION_NOT_FOUND => :project_version_not_found,
|
||||||
BuildServer::PLATFORM_PENDING => :platform_pending,
|
|
||||||
BuildServer::PROJECT_NOT_FOUND => :project_not_found,
|
|
||||||
BuildServer::PROJECT_VERSION_NOT_FOUND => :project_version_not_found,
|
|
||||||
# BuildServer::DEPENDENCY_TEST_FAILED => :dependency_test_failed,
|
|
||||||
# BuildServer::BINARY_TEST_FAILED => :binary_test_failed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :recent, order("#{table_name}.updated_at DESC")
|
scope :recent, order("#{table_name}.updated_at DESC")
|
||||||
|
@ -128,28 +124,26 @@ class BuildList < ActiveRecord::Base
|
||||||
serialize :results, Array
|
serialize :results, Array
|
||||||
|
|
||||||
after_commit :place_build
|
after_commit :place_build
|
||||||
after_destroy :delete_container
|
|
||||||
|
|
||||||
state_machine :status, :initial => :waiting_for_response do
|
state_machine :status, :initial => :waiting_for_response do
|
||||||
|
|
||||||
# WTF? around_transition -> infinite loop
|
# WTF? around_transition -> infinite loop
|
||||||
before_transition do |build_list, transition|
|
before_transition do |build_list, transition|
|
||||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
status = HUMAN_STATUSES[build_list.status]
|
||||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||||
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
|
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after_transition do |build_list, transition|
|
after_transition do |build_list, transition|
|
||||||
status = BuildList::HUMAN_STATUSES[build_list.status]
|
status = HUMAN_STATUSES[build_list.status]
|
||||||
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
|
||||||
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
after_transition :on => :published, :do => [:set_version_and_tag, :actualize_packages]
|
after_transition :on => :published, :do => [:set_version_and_tag, :actualize_packages]
|
||||||
after_transition :on => :cancel, :do => [:cancel_job],
|
after_transition :on => :cancel, :do => :cancel_job
|
||||||
:if => lambda { |build_list| build_list.new_core? }
|
|
||||||
|
|
||||||
after_transition :on => [:published, :fail_publish, :build_error], :do => :notify_users
|
after_transition :on => [:published, :fail_publish, :build_error], :do => :notify_users
|
||||||
after_transition :on => :build_success, :do => :notify_users,
|
after_transition :on => :build_success, :do => :notify_users,
|
||||||
|
@ -157,15 +151,9 @@ class BuildList < ActiveRecord::Base
|
||||||
|
|
||||||
event :place_build do
|
event :place_build do
|
||||||
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
|
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
|
||||||
build_list.add_to_queue == BuildServer::SUCCESS
|
build_list.add_to_queue == BuildList::SUCCESS
|
||||||
}
|
}
|
||||||
[
|
%w[BUILD_PENDING PROJECT_VERSION_NOT_FOUND].each do |code|
|
||||||
'BuildList::BUILD_PENDING',
|
|
||||||
'BuildServer::PLATFORM_PENDING',
|
|
||||||
'BuildServer::PLATFORM_NOT_FOUND',
|
|
||||||
'BuildServer::PROJECT_NOT_FOUND',
|
|
||||||
'BuildServer::PROJECT_VERSION_NOT_FOUND'
|
|
||||||
].each do |code|
|
|
||||||
transition :waiting_for_response => code.demodulize.downcase.to_sym, :if => lambda { |build_list|
|
transition :waiting_for_response => code.demodulize.downcase.to_sym, :if => lambda { |build_list|
|
||||||
build_list.add_to_queue == code.constantize
|
build_list.add_to_queue == code.constantize
|
||||||
}
|
}
|
||||||
|
@ -173,28 +161,17 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
event :start_build do
|
event :start_build do
|
||||||
transition [ :build_pending,
|
transition [ :build_pending, :project_version_not_found ] => :build_started
|
||||||
:platform_pending,
|
|
||||||
:platform_not_found,
|
|
||||||
:project_not_found,
|
|
||||||
:project_version_not_found ] => :build_started
|
|
||||||
end
|
end
|
||||||
|
|
||||||
event :cancel do
|
event :cancel do
|
||||||
transition [:build_pending, :platform_pending] => :build_canceled, :if => lambda { |build_list|
|
transition [:build_pending, :build_started] => :build_canceling
|
||||||
!build_list.new_core? && build_list.can_cancel? && BuildServer.delete_build_list(build_list.bs_id) == BuildServer::SUCCESS
|
|
||||||
}
|
|
||||||
transition [:build_pending, :build_started] => :build_canceling, :if => lambda { |build_list|
|
|
||||||
build_list.new_core?
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# :build_canceling => :build_canceled - canceling from UI
|
# :build_canceling => :build_canceled - canceling from UI
|
||||||
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
||||||
event :build_canceled do
|
event :build_canceled do
|
||||||
transition [:build_canceling, :build_started] => :build_canceled, :if => lambda { |build_list|
|
transition [:build_canceling, :build_started] => :build_canceled
|
||||||
build_list.new_core?
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
event :published do
|
event :published do
|
||||||
|
@ -206,12 +183,7 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
event :publish do
|
event :publish do
|
||||||
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
transition [:success, :failed_publish] => :build_publish
|
||||||
!build_list.new_core? && BuildServer.publish_container(build_list.bs_id) == BuildServer::SUCCESS
|
|
||||||
}
|
|
||||||
transition [:success, :failed_publish] => :build_publish, :if => lambda { |build_list|
|
|
||||||
build_list.new_core?
|
|
||||||
}
|
|
||||||
transition [:success, :failed_publish] => :failed_publish
|
transition [:success, :failed_publish] => :failed_publish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -253,15 +225,11 @@ class BuildList < ActiveRecord::Base
|
||||||
|
|
||||||
#TODO: Share this checking on product owner.
|
#TODO: Share this checking on product owner.
|
||||||
def can_cancel?
|
def can_cancel?
|
||||||
if new_core?
|
|
||||||
build_started? || build_pending?
|
build_started? || build_pending?
|
||||||
else
|
|
||||||
[BUILD_PENDING, BuildServer::PLATFORM_PENDING].include?(status) && bs_id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_publish?
|
def can_publish?
|
||||||
[BuildServer::SUCCESS, FAILED_PUBLISH].include? status
|
[SUCCESS, FAILED_PUBLISH].include? status
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_reject_publish?
|
def can_reject_publish?
|
||||||
|
@ -269,41 +237,12 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_queue
|
def add_to_queue
|
||||||
if new_core?
|
|
||||||
# TODO: Investigate: why 2 tasks will be created without checking @state
|
# TODO: Investigate: why 2 tasks will be created without checking @state
|
||||||
unless @status
|
unless @status
|
||||||
add_job_to_abf_worker_queue
|
add_job_to_abf_worker_queue
|
||||||
update_column(:bs_id, id)
|
update_column(:bs_id, id)
|
||||||
end
|
end
|
||||||
@status ||= BUILD_PENDING
|
@status ||= BUILD_PENDING
|
||||||
else
|
|
||||||
# XML-RPC params:
|
|
||||||
# - project_name
|
|
||||||
# - project_version
|
|
||||||
# - plname
|
|
||||||
# - arch
|
|
||||||
# - bplname
|
|
||||||
# - update_type
|
|
||||||
# - build_requires
|
|
||||||
# - id_web
|
|
||||||
# - include_repos
|
|
||||||
# - priority
|
|
||||||
# - git_project_address
|
|
||||||
@status ||= BuildServer.add_build_list(
|
|
||||||
project.name,
|
|
||||||
project_version,
|
|
||||||
save_to_platform.name,
|
|
||||||
arch.name,
|
|
||||||
(save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name),
|
|
||||||
update_type,
|
|
||||||
false,
|
|
||||||
id,
|
|
||||||
include_repos,
|
|
||||||
priority,
|
|
||||||
project.git_project_address(user)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
@status
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.human_status(status)
|
def self.human_status(status)
|
||||||
|
@ -315,7 +254,7 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.status_by_human(human)
|
def self.status_by_human(human)
|
||||||
BuildList::HUMAN_STATUSES.key human
|
HUMAN_STATUSES.key human
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_items(items_hash)
|
def set_items(items_hash)
|
||||||
|
@ -357,8 +296,8 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def in_work?
|
def in_work?
|
||||||
status == BuildServer::BUILD_STARTED
|
status == BUILD_STARTED
|
||||||
#[WAITING_FOR_RESPONSE, BuildServer::BUILD_PENDING, BuildServer::BUILD_STARTED].include?(status)
|
#[WAITING_FOR_RESPONSE, BUILD_PENDING, BUILD_STARTED].include?(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
def associate_and_create_advisory(params)
|
def associate_and_create_advisory(params)
|
||||||
|
@ -459,14 +398,6 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end # notify_users
|
end # notify_users
|
||||||
|
|
||||||
def delete_container
|
|
||||||
if can_cancel?
|
|
||||||
BuildServer.delete_build_list bs_id
|
|
||||||
else
|
|
||||||
BuildServer.delete_container bs_id if bs_id # prevent error if bs_id does not set
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def build_package(pkg_hash, package_type, prj)
|
def build_package(pkg_hash, package_type, prj)
|
||||||
packages.create(pkg_hash) do |p|
|
packages.create(pkg_hash) do |p|
|
||||||
p.project = prj
|
p.project = prj
|
||||||
|
@ -475,5 +406,4 @@ class BuildList < ActiveRecord::Base
|
||||||
yield p
|
yield p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,14 +7,14 @@ class BuildList::Item < ActiveRecord::Base
|
||||||
|
|
||||||
GIT_ERROR = 5
|
GIT_ERROR = 5
|
||||||
|
|
||||||
STATUSES = [BuildServer::SUCCESS, BuildServer::DEPENDENCIES_ERROR, BuildServer::BUILD_ERROR, BuildServer::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED]
|
STATUSES = [BuildList::SUCCESS, BuildList::DEPENDENCIES_ERROR, BuildList::BUILD_ERROR, BuildList::BUILD_STARTED, GIT_ERROR, BuildList::BUILD_CANCELED]
|
||||||
HUMAN_STATUSES = {
|
HUMAN_STATUSES = {
|
||||||
nil => :unknown,
|
nil => :unknown,
|
||||||
GIT_ERROR => :git_error,
|
GIT_ERROR => :git_error,
|
||||||
BuildServer::DEPENDENCIES_ERROR => :dependencies_error,
|
BuildList::DEPENDENCIES_ERROR => :dependencies_error,
|
||||||
BuildServer::SUCCESS => :success,
|
BuildList::SUCCESS => :success,
|
||||||
BuildServer::BUILD_STARTED => :build_started,
|
BuildList::BUILD_STARTED => :build_started,
|
||||||
BuildServer::BUILD_ERROR => :build_error,
|
BuildList::BUILD_ERROR => :build_error,
|
||||||
BuildList::BUILD_CANCELED => :build_canceled
|
BuildList::BUILD_CANCELED => :build_canceled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,15 @@ class BuildListObserver < ActiveRecord::Observer
|
||||||
|
|
||||||
def before_update(record)
|
def before_update(record)
|
||||||
if record.status_changed?
|
if record.status_changed?
|
||||||
record.started_at = Time.now if record.status == BuildServer::BUILD_STARTED
|
record.started_at = Time.now if record.status == BuildList::BUILD_STARTED
|
||||||
if [BuildServer::BUILD_ERROR,
|
if [BuildList::BUILD_ERROR,
|
||||||
BuildServer::SUCCESS,
|
BuildList::SUCCESS,
|
||||||
BuildList::BUILD_CANCELING,
|
BuildList::BUILD_CANCELING,
|
||||||
BuildList::BUILD_CANCELED].include? record.status
|
BuildList::BUILD_CANCELED].include? record.status
|
||||||
# stores time interval beetwin build start and finish in seconds
|
# stores time interval beetwin build start and finish in seconds
|
||||||
record.duration = record.current_duration if record.started_at
|
record.duration = record.current_duration if record.started_at
|
||||||
|
|
||||||
if record.status == BuildServer::SUCCESS
|
if record.status == BuildList::SUCCESS
|
||||||
# Update project average build time
|
# Update project average build time
|
||||||
build_count = record.project.build_count
|
build_count = record.project.build_count
|
||||||
new_av_time = ( record.project.average_build_time * build_count + record.duration ) / ( build_count + 1 )
|
new_av_time = ( record.project.average_build_time * build_count + record.duration ) / ( build_count + 1 )
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MassBuild < ActiveRecord::Base
|
||||||
|
|
||||||
def generate_failed_builds_list
|
def generate_failed_builds_list
|
||||||
report = ""
|
report = ""
|
||||||
BuildList.where(:status => BuildServer::BUILD_ERROR, :mass_build_id => self.id).each do |build_list|
|
BuildList.where(:status => BuildList::BUILD_ERROR, :mass_build_id => self.id).each do |build_list|
|
||||||
report << "ID: #{build_list.id}; "
|
report << "ID: #{build_list.id}; "
|
||||||
report << "PROJECT_NAME: #{build_list.project.name}\n"
|
report << "PROJECT_NAME: #{build_list.project.name}\n"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
#require 'lib/build_server.rb'
|
|
||||||
class Platform < ActiveRecord::Base
|
class Platform < ActiveRecord::Base
|
||||||
VISIBILITIES = ['open', 'hidden']
|
VISIBILITIES = ['open', 'hidden']
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
|
|
||||||
after_create :add_job_to_abf_worker_queue
|
after_create :add_job_to_abf_worker_queue
|
||||||
before_destroy :can_destroy?
|
before_destroy :can_destroy?
|
||||||
after_destroy :xml_delete_iso_container
|
|
||||||
|
|
||||||
state_machine :status, :initial => :build_pending do
|
state_machine :status, :initial => :build_pending do
|
||||||
|
|
||||||
|
@ -75,7 +74,7 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
event :cancel do
|
event :cancel do
|
||||||
transition [:build_pending, :build_started] => :build_canceling
|
transition [:build_pending, :build_started] => :build_canceling
|
||||||
end
|
end
|
||||||
after_transition :on => :cancel, :do => [:cancel_job]
|
after_transition :on => :cancel, :do => :cancel_job
|
||||||
|
|
||||||
# :build_canceling => :build_canceled - canceling from UI
|
# :build_canceling => :build_canceled - canceling from UI
|
||||||
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
|
||||||
|
@ -162,18 +161,4 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
:user => {:uname => user.try(:uname), :email => user.try(:email)}
|
:user => {:uname => user.try(:uname), :email => user.try(:email)}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_delete_iso_container
|
|
||||||
# TODO: write new worker for delete
|
|
||||||
if project
|
|
||||||
raise "Failed to destroy product_build_list #{id} inside platform #{product.platform.name} (Not Implemented)."
|
|
||||||
else
|
|
||||||
result = ProductBuilder.delete_iso_container self
|
|
||||||
if result == ProductBuilder::SUCCESS
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
raise "Failed to destroy product_build_list #{id} inside platform #{product.platform.name} with code #{result}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -175,24 +175,6 @@ class Project < ActiveRecord::Base
|
||||||
"%02d:%02d" % [average_build_time / 3600, average_build_time % 3600 / 60]
|
"%02d:%02d" % [average_build_time / 3600, average_build_time % 3600 / 60]
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_rpc_create(repository)
|
|
||||||
result = BuildServer.create_project name, repository.platform.name, repository.name, path
|
|
||||||
if result == BuildServer::SUCCESS
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
raise "Failed to create project #{name} (repo #{repository.name}) inside platform #{repository.platform.name} in path #{path} with code #{result}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def xml_rpc_destroy(repository)
|
|
||||||
result = BuildServer.delete_project name, repository.platform.name
|
|
||||||
if result == BuildServer::SUCCESS
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
raise "Failed to delete repository #{name} (repo main) inside platform #{owner.uname}_personal with code #{result}."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy_project_from_repository(repository)
|
def destroy_project_from_repository(repository)
|
||||||
AbfWorker::BuildListsPublishTaskManager.destroy_project_from_repository self, repository
|
AbfWorker::BuildListsPublishTaskManager.destroy_project_from_repository self, repository
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
%h3= t("layout.activity_feed.my_builds_by_day")
|
%h3= t("layout.activity_feed.my_builds_by_day")
|
||||||
%table{:cellpadding => "0", :cellspacing => "0"}
|
%table{:cellpadding => "0", :cellspacing => "0"}
|
||||||
%tbody
|
%tbody
|
||||||
- ['BuildList::BUILD_PUBLISHED', 'BuildServer::SUCCESS', 'BuildServer::BUILD_STARTED', 'BuildList::BUILD_PENDING', 'BuildServer::BUILD_ERROR'].each do |state|
|
- ['BuildList::BUILD_PUBLISHED', 'BuildList::SUCCESS', 'BuildList::BUILD_STARTED', 'BuildList::BUILD_PENDING', 'BuildList::BUILD_ERROR'].each do |state|
|
||||||
%tr
|
%tr
|
||||||
%td.first
|
%td.first
|
||||||
= link_to t("layout.build_lists.statuses.#{state.demodulize.downcase}"), build_lists_path(:filter => {:status => state.constantize, :'updated_at_start(1i)' => midnight.year, :'updated_at_start(2i)' => midnight.month, :'updated_at_start(3i)' => midnight.day})
|
= link_to t("layout.build_lists.statuses.#{state.demodulize.downcase}"), build_lists_path(:filter => {:status => state.constantize, :'updated_at_start(1i)' => midnight.year, :'updated_at_start(2i)' => midnight.month, :'updated_at_start(3i)' => midnight.day})
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
- ['pending', nil]
|
- ['pending', nil]
|
||||||
- when BuildList::BUILD_PUBLISHED
|
- when BuildList::BUILD_PUBLISHED
|
||||||
- ['published', nil]
|
- ['published', nil]
|
||||||
- when BuildServer::SUCCESS
|
- when BuildList::SUCCESS
|
||||||
- ['success', nil]
|
- ['success', nil]
|
||||||
- else ['failed', t("layout.build_lists.statuses.#{BuildList::HUMAN_STATUSES[status]}")]
|
- else ['failed', t("layout.build_lists.statuses.#{BuildList::HUMAN_STATUSES[status]}")]
|
||||||
= raw t("notifications.bodies.build_status.#{message}", :error => error)
|
= raw t("notifications.bodies.build_status.#{message}", :error => error)
|
||||||
|
|
|
@ -40,13 +40,6 @@ set :workers_count, 4
|
||||||
require './lib/recipes/resque'
|
require './lib/recipes/resque'
|
||||||
|
|
||||||
namespace :deploy do
|
namespace :deploy do
|
||||||
task :stub_xml_rpc do
|
|
||||||
path = File.join(release_path, 'config', 'environment.rb')
|
|
||||||
code = %Q{\nrequire 'stub_xml_rpc'\n}
|
|
||||||
puts "Stub XML RPC"
|
|
||||||
run %Q{echo "#{code}" >> #{path}}
|
|
||||||
end
|
|
||||||
|
|
||||||
task :symlink_all, :roles => :app do
|
task :symlink_all, :roles => :app do
|
||||||
run "mkdir -p #{fetch :shared_path}/config"
|
run "mkdir -p #{fetch :shared_path}/config"
|
||||||
|
|
||||||
|
|
|
@ -41,5 +41,3 @@ Rosa::Application.configure do
|
||||||
# Log the query plan for queries taking more than this (works with SQLite, MySQL, and PostgreSQL)
|
# Log the query plan for queries taking more than this (works with SQLite, MySQL, and PostgreSQL)
|
||||||
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'stub_xml_rpc'
|
|
|
@ -65,5 +65,3 @@ Rosa::Application.configure do
|
||||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||||
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js)
|
config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js)
|
||||||
end
|
end
|
||||||
|
|
||||||
# require 'stub_xml_rpc'
|
|
||||||
|
|
|
@ -42,5 +42,3 @@ Rosa::Application.configure do
|
||||||
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
||||||
config.assets.allow_debugging = true
|
config.assets.allow_debugging = true
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'stub_xml_rpc' # TODO stub XML calls through stubbers
|
|
||||||
|
|
|
@ -116,14 +116,10 @@ en:
|
||||||
waiting_for_response: Waiting for response
|
waiting_for_response: Waiting for response
|
||||||
build_pending: Build pending
|
build_pending: Build pending
|
||||||
build_canceling: Build is canceling
|
build_canceling: Build is canceling
|
||||||
dependency_test_failed: Dependency test failed
|
|
||||||
binary_test_failed: Binary test failed
|
|
||||||
build_canceled: Build canceled
|
build_canceled: Build canceled
|
||||||
success: Build complete
|
success: Build complete
|
||||||
build_started: Build started
|
build_started: Build started
|
||||||
platform_not_found: Platform not found
|
|
||||||
platform_pending: Platform pending
|
platform_pending: Platform pending
|
||||||
project_not_found: Project not found
|
|
||||||
project_version_not_found: Project version not found
|
project_version_not_found: Project version not found
|
||||||
|
|
||||||
log:
|
log:
|
||||||
|
|
|
@ -112,15 +112,11 @@ ru:
|
||||||
dependencies_fail: зависимости не найдены
|
dependencies_fail: зависимости не найдены
|
||||||
waiting_for_response: ожидает ответа
|
waiting_for_response: ожидает ответа
|
||||||
build_pending: ожидает сборку
|
build_pending: ожидает сборку
|
||||||
dependency_test_failed: тестирование зависимостей не пройдено
|
|
||||||
binary_test_failed: тестирование бинарной совместимости не пройдено
|
|
||||||
build_canceled: сборка отменена
|
build_canceled: сборка отменена
|
||||||
build_canceling: сборка отменяется
|
build_canceling: сборка отменяется
|
||||||
success: собран
|
success: собран
|
||||||
build_started: собирается
|
build_started: собирается
|
||||||
platform_not_found: платформа не найдена
|
|
||||||
platform_pending: платформа в процессе создания
|
platform_pending: платформа в процессе создания
|
||||||
project_not_found: проект не найден
|
|
||||||
project_version_not_found: версия не найдена
|
project_version_not_found: версия не найдена
|
||||||
|
|
||||||
log:
|
log:
|
||||||
|
|
|
@ -11,7 +11,6 @@ en:
|
||||||
'devise/sessions_controller': 'User Authentication'
|
'devise/sessions_controller': 'User Authentication'
|
||||||
'devise/passwords_controller': 'Password recovery'
|
'devise/passwords_controller': 'Password recovery'
|
||||||
'users/omniauth_callbacks_controller': 'External users authentication'
|
'users/omniauth_callbacks_controller': 'External users authentication'
|
||||||
rpc_controller: 'XML RPC'
|
|
||||||
private_users_controller: 'access to private repositories'
|
private_users_controller: 'access to private repositories'
|
||||||
personal_repositories_controller: 'Personal repositories management'
|
personal_repositories_controller: 'Personal repositories management'
|
||||||
actions:
|
actions:
|
||||||
|
|
|
@ -11,7 +11,6 @@ ru:
|
||||||
'devise/sessions_controller': 'Аутентификация пользователей'
|
'devise/sessions_controller': 'Аутентификация пользователей'
|
||||||
'devise/passwords_controller': 'Восстановление пароля'
|
'devise/passwords_controller': 'Восстановление пароля'
|
||||||
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
||||||
rpc_controller: 'XML RPC'
|
|
||||||
private_users_controller: 'Доступ к приватным репозиториям'
|
private_users_controller: 'Доступ к приватным репозиториям'
|
||||||
personal_repositories_controller: 'Управление персональными репозиториями'
|
personal_repositories_controller: 'Управление персональными репозиториями'
|
||||||
actions:
|
actions:
|
||||||
|
|
|
@ -207,14 +207,6 @@ Rosa::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :module => 'projects' do
|
scope :module => 'projects' do
|
||||||
# Core callbacks
|
|
||||||
match 'build_lists/publish_build', :to => "build_lists#publish_build"
|
|
||||||
match 'build_lists/status_build', :to => "build_lists#status_build"
|
|
||||||
match 'build_lists/post_build', :to => "build_lists#post_build"
|
|
||||||
match 'build_lists/pre_build', :to => "build_lists#pre_build"
|
|
||||||
match 'build_lists/circle_build', :to => "build_lists#circle_build"
|
|
||||||
match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt"
|
|
||||||
|
|
||||||
resources :build_lists, :only => [:index, :show, :update] do
|
resources :build_lists, :only => [:index, :show, :update] do
|
||||||
member do
|
member do
|
||||||
put :cancel
|
put :cancel
|
||||||
|
|
|
@ -12,11 +12,11 @@ module AbfWorker
|
||||||
case status
|
case status
|
||||||
when COMPLETED
|
when COMPLETED
|
||||||
bl.build_success
|
bl.build_success
|
||||||
item.update_attributes({:status => BuildServer::SUCCESS})
|
item.update_attributes({:status => BuildList::SUCCESS})
|
||||||
bl.now_publish if bl.auto_publish?
|
bl.now_publish if bl.auto_publish?
|
||||||
when FAILED
|
when FAILED
|
||||||
bl.build_error
|
bl.build_error
|
||||||
item.update_attributes({:status => BuildServer::BUILD_ERROR})
|
item.update_attributes({:status => BuildList::BUILD_ERROR})
|
||||||
when STARTED
|
when STARTED
|
||||||
bl.start_build
|
bl.start_build
|
||||||
when CANCELED
|
when CANCELED
|
||||||
|
@ -32,7 +32,7 @@ module AbfWorker
|
||||||
bl.items.first || bl.items.create({
|
bl.items.first || bl.items.create({
|
||||||
:version => bl.commit_hash,
|
:version => bl.commit_hash,
|
||||||
:name => bl.project.name,
|
:name => bl.project.name,
|
||||||
:status => BuildServer::BUILD_STARTED,
|
:status => BuildList::BUILD_STARTED,
|
||||||
:level => 0
|
:level => 0
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
require 'xmlrpc/client'
|
|
||||||
|
|
||||||
class BuildServer
|
|
||||||
|
|
||||||
SUCCESS = 0
|
|
||||||
ERROR = 1
|
|
||||||
|
|
||||||
PLATFORM_NOT_FOUND = 1
|
|
||||||
PLATFORM_PENDING = 2
|
|
||||||
PROJECT_NOT_FOUND = 3
|
|
||||||
PROJECT_VERSION_NOT_FOUND = 4
|
|
||||||
PROJECT_SOURCE_ERROR = 6
|
|
||||||
|
|
||||||
DEPENDENCY_TEST_FAILED = 21
|
|
||||||
BINARY_TEST_FAILED = 22
|
|
||||||
|
|
||||||
DEPENDENCIES_ERROR = 555
|
|
||||||
BUILD_ERROR = 666
|
|
||||||
BUILD_STARTED = 3000
|
|
||||||
|
|
||||||
def self.client
|
|
||||||
@@client ||= XMLRPC::Client.new3('host' => APP_CONFIG['build_server_ip'], 'port' => APP_CONFIG['build_server_port'], 'path' => APP_CONFIG['build_server_path'])
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.add_platform name, platforms_root_folder, distrib_type, repos = {:src => [], :rpm => []}
|
|
||||||
self.client.call('add_platform', name, platforms_root_folder, repos, distrib_type)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_platform name
|
|
||||||
self.client.call('delete_platform', name)
|
|
||||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
|
||||||
0
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.clone_platform new_name, old_name, new_root_folder
|
|
||||||
self.client.call('clone_platform', new_name, old_name, new_root_folder)
|
|
||||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
|
||||||
0
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_repo name, platform_name
|
|
||||||
self.client.call('create_repository', name, platform_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_repo name, platform_name
|
|
||||||
self.client.call('delete_repository', name, platform_name)
|
|
||||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
|
||||||
0
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.clone_repo new_name, old_name, new_platform_name
|
|
||||||
self.client.call('clone_repo', new_name, old_name, new_platform_name)
|
|
||||||
rescue Timeout::Error => e # TODO remove this when core will be ready
|
|
||||||
0
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.publish_container container_id
|
|
||||||
self.client.call('publish_container', container_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_container container_id
|
|
||||||
self.client.call('delete_container', container_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_project name, platform_name, repo_name, git_project_path
|
|
||||||
self.client.call('create_project', name, platform_name, repo_name, git_project_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_project name, platform_name
|
|
||||||
self.client.call('delete_project', name, platform_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.add_to_repo name, repo_name
|
|
||||||
self.client.call('add_to_repo', name, repo_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.add_build_list project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_path
|
|
||||||
include_repos_hash = {}.tap do |h|
|
|
||||||
include_repos.each do |r|
|
|
||||||
repo = Repository.find r
|
|
||||||
h[repo.name] = repo.platform.public_downloads_url(nil, arch, repo.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# raise include_repos_hash.inspect
|
|
||||||
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos_hash, priority, git_project_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_build_list idlist
|
|
||||||
self.client.call('delete_build_list', idlist)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_status
|
|
||||||
self.client.call('get_status')
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.freeze platform_name
|
|
||||||
self.client.call('freeze_platform', platform_name)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Repository key pair calls
|
|
||||||
def self.import_gpg_key_pair key_pub, key_secret
|
|
||||||
self.client.call('import_gpg_key_pair', key_pub, key_secret)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.set_repository_key platform, repository, key_id
|
|
||||||
self.client.call('set_repository_key', platform, repository, key_id)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.rm_repository_key platform, repository
|
|
||||||
self.client.call('rm_repository_key', platform, repository)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,21 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
require 'xmlrpc/client'
|
|
||||||
|
|
||||||
class ProductBuilder
|
|
||||||
SUCCESS = 0
|
|
||||||
ERROR = 1
|
|
||||||
|
|
||||||
def self.client(distrib_type)
|
|
||||||
@@client ||= XMLRPC::Client.new3(:host => APP_CONFIG['product_builder_ip'][distrib_type], :port => APP_CONFIG['product_builder_port'], :path => APP_CONFIG['product_builder_path'])
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_product pbl # product_build_list
|
|
||||||
self.client(pbl.product.platform.distrib_type).
|
|
||||||
call('create_product', pbl.id.to_s, pbl.product.platform.name, pbl.product.ks, pbl.product.menu, pbl.product.build_script,
|
|
||||||
pbl.product.counter, [], pbl.product.tar.exists? ? "#{pbl.base_url}#{pbl.product.tar.url}" : '')
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_iso_container pbl # product_build_list
|
|
||||||
self.client(pbl.product.platform.distrib_type).call('delete_iso_container', pbl.product.platform.name, pbl.id.to_s)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
# -*- encoding : utf-8 -*-
|
|
||||||
require 'xmlrpc/client'
|
|
||||||
module XMLRPC
|
|
||||||
class Client
|
|
||||||
def call(*args)
|
|
||||||
# raise args.inspect
|
|
||||||
case
|
|
||||||
when args.first == 'get_status'
|
|
||||||
{'client_count' => 1, 'count_new_task' => 2, 'count_build_task' => 3}
|
|
||||||
else; 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -23,7 +23,7 @@ namespace :new_core do
|
||||||
platform_repository_folder = "#{bl.save_to_platform.path}/repository"
|
platform_repository_folder = "#{bl.save_to_platform.path}/repository"
|
||||||
BuildList.where(:mass_build_id => 73).
|
BuildList.where(:mass_build_id => 73).
|
||||||
where(:status => [
|
where(:status => [
|
||||||
BuildServer::SUCCESS,
|
BuildList::SUCCESS,
|
||||||
BuildList::FAILED_PUBLISH
|
BuildList::FAILED_PUBLISH
|
||||||
]).
|
]).
|
||||||
order(:id).
|
order(:id).
|
||||||
|
@ -61,7 +61,7 @@ namespace :new_core do
|
||||||
token = User.find_by_uname('rosa_system').authentication_token
|
token = User.find_by_uname('rosa_system').authentication_token
|
||||||
BuildList.where(:new_core => true).
|
BuildList.where(:new_core => true).
|
||||||
where(:status => [
|
where(:status => [
|
||||||
BuildServer::SUCCESS,
|
BuildList::SUCCESS,
|
||||||
BuildList::FAILED_PUBLISH,
|
BuildList::FAILED_PUBLISH,
|
||||||
BuildList::BUILD_PUBLISHED,
|
BuildList::BUILD_PUBLISHED,
|
||||||
BuildList::BUILD_PUBLISH
|
BuildList::BUILD_PUBLISH
|
||||||
|
|
|
@ -124,21 +124,21 @@ describe Api::V1::BuildListsController do
|
||||||
it "should cancel build list" do
|
it "should cancel build list" do
|
||||||
@build_list.update_column(:status, BuildList::BUILD_PENDING)
|
@build_list.update_column(:status, BuildList::BUILD_PENDING)
|
||||||
do_cancel
|
do_cancel
|
||||||
@build_list.reload.status.should == BuildList::BUILD_CANCELED
|
@build_list.reload.status.should == BuildList::BUILD_CANCELING
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "if it has another status" do
|
context "if it has another status" do
|
||||||
it "should return correct json error message" do
|
it "should return correct json error message" do
|
||||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
@build_list.update_column(:status, BuildList::PROJECT_VERSION_NOT_FOUND)
|
||||||
do_cancel
|
do_cancel
|
||||||
response.body.should == {:is_canceled => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => incorrect_action_message}.to_json
|
response.body.should == {:is_canceled => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => incorrect_action_message}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not cancel build list" do
|
it "should not cancel build list" do
|
||||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
@build_list.update_column(:status, BuildList::PROJECT_VERSION_NOT_FOUND)
|
||||||
do_cancel
|
do_cancel
|
||||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -183,7 +183,7 @@ describe Api::V1::BuildListsController do
|
||||||
|
|
||||||
context "if it has another status" do
|
context "if it has another status" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
@build_list.update_column(:status, BuildList::PROJECT_VERSION_NOT_FOUND)
|
||||||
do_publish
|
do_publish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ describe Api::V1::BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not cancel build list" do
|
it "should not cancel build list" do
|
||||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -226,7 +226,7 @@ describe Api::V1::BuildListsController do
|
||||||
context 'if user is project owner' do
|
context 'if user is project owner' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
http_login(@owner_user)
|
http_login(@owner_user)
|
||||||
@build_list.update_column(:status, BuildServer::SUCCESS)
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
||||||
@build_list.save_to_platform.update_column(:released, true)
|
@build_list.save_to_platform.update_column(:released, true)
|
||||||
do_reject_publish
|
do_reject_publish
|
||||||
end
|
end
|
||||||
|
@ -243,7 +243,7 @@ describe Api::V1::BuildListsController do
|
||||||
|
|
||||||
context "if it has another status" do
|
context "if it has another status" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
@build_list.update_column(:status, BuildList::PROJECT_VERSION_NOT_FOUND)
|
||||||
do_reject_publish
|
do_reject_publish
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -252,14 +252,14 @@ describe Api::V1::BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not cancel build list" do
|
it "should not cancel build list" do
|
||||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if user is not project owner' do
|
context 'if user is not project owner' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@build_list.update_column(:status, BuildServer::SUCCESS)
|
@build_list.update_column(:status, BuildList::SUCCESS)
|
||||||
@build_list.save_to_platform.update_column(:released, true)
|
@build_list.save_to_platform.update_column(:released, true)
|
||||||
do_reject_publish
|
do_reject_publish
|
||||||
end
|
end
|
||||||
|
@ -270,7 +270,7 @@ describe Api::V1::BuildListsController do
|
||||||
|
|
||||||
it "should not cancel build list" do
|
it "should not cancel build list" do
|
||||||
do_reject_publish
|
do_reject_publish
|
||||||
@build_list.reload.status.should == BuildServer::SUCCESS
|
@build_list.reload.status.should == BuildList::SUCCESS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -321,176 +321,5 @@ describe Projects::BuildListsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'callbacks' do
|
|
||||||
let(:build_list) { FactoryGirl.create(:build_list_core) }
|
|
||||||
let(:build_list_package) { FactoryGirl.create(:build_list_package, :build_list_id => build_list.id, :platform_id => build_list.save_to_platform_id, :project_id => build_list.project_id, :version => "4.7.5.3", :release => 1) }
|
|
||||||
|
|
||||||
before(:each) do
|
|
||||||
mock(controller).authenticate_build_service! {true}
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'publish_build' do
|
|
||||||
before {
|
|
||||||
build_list.update_column(:commit_hash, build_list.project.repo.commits('master').last.id)
|
|
||||||
build_list.update_column(:status, BuildList::BUILD_PUBLISH)
|
|
||||||
build_list_package
|
|
||||||
}
|
|
||||||
|
|
||||||
def do_get(status)
|
|
||||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
|
||||||
build_list.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it(:passes) {
|
|
||||||
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
|
||||||
do_get(BuildServer::SUCCESS)
|
|
||||||
response.should be_ok
|
|
||||||
}
|
|
||||||
it 'should create correct git tag for correct commit' do
|
|
||||||
do_get(BuildServer::SUCCESS)
|
|
||||||
build_list.project.repo.tags.last.name.should == build_list.package_version
|
|
||||||
build_list.project.repo.commits(build_list.package_version).last.id.should == build_list.commit_hash
|
|
||||||
end
|
|
||||||
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
|
||||||
it(:passes) { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to("#{ build_list_package.platform.name }-4.7.5.3-1") }
|
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should_not change(build_list, :package_version) }
|
|
||||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :updated_at) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'status_build' do
|
|
||||||
before do
|
|
||||||
@item = build_list.items.create(:name => build_list.project.name, :version => build_list.project_version, :level => 0)
|
|
||||||
repo = build_list.save_to_platform.repositories.first
|
|
||||||
@project2 = FactoryGirl.create(:project)
|
|
||||||
repo.projects << @project2
|
|
||||||
end
|
|
||||||
|
|
||||||
def do_get
|
|
||||||
get :status_build, :id => build_list.bs_id, :package_name => build_list.project.name, :status => BuildServer::SUCCESS, :container_path => '/path/to',
|
|
||||||
:pkg_info => ActiveSupport::JSON.encode({'srpm' => {'fullname' => 'srpm_filename.srpm',
|
|
||||||
'name' => build_list.project.name,
|
|
||||||
'version' => 'version1',
|
|
||||||
'release' => 'release1'},
|
|
||||||
'rpm' => [{'fullname' => 'filename1.rpm',
|
|
||||||
'name' => build_list.project.name,
|
|
||||||
'version' => 'version2',
|
|
||||||
'release' => 'release2'},
|
|
||||||
{'fullname' => 'filename2.rpm',
|
|
||||||
'name' => @project2.name,
|
|
||||||
'version' => 'version2',
|
|
||||||
'release' => 'release2'}]})
|
|
||||||
build_list.reload
|
|
||||||
@item.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { do_get; response.should be_ok }
|
|
||||||
it { lambda{ do_get }.should change(@item, :status) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :container_path) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
|
||||||
it('should create packages for build list') { lambda{ do_get }.should change(build_list.packages, :count).to(3) }
|
|
||||||
it 'should create correct packages for build list' do
|
|
||||||
do_get
|
|
||||||
package = build_list.packages.order('created_at ASC').first
|
|
||||||
package.fullname.should == 'srpm_filename.srpm'
|
|
||||||
package.name.should == build_list.project.name
|
|
||||||
package.version.should == 'version1'
|
|
||||||
package.release.should == 'release1'
|
|
||||||
package.package_type == 'source'
|
|
||||||
package.build_list.should == build_list
|
|
||||||
package.platform.should == build_list.save_to_platform
|
|
||||||
package.project.should == build_list.project
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'pre_build' do
|
|
||||||
before do
|
|
||||||
build_list.update_column :status, BuildList::BUILD_PENDING
|
|
||||||
end
|
|
||||||
|
|
||||||
def do_get
|
|
||||||
get :pre_build, :id => build_list.bs_id
|
|
||||||
build_list.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { do_get; response.should be_ok }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :status).to(BuildServer::BUILD_STARTED) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'post_build' do
|
|
||||||
def do_get(status)
|
|
||||||
build_list.started_at = Time.now
|
|
||||||
build_list.save
|
|
||||||
get :post_build, :id => build_list.bs_id, :status => status, :container_path => '/path/to'
|
|
||||||
build_list.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :container_path) }
|
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :updated_at) }
|
|
||||||
|
|
||||||
context 'with auto_publish' do
|
|
||||||
it(:passes) {
|
|
||||||
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
||||||
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
|
||||||
build_list.reload
|
|
||||||
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH)
|
|
||||||
}
|
|
||||||
it(:passes) {
|
|
||||||
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
||||||
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
|
||||||
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'without auto_publish' do
|
|
||||||
before { build_list.update_column(:auto_publish, false) }
|
|
||||||
|
|
||||||
it(:passes) {
|
|
||||||
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
||||||
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
|
||||||
lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS)
|
|
||||||
}
|
|
||||||
it(:passes) {
|
|
||||||
build_list.update_column(:started_at, (Time.now - 1.day))
|
|
||||||
build_list.update_column(:status, BuildServer::BUILD_STARTED)
|
|
||||||
lambda{ do_get(BuildServer::BUILD_ERROR) }.should change(build_list, :status).to(BuildServer::BUILD_ERROR)
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'circle_build' do
|
|
||||||
def do_get
|
|
||||||
get :circle_build, :id => build_list.bs_id, :container_path => '/path/to'
|
|
||||||
build_list.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { do_get; response.should be_ok }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :container_path) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'new_bbdt' do
|
|
||||||
before { @items = build_list.items }
|
|
||||||
|
|
||||||
def do_get
|
|
||||||
get :new_bbdt, :id => 123, :web_id => build_list.id, :name => build_list.project.name, :is_circular => 1,
|
|
||||||
:additional_repos => ActiveSupport::JSON.encode([{:name => 'build_repos'}, {:name => 'main'}]),
|
|
||||||
:items => ActiveSupport::JSON.encode(0 => [{:name => build_list.project.name, :version => build_list.project_version}])
|
|
||||||
build_list.reload
|
|
||||||
@items.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { do_get; response.should be_ok }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :name).to(build_list.project.name) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :additional_repos) }
|
|
||||||
it { lambda{ do_get }.should change(@items, :first) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :bs_id).to(123) }
|
|
||||||
it { lambda{ do_get }.should change(build_list, :updated_at) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
after(:all) {clean_projects_dir}
|
after(:all) {clean_projects_dir}
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe BuildList do
|
||||||
before(:all) { ActionMailer::Base.deliveries = [] }
|
before(:all) { ActionMailer::Base.deliveries = [] }
|
||||||
before do
|
before do
|
||||||
build_list.update_attributes({:commit_hash => build_list.project.repo.commits('master').last.id,
|
build_list.update_attributes({:commit_hash => build_list.project.repo.commits('master').last.id,
|
||||||
:status => BuildServer::BUILD_STARTED}, :without_protection => true)
|
:status => BuildList::BUILD_STARTED}, :without_protection => true)
|
||||||
end
|
end
|
||||||
after { ActionMailer::Base.deliveries = [] }
|
after { ActionMailer::Base.deliveries = [] }
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ APP_CONFIG['git_path'] = "#{Rails.root}/tmp/test_root"
|
||||||
|
|
||||||
def init_test_root
|
def init_test_root
|
||||||
clear_test_root
|
clear_test_root
|
||||||
%x(mkdir -p #{APP_CONFIG['root_path']}/{platforms,tmp})
|
%x(bash -c 'mkdir -p #{APP_CONFIG['root_path']}/{platforms,tmp}')
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_test_root
|
def clear_test_root
|
||||||
|
|
Loading…
Reference in New Issue