#390: added ability to rerun tests
This commit is contained in:
parent
6253c025c6
commit
90f921e038
|
@ -9,11 +9,13 @@ RosaABF.controller('BuildListsController', ['$scope', '$http', '$location', '$ti
|
|||
|
||||
$scope.opened = {};
|
||||
$scope.map_priorities = {
|
||||
<%=BuildList::WAITING_FOR_RESPONSE%>: 11,
|
||||
<%=BuildList::BUILD_PENDING%>: 10,
|
||||
<%=BuildList::BUILD_CANCELING%>: 9,
|
||||
<%=BuildList::BUILD_CANCELED%>: 8,
|
||||
<%=BuildList::BUILD_STARTED%>: 7,
|
||||
<%=BuildList::WAITING_FOR_RESPONSE%>: 13,
|
||||
<%=BuildList::BUILD_PENDING%>: 12,
|
||||
<%=BuildList::RERUN_TESTS%>: 11,
|
||||
<%=BuildList::BUILD_CANCELING%>: 10,
|
||||
<%=BuildList::BUILD_CANCELED%>: 9,
|
||||
<%=BuildList::BUILD_STARTED%>: 8,
|
||||
<%=BuildList::RERUNINNG_TESTS%>: 7,
|
||||
<%=BuildList::BUILD_PUBLISH%>: 6,
|
||||
<%=BuildList::BUILD_PUBLISHED%>: 5,
|
||||
<%=BuildList::BUILD_ERROR%>: 4,
|
||||
|
|
|
@ -14,7 +14,9 @@ class Api::V1::JobsController < Api::V1::BaseController
|
|||
else
|
||||
platform_ids = Platform.where(name: params[:platforms].split(',')).pluck(:id) if params[:platforms].present?
|
||||
arch_ids = Arch.where(name: params[:arches].split(',')).pluck(:id) if params[:arches].present?
|
||||
build_lists = BuildList.for_status(BuildList::BUILD_PENDING).scoped_to_arch(arch_ids).
|
||||
build_lists = BuildList.scoped_to_arch(arch_ids).
|
||||
for_status([BuildList::BUILD_PENDING, BuildList::RERUN_TESTS]).
|
||||
scoped_to_arch(arch_ids).
|
||||
oldest.order(:created_at)
|
||||
build_lists = build_lists.for_platform(platform_ids) if platform_ids.present?
|
||||
|
||||
|
|
|
@ -119,30 +119,29 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
end
|
||||
|
||||
@build_list.publisher = current_user
|
||||
message = @build_list.publish ? 'success' : 'fail'
|
||||
redirect_to :back, notice: t("layout.build_lists.publish_#{message}")
|
||||
do_and_back(:publish, 'publish_')
|
||||
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}")
|
||||
do_and_back(:publish_into_testing, 'publish_')
|
||||
end
|
||||
|
||||
def rerun_tests
|
||||
do_and_back(:rerun_tests, 'rerun_tests_')
|
||||
end
|
||||
|
||||
def reject_publish
|
||||
@build_list.publisher = current_user
|
||||
message = @build_list.reject_publish ? 'success' : 'fail'
|
||||
redirect_to :back, notice: t("layout.build_lists.reject_publish_#{message}")
|
||||
do_and_back(:reject_publish, 'reject_publish_')
|
||||
end
|
||||
|
||||
def create_container
|
||||
message = @build_list.publish_container ? 'success' : 'fail'
|
||||
redirect_to :back, notice: t("layout.build_lists.create_container_#{message}")
|
||||
do_and_back(:publish_container, 'create_container_')
|
||||
end
|
||||
|
||||
def cancel
|
||||
message = @build_list.cancel ? 'will_be_canceled' : 'cancel_fail'
|
||||
redirect_to :back, notice: t("layout.build_lists.#{message}")
|
||||
do_and_back(:cancel, nil, 'will_be_canceled', 'cancel_fail')
|
||||
end
|
||||
|
||||
def log
|
||||
|
@ -184,6 +183,13 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
|
||||
protected
|
||||
|
||||
def do_and_back(action, prefix, success = 'success', fail = 'fail')
|
||||
result = @build_list.send(action)
|
||||
message = result ? success : fail
|
||||
flash[result ? :notice : :error] = t("layout.build_lists.#{prefix}#{message}")
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
def find_build_list
|
||||
@build_list = BuildList.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -87,7 +87,7 @@ class Ability
|
|||
can([:read, :log, :everything, :list], BuildList, read_relations_with_projects('build_lists')) {|build_list| can? :read, build_list.project}
|
||||
|
||||
can(:publish_into_testing, BuildList) { |build_list| can?(:create, build_list) && build_list.save_to_platform.main? }
|
||||
can(:create, BuildList) {|build_list|
|
||||
can([:create, :rerun_tests], 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))
|
||||
|
|
|
@ -86,6 +86,8 @@ class BuildList < ActiveRecord::Base
|
|||
%w(BUILD_CANCELED 5000),
|
||||
%w(WAITING_FOR_RESPONSE 4000),
|
||||
%w(BUILD_PENDING 2000),
|
||||
%w(RERUN_TESTS 2500),
|
||||
%w(RERUNINNG_TESTS 2550),
|
||||
%w(BUILD_PUBLISHED 6000),
|
||||
%w(BUILD_PUBLISH 7000),
|
||||
%w(FAILED_PUBLISH 8000),
|
||||
|
@ -156,9 +158,10 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
state_machine :status, initial: :waiting_for_response do
|
||||
|
||||
after_transition(on: :place_build) do |build_list, transition|
|
||||
after_transition(on: [:place_build, :rerun_tests]) do |build_list, transition|
|
||||
build_list.add_job_to_abf_worker_queue if build_list.external_nodes.blank?
|
||||
end
|
||||
|
||||
after_transition on: :published,
|
||||
do: [:set_version_and_tag, :actualize_packages]
|
||||
after_transition on: :publish, do: :set_publisher
|
||||
|
@ -177,18 +180,25 @@ class BuildList < ActiveRecord::Base
|
|||
transition waiting_for_response: :build_pending
|
||||
end
|
||||
|
||||
event :rerun_tests do
|
||||
transition %i(success tests_failed) => :rerun_tests
|
||||
end
|
||||
|
||||
event :start_build do
|
||||
transition build_pending: :build_started
|
||||
transition rerun_tests: :reruninng_tests
|
||||
end
|
||||
|
||||
event :cancel do
|
||||
transition [:build_pending, :build_started] => :build_canceling
|
||||
transition [:rerun_tests, :reruninng_tests] => :tests_failed
|
||||
end
|
||||
|
||||
# build_canceling: :build_canceled - canceling from UI
|
||||
# build_started: :build_canceled - canceling from worker by time-out (time_living has been expired)
|
||||
event :build_canceled do
|
||||
transition [:build_canceling, :build_started, :build_pending] => :build_canceled
|
||||
transition [:rerun_tests, :reruninng_tests] => :tests_failed
|
||||
end
|
||||
|
||||
event :published do
|
||||
|
@ -245,12 +255,13 @@ class BuildList < ActiveRecord::Base
|
|||
# ===== into testing - end
|
||||
|
||||
event :build_success do
|
||||
transition [:build_started, :build_canceling, :build_canceled] => :success
|
||||
transition [:build_started, :build_canceling, :build_canceled, :reruninng_tests] => :success
|
||||
end
|
||||
|
||||
[:build_error, :tests_failed].each do |kind|
|
||||
event kind do
|
||||
transition [:build_started, :build_canceling, :build_canceled] => kind
|
||||
transition reruninng_tests: :tests_failed
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -525,6 +536,10 @@ class BuildList < ActiveRecord::Base
|
|||
'EXTRA_BUILD_SRC_RPM_OPTIONS' => extra_params['build_src_rpm'],
|
||||
'EXTRA_BUILD_RPM_OPTIONS' => extra_params['build_rpm']
|
||||
}
|
||||
cmd_params.merge!(
|
||||
'RERUN_TESTS' => true,
|
||||
'PACKAGES' => packages.pluck(:sha1).compact * ' '
|
||||
) if rerun_tests?
|
||||
if use_cached_chroot?
|
||||
sha1 = build_for_platform.cached_chroot(arch.name)
|
||||
cmd_params.merge!('CACHED_CHROOT_SHA1' => sha1) if sha1.present?
|
||||
|
|
|
@ -181,6 +181,13 @@
|
|||
data: { confirm: t("layout.publish_again_warning") },
|
||||
name: 'publish',
|
||||
'ng-show' => "build_list.can_publish && build_list.status == #{BuildList::BUILD_PUBLISHED}"
|
||||
- if can? :rerun_tests, @build_list
|
||||
= link_to t('layout.build_lists.rerun_tests'),
|
||||
rerun_tests_build_list_path(@build_list),
|
||||
method: :put,
|
||||
data: { confirm: t("layout.confirm") },
|
||||
class: 'button',
|
||||
'ng-show' => "build_list.status == #{BuildList::TESTS_FAILED} || build_list.status == #{BuildList::SUCCESS}"
|
||||
= submit_tag t("layout.publish"),
|
||||
data: { confirm: t('layout.build_lists.tests_failed') }, 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}"
|
||||
|
|
|
@ -81,6 +81,9 @@ en:
|
|||
cancel: Cancel build
|
||||
will_be_canceled: 'Build will be canceled...'
|
||||
creating: 'creating...'
|
||||
rerun_tests: Rerun tests
|
||||
rerun_tests_success: 'Build is queued for rerun tests'
|
||||
rerun_tests_fail: 'Errors during rerun tests!'
|
||||
create_container_success: 'Container is queued for creating'
|
||||
create_container_fail: 'Errors during container creating!'
|
||||
publish_success: 'Build is queued for publishing'
|
||||
|
@ -143,6 +146,8 @@ en:
|
|||
|
||||
statuses:
|
||||
build_lists: All
|
||||
rerun_tests: Rerun tests
|
||||
reruninng_tests: Build is being rerun tests
|
||||
build_error: Build error
|
||||
build_published: Build has been published
|
||||
tests_failed: Tests failed
|
||||
|
|
|
@ -80,6 +80,9 @@ ru:
|
|||
cancel: Отменить сборку
|
||||
will_be_canceled: 'Сборка будет отменена...'
|
||||
creating: 'создается...'
|
||||
rerun_tests: Перезапустить тесты
|
||||
rerun_tests_success: 'Сборка поставлена в очередь на перезапуск тестов'
|
||||
rerun_tests_fail: 'При перезапуске тестов произошла ошибка!'
|
||||
create_container_success: 'Контейнер поставлен в очередь на создание'
|
||||
create_container_fail: 'При создании контейнера произошла ошибка!'
|
||||
cancel_success: 'Сборка отменена.'
|
||||
|
@ -142,6 +145,8 @@ ru:
|
|||
|
||||
statuses:
|
||||
build_lists: Всего
|
||||
rerun_tests: перезапуск тестов
|
||||
reruninng_tests: тесты перезапускаются
|
||||
build_error: ошибка сборки
|
||||
build_published: опубликован
|
||||
tests_failed: тесты не прошли
|
||||
|
|
|
@ -276,6 +276,7 @@ Rosa::Application.routes.draw do
|
|||
member do
|
||||
put :cancel
|
||||
put :create_container
|
||||
put :rerun_tests
|
||||
get :log
|
||||
patch :publish
|
||||
put :reject_publish
|
||||
|
|
|
@ -18,6 +18,8 @@ module AbfWorker
|
|||
item = find_or_create_item
|
||||
fill_container_data if status != STARTED
|
||||
|
||||
reruninng_tests = subject.reruninng_tests?
|
||||
|
||||
case status
|
||||
when COMPLETED
|
||||
subject.build_success
|
||||
|
@ -28,17 +30,17 @@ module AbfWorker
|
|||
end
|
||||
when FAILED
|
||||
subject.build_error
|
||||
item.update_attributes({status: BuildList::BUILD_ERROR})
|
||||
item.update_attributes({status: BuildList::BUILD_ERROR}) unless reruninng_tests
|
||||
when STARTED
|
||||
subject.start_build
|
||||
when CANCELED
|
||||
subject.build_canceled
|
||||
item.update_attributes({status: BuildList::BUILD_CANCELED})
|
||||
item.update_attributes({status: BuildList::BUILD_CANCELED}) unless reruninng_tests
|
||||
when TESTS_FAILED
|
||||
subject.tests_failed
|
||||
end
|
||||
|
||||
if [TESTS_FAILED, COMPLETED].include?(status)
|
||||
if !reruninng_tests && [TESTS_FAILED, COMPLETED].include?(status)
|
||||
item.update_attributes({status: BuildList::SUCCESS})
|
||||
subject.publish_container if subject.auto_create_container?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue