[refs #847] refactoring
This commit is contained in:
parent
1873f9cd49
commit
643e163652
|
@ -1,11 +1,11 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module BuildListsHelper
|
||||
def build_list_status_color(status)
|
||||
if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS].include? status
|
||||
if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS].include? status
|
||||
return 'success'
|
||||
end
|
||||
if [BuildServer::BUILD_ERROR, BuildServer::PLATFORM_NOT_FOUND,
|
||||
BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND,
|
||||
if [BuildList::BUILD_ERROR, BuildList::PLATFORM_NOT_FOUND,
|
||||
BuildList::PROJECT_NOT_FOUND, BuildList::PROJECT_VERSION_NOT_FOUND,
|
||||
BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH].include? status
|
||||
return 'error'
|
||||
end
|
||||
|
@ -21,10 +21,10 @@ module BuildListsHelper
|
|||
end
|
||||
|
||||
def build_list_item_status_color(status)
|
||||
if BuildServer::SUCCESS == status
|
||||
if BuildList::SUCCESS == status
|
||||
return 'success'
|
||||
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'
|
||||
end
|
||||
|
||||
|
|
|
@ -130,8 +130,8 @@ class ActivityFeedObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
when 'BuildList'
|
||||
if [BuildList::BUILD_PUBLISHED, BuildServer::SUCCESS, BuildServer::BUILD_ERROR, BuildServer::PLATFORM_NOT_FOUND,
|
||||
BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH].include? record.status or
|
||||
if [BuildList::BUILD_PUBLISHED, BuildList::SUCCESS, BuildList::BUILD_ERROR, BuildList::PLATFORM_NOT_FOUND,
|
||||
BuildList::PROJECT_NOT_FOUND, BuildList::PROJECT_VERSION_NOT_FOUND, BuildList::FAILED_PUBLISH].include? record.status or
|
||||
(record.status == BuildList::BUILD_PENDING && record.bs_id_changed?)
|
||||
record.project.admins.each do |recipient|
|
||||
ActivityFeed.create(
|
||||
|
|
|
@ -49,15 +49,25 @@ class BuildList < ActiveRecord::Base
|
|||
LIVE_TIME = 4.week # for unpublished
|
||||
MAX_LIVE_TIME = 3.month # for published
|
||||
|
||||
# The kernel does not send these statuses directly
|
||||
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
|
||||
SUCCESS = 0
|
||||
ERROR = 1
|
||||
|
||||
PLATFORM_NOT_FOUND = 1
|
||||
PLATFORM_PENDING = 2
|
||||
PROJECT_NOT_FOUND = 3
|
||||
PROJECT_VERSION_NOT_FOUND = 4
|
||||
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
|
||||
|
||||
STATUSES = [ WAITING_FOR_RESPONSE,
|
||||
BUILD_CANCELED,
|
||||
|
@ -67,15 +77,13 @@ class BuildList < ActiveRecord::Base
|
|||
BUILD_PUBLISH,
|
||||
FAILED_PUBLISH,
|
||||
REJECTED_PUBLISH,
|
||||
BuildServer::SUCCESS,
|
||||
BuildServer::BUILD_STARTED,
|
||||
BuildServer::BUILD_ERROR,
|
||||
BuildServer::PLATFORM_NOT_FOUND,
|
||||
BuildServer::PLATFORM_PENDING,
|
||||
BuildServer::PROJECT_NOT_FOUND,
|
||||
BuildServer::PROJECT_VERSION_NOT_FOUND,
|
||||
# BuildServer::BINARY_TEST_FAILED,
|
||||
# BuildServer::DEPENDENCY_TEST_FAILED
|
||||
SUCCESS,
|
||||
BUILD_STARTED,
|
||||
BUILD_ERROR,
|
||||
PLATFORM_NOT_FOUND,
|
||||
PLATFORM_PENDING,
|
||||
PROJECT_NOT_FOUND,
|
||||
PROJECT_VERSION_NOT_FOUND
|
||||
]
|
||||
|
||||
HUMAN_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_response,
|
||||
|
@ -86,15 +94,13 @@ class BuildList < ActiveRecord::Base
|
|||
BUILD_PUBLISH => :build_publish,
|
||||
FAILED_PUBLISH => :failed_publish,
|
||||
REJECTED_PUBLISH => :rejected_publish,
|
||||
BuildServer::BUILD_ERROR => :build_error,
|
||||
BuildServer::BUILD_STARTED => :build_started,
|
||||
BuildServer::SUCCESS => :success,
|
||||
BuildServer::PLATFORM_NOT_FOUND => :platform_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
|
||||
BUILD_ERROR => :build_error,
|
||||
BUILD_STARTED => :build_started,
|
||||
SUCCESS => :success,
|
||||
PLATFORM_NOT_FOUND => :platform_not_found,
|
||||
PLATFORM_PENDING => :platform_pending,
|
||||
PROJECT_NOT_FOUND => :project_not_found,
|
||||
PROJECT_VERSION_NOT_FOUND => :project_version_not_found,
|
||||
}
|
||||
|
||||
scope :recent, order("#{table_name}.updated_at DESC")
|
||||
|
@ -132,14 +138,14 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
# WTF? around_transition -> infinite loop
|
||||
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)
|
||||
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
|
||||
end
|
||||
|
@ -154,14 +160,13 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
event :place_build do
|
||||
transition :waiting_for_response => :build_pending, :if => lambda { |build_list|
|
||||
build_list.add_to_queue == BuildServer::SUCCESS
|
||||
build_list.add_to_queue == BuildList::SUCCESS
|
||||
}
|
||||
[
|
||||
'BuildList::BUILD_PENDING',
|
||||
'BuildServer::PLATFORM_PENDING',
|
||||
'BuildServer::PLATFORM_NOT_FOUND',
|
||||
'BuildServer::PROJECT_NOT_FOUND',
|
||||
'BuildServer::PROJECT_VERSION_NOT_FOUND'
|
||||
%w[BUILD_PENDING
|
||||
PLATFORM_PENDING
|
||||
PLATFORM_NOT_FOUND
|
||||
PROJECT_NOT_FOUND
|
||||
PROJECT_VERSION_NOT_FOUND
|
||||
].each do |code|
|
||||
transition :waiting_for_response => code.demodulize.downcase.to_sym, :if => lambda { |build_list|
|
||||
build_list.add_to_queue == code.constantize
|
||||
|
@ -242,7 +247,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def can_publish?
|
||||
[BuildServer::SUCCESS, FAILED_PUBLISH].include? status
|
||||
[SUCCESS, FAILED_PUBLISH].include? status
|
||||
end
|
||||
|
||||
def can_reject_publish?
|
||||
|
@ -267,7 +272,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.status_by_human(human)
|
||||
BuildList::HUMAN_STATUSES.key human
|
||||
HUMAN_STATUSES.key human
|
||||
end
|
||||
|
||||
def set_items(items_hash)
|
||||
|
@ -309,8 +314,8 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def in_work?
|
||||
status == BuildServer::BUILD_STARTED
|
||||
#[WAITING_FOR_RESPONSE, BuildServer::BUILD_PENDING, BuildServer::BUILD_STARTED].include?(status)
|
||||
status == BUILD_STARTED
|
||||
#[WAITING_FOR_RESPONSE, BUILD_PENDING, BUILD_STARTED].include?(status)
|
||||
end
|
||||
|
||||
def associate_and_create_advisory(params)
|
||||
|
|
|
@ -7,14 +7,14 @@ class BuildList::Item < ActiveRecord::Base
|
|||
|
||||
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 = {
|
||||
nil => :unknown,
|
||||
GIT_ERROR => :git_error,
|
||||
BuildServer::DEPENDENCIES_ERROR => :dependencies_error,
|
||||
BuildServer::SUCCESS => :success,
|
||||
BuildServer::BUILD_STARTED => :build_started,
|
||||
BuildServer::BUILD_ERROR => :build_error,
|
||||
BuildList::DEPENDENCIES_ERROR => :dependencies_error,
|
||||
BuildList::SUCCESS => :success,
|
||||
BuildList::BUILD_STARTED => :build_started,
|
||||
BuildList::BUILD_ERROR => :build_error,
|
||||
BuildList::BUILD_CANCELED => :build_canceled
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,15 @@ class BuildListObserver < ActiveRecord::Observer
|
|||
|
||||
def before_update(record)
|
||||
if record.status_changed?
|
||||
record.started_at = Time.now if record.status == BuildServer::BUILD_STARTED
|
||||
if [BuildServer::BUILD_ERROR,
|
||||
BuildServer::SUCCESS,
|
||||
record.started_at = Time.now if record.status == BuildList::BUILD_STARTED
|
||||
if [BuildList::BUILD_ERROR,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::BUILD_CANCELING,
|
||||
BuildList::BUILD_CANCELED].include? record.status
|
||||
# stores time interval beetwin build start and finish in seconds
|
||||
record.duration = record.current_duration if record.started_at
|
||||
|
||||
if record.status == BuildServer::SUCCESS
|
||||
if record.status == BuildList::SUCCESS
|
||||
# Update project average build time
|
||||
build_count = record.project.build_count
|
||||
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
|
||||
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 << "PROJECT_NAME: #{build_list.project.name}\n"
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
#require 'lib/build_server.rb'
|
||||
class Platform < ActiveRecord::Base
|
||||
VISIBILITIES = ['open', 'hidden']
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
%h3= t("layout.activity_feed.my_builds_by_day")
|
||||
%table{:cellpadding => "0", :cellspacing => "0"}
|
||||
%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
|
||||
%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})
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
- ['pending', nil]
|
||||
- when BuildList::BUILD_PUBLISHED
|
||||
- ['published', nil]
|
||||
- when BuildServer::SUCCESS
|
||||
- when BuildList::SUCCESS
|
||||
- ['success', nil]
|
||||
- else ['failed', t("layout.build_lists.statuses.#{BuildList::HUMAN_STATUSES[status]}")]
|
||||
= raw t("notifications.bodies.build_status.#{message}", :error => error)
|
||||
|
|
|
@ -116,8 +116,6 @@ en:
|
|||
waiting_for_response: Waiting for response
|
||||
build_pending: Build pending
|
||||
build_canceling: Build is canceling
|
||||
dependency_test_failed: Dependency test failed
|
||||
binary_test_failed: Binary test failed
|
||||
build_canceled: Build canceled
|
||||
success: Build complete
|
||||
build_started: Build started
|
||||
|
|
|
@ -112,8 +112,6 @@ ru:
|
|||
dependencies_fail: зависимости не найдены
|
||||
waiting_for_response: ожидает ответа
|
||||
build_pending: ожидает сборку
|
||||
dependency_test_failed: тестирование зависимостей не пройдено
|
||||
binary_test_failed: тестирование бинарной совместимости не пройдено
|
||||
build_canceled: сборка отменена
|
||||
build_canceling: сборка отменяется
|
||||
success: собран
|
||||
|
|
|
@ -12,11 +12,11 @@ module AbfWorker
|
|||
case status
|
||||
when COMPLETED
|
||||
bl.build_success
|
||||
item.update_attributes({:status => BuildServer::SUCCESS})
|
||||
item.update_attributes({:status => BuildList::SUCCESS})
|
||||
bl.now_publish if bl.auto_publish?
|
||||
when FAILED
|
||||
bl.build_error
|
||||
item.update_attributes({:status => BuildServer::BUILD_ERROR})
|
||||
item.update_attributes({:status => BuildList::BUILD_ERROR})
|
||||
when STARTED
|
||||
bl.start_build
|
||||
when CANCELED
|
||||
|
@ -32,7 +32,7 @@ module AbfWorker
|
|||
bl.items.first || bl.items.create({
|
||||
:version => bl.commit_hash,
|
||||
:name => bl.project.name,
|
||||
:status => BuildServer::BUILD_STARTED,
|
||||
:status => BuildList::BUILD_STARTED,
|
||||
:level => 0
|
||||
})
|
||||
end
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
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
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class ProductBuilder
|
||||
SUCCESS = 0
|
||||
ERROR = 1
|
||||
end
|
|
@ -23,7 +23,7 @@ namespace :new_core do
|
|||
platform_repository_folder = "#{bl.save_to_platform.path}/repository"
|
||||
BuildList.where(:mass_build_id => 73).
|
||||
where(:status => [
|
||||
BuildServer::SUCCESS,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::FAILED_PUBLISH
|
||||
]).
|
||||
order(:id).
|
||||
|
@ -61,7 +61,7 @@ namespace :new_core do
|
|||
token = User.find_by_uname('rosa_system').authentication_token
|
||||
BuildList.where(:new_core => true).
|
||||
where(:status => [
|
||||
BuildServer::SUCCESS,
|
||||
BuildList::SUCCESS,
|
||||
BuildList::FAILED_PUBLISH,
|
||||
BuildList::BUILD_PUBLISHED,
|
||||
BuildList::BUILD_PUBLISH
|
||||
|
|
|
@ -130,15 +130,15 @@ describe Api::V1::BuildListsController do
|
|||
|
||||
context "if it has another status" 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_NOT_FOUND)
|
||||
do_cancel
|
||||
response.body.should == {:is_canceled => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => incorrect_action_message}.to_json
|
||||
end
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
||||
@build_list.update_column(:status, BuildList::PROJECT_NOT_FOUND)
|
||||
do_cancel
|
||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
||||
@build_list.reload.status.should == BuildList::PROJECT_NOT_FOUND
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -183,7 +183,7 @@ describe Api::V1::BuildListsController do
|
|||
|
||||
context "if it has another status" do
|
||||
before(:each) do
|
||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
||||
@build_list.update_column(:status, BuildList::PROJECT_NOT_FOUND)
|
||||
do_publish
|
||||
end
|
||||
|
||||
|
@ -192,7 +192,7 @@ describe Api::V1::BuildListsController do
|
|||
end
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
||||
@build_list.reload.status.should == BuildList::PROJECT_NOT_FOUND
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -226,7 +226,7 @@ describe Api::V1::BuildListsController do
|
|||
context 'if user is project owner' do
|
||||
before(:each) do
|
||||
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)
|
||||
do_reject_publish
|
||||
end
|
||||
|
@ -243,7 +243,7 @@ describe Api::V1::BuildListsController do
|
|||
|
||||
context "if it has another status" do
|
||||
before(:each) do
|
||||
@build_list.update_column(:status, BuildServer::PROJECT_NOT_FOUND)
|
||||
@build_list.update_column(:status, BuildList::PROJECT_NOT_FOUND)
|
||||
do_reject_publish
|
||||
end
|
||||
|
||||
|
@ -252,14 +252,14 @@ describe Api::V1::BuildListsController do
|
|||
end
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.reload.status.should == BuildServer::PROJECT_NOT_FOUND
|
||||
@build_list.reload.status.should == BuildList::PROJECT_NOT_FOUND
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'if user is not project owner' 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)
|
||||
do_reject_publish
|
||||
end
|
||||
|
@ -270,7 +270,7 @@ describe Api::V1::BuildListsController do
|
|||
|
||||
it "should not cancel build list" do
|
||||
do_reject_publish
|
||||
@build_list.reload.status.should == BuildServer::SUCCESS
|
||||
@build_list.reload.status.should == BuildList::SUCCESS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ describe BuildList do
|
|||
before(:all) { ActionMailer::Base.deliveries = [] }
|
||||
before do
|
||||
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
|
||||
after { ActionMailer::Base.deliveries = [] }
|
||||
|
||||
|
|
Loading…
Reference in New Issue