#418: Added page for creation of builds for dependent projects
This commit is contained in:
parent
88a852b4c8
commit
9afa84e8de
|
@ -7,7 +7,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access']
|
||||
|
||||
before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container]
|
||||
before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container, :dependent_projects]
|
||||
|
||||
load_and_authorize_resource :project, only: [:new, :create]
|
||||
load_resource :project, only: :index, parent: false
|
||||
|
@ -55,18 +55,6 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
def create
|
||||
notices, errors = [], []
|
||||
|
||||
if params[:origin].present?
|
||||
build_list = BuildList.find(params[:origin])
|
||||
if build_list.save_to_platform.personal?
|
||||
raise CanCan::AccessDenied
|
||||
else
|
||||
Resque.enqueue(BuildLists::DependentPackagesJob, build_list.id, current_user.id, params[:project_id])
|
||||
|
||||
flash[:notice] = t('flash.build_list.run_build_lists_job_added_to_queue')
|
||||
redirect_to build_list_path(build_list)
|
||||
end
|
||||
else
|
||||
|
||||
@repository = Repository.find params[:build_list][:save_to_repository_id]
|
||||
@platform = @repository.platform
|
||||
|
||||
|
@ -103,7 +91,6 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
redirect_to project_build_lists_path(@project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@item_groups = @build_list.items.group_by_level
|
||||
|
@ -136,6 +123,35 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
do_and_back(:publish, 'publish_')
|
||||
end
|
||||
|
||||
def dependent_projects
|
||||
raise CanCan::AccessDenied if @build_list.save_to_platform.personal?
|
||||
|
||||
if request.post?
|
||||
prs = params[:build_list]
|
||||
if prs.present? && prs[:projects].present? && prs[:arches].present?
|
||||
project_ids = prs[:projects].select{ |k, v| v == '1' }.keys
|
||||
arch_ids = prs[:arches]. select{ |k, v| v == '1' }.keys
|
||||
|
||||
Resque.enqueue(
|
||||
BuildLists::DependentPackagesJob,
|
||||
@build_list.id,
|
||||
current_user.id,
|
||||
project_ids,
|
||||
arch_ids,
|
||||
{
|
||||
auto_publish_status: prs[:auto_publish_status],
|
||||
auto_create_container: prs[:auto_create_container],
|
||||
include_testing_subrepository: prs[:include_testing_subrepository],
|
||||
use_cached_chroot: prs[:use_cached_chroot],
|
||||
use_extra_tests: prs[:use_extra_tests]
|
||||
}
|
||||
)
|
||||
flash[:notice] = t('flash.build_list.dependent_projects_job_added_to_queue')
|
||||
redirect_to build_list_path(@build_list)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def publish_into_testing
|
||||
@build_list.publisher = current_user
|
||||
do_and_back(:publish_into_testing, 'publish_')
|
||||
|
|
|
@ -2,30 +2,16 @@ module BuildLists
|
|||
class DependentPackagesJob
|
||||
@queue = :middle
|
||||
|
||||
def self.perform(build_list_id, user_id, project_id = nil)
|
||||
def self.perform(build_list_id, user_id, project_ids, arch_ids, options)
|
||||
build_list = BuildList.find(build_list_id)
|
||||
return if build_list.save_to_platform.personal?
|
||||
user = User.find(user_id)
|
||||
ability = Ability.new(user)
|
||||
|
||||
return unless ability.can?(:show, build_list)
|
||||
project = Project.find(project_id) if project_id.present?
|
||||
return if project && !ability.can?(:write, project)
|
||||
|
||||
dependent_packages = build_list.packages.pluck(:dependent_packages).flatten.uniq
|
||||
project_ids = BuildList::Package.
|
||||
joins(:build_list).
|
||||
where(
|
||||
platform_id: build_list.save_to_platform,
|
||||
name: dependent_packages,
|
||||
build_lists: { status: BuildList::BUILD_PUBLISHED }
|
||||
).reorder(nil).uniq.pluck(:project_id)
|
||||
|
||||
return if project && project_ids.exclude?(project.id)
|
||||
|
||||
projects = project ? [project] : Project.where(id: project_ids).to_a
|
||||
|
||||
projects.each do |project|
|
||||
arches = Arch.where(id: arch_ids).to_a
|
||||
Project.where(id: project_ids).to_a.each do |project|
|
||||
next unless ability.can?(:write, project)
|
||||
|
||||
build_for_platform = save_to_platform = build_list.build_for_platform
|
||||
|
@ -35,7 +21,9 @@ module BuildLists
|
|||
project_version = project.project_version_for(save_to_platform, build_for_platform)
|
||||
project.increase_release_tag(project_version, user, "BuildList##{build_list.id}: Increase release tag")
|
||||
|
||||
arches.each do |arch|
|
||||
bl = project.build_lists.build
|
||||
bl.arch = arch
|
||||
bl.save_to_repository = save_to_repository
|
||||
bl.priority = user.build_priority # User builds more priority than mass rebuild with zero priority
|
||||
bl.project_version = project_version
|
||||
|
@ -44,23 +32,26 @@ module BuildLists
|
|||
bl.include_repos |= [save_to_repository.id]
|
||||
%i(
|
||||
build_for_platform
|
||||
arch
|
||||
update_type
|
||||
save_to_platform
|
||||
auto_create_container
|
||||
extra_build_lists
|
||||
extra_params
|
||||
external_nodes
|
||||
include_testing_subrepository
|
||||
auto_publish_status
|
||||
use_cached_chroot
|
||||
use_extra_tests
|
||||
group_id
|
||||
).each { |field| bl.send("#{field}=", build_list.send(field)) }
|
||||
|
||||
%i(
|
||||
auto_publish_status
|
||||
auto_create_container
|
||||
include_testing_subrepository
|
||||
use_cached_chroot
|
||||
use_extra_tests
|
||||
).each { |field| bl.send("#{field}=", options[field]) }
|
||||
|
||||
ability.can?(:create, bl) && bl.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,58 @@
|
|||
-set_meta_tags title: [title_object(@build_list.project), t('activerecord.models.build_list')]
|
||||
|
||||
:javascript
|
||||
$('article .all').addClass('bigpadding');
|
||||
|
||||
= render 'submenu'
|
||||
|
||||
%h3= t('.title')
|
||||
|
||||
= form_for @build_list, url: dependent_projects_build_list_path(@build_list), html: { class: :form, method: :post } do |f|
|
||||
|
||||
%h3= t('.projects')
|
||||
- @build_list.packages.each do |package|
|
||||
- dependent_projects(package).each do |project, packages|
|
||||
.leftlist
|
||||
= link_to project.name_with_owner, project_path(project.name_with_owner)
|
||||
.both
|
||||
%span
|
||||
= t('.packages')
|
||||
%i= packages * ', '
|
||||
|
||||
.rightlist
|
||||
= f.check_box :project_id, name: "build_list[projects][#{project.id}]", checked: true
|
||||
.both
|
||||
|
||||
%h3= t('.architecture')
|
||||
|
||||
- Arch.recent.each do |arch|
|
||||
.leftlist= arch.name
|
||||
.rightlist
|
||||
- arches = @build_list.build_for_platform.platform_arch_settings.by_default.pluck(:arch_id)
|
||||
= f.check_box :arch_id, name: "build_list[arches][#{arch.id}]", checked: arches.include?(arch.id)
|
||||
.both
|
||||
|
||||
%h3= t('.preferences')
|
||||
.leftlist= f.label :auto_publish_status
|
||||
.rightlist= f.select :auto_publish_status, auto_publish_statuses
|
||||
|
||||
.leftlist= f.label :auto_create_container
|
||||
.rightlist= f.check_box :auto_create_container
|
||||
|
||||
.leftlist= f.label :include_testing_subrepository
|
||||
.rightlist= f.check_box :include_testing_subrepository
|
||||
|
||||
.leftlist= f.label :use_cached_chroot
|
||||
.rightlist= f.check_box :use_cached_chroot
|
||||
|
||||
.leftlist= f.label :use_extra_tests
|
||||
.rightlist= f.check_box :use_extra_tests
|
||||
|
||||
.both
|
||||
.hr
|
||||
|
||||
.button_block
|
||||
= submit_tag t('layout.create'),
|
||||
data: {'disable-with' => t('layout.saving'), confirm: t('.are_you_sure') }
|
||||
%span.text_button_padding= t('layout.or')
|
||||
= link_to t('layout.cancel'), build_list_path(@build_list), class: 'button'
|
|
@ -223,12 +223,9 @@
|
|||
- if can? :create, @build_list
|
||||
= link_to t('layout.build_lists.recreate_build_list'), new_project_build_list_path(@build_list.project, build_list_id: @build_list.id), class: 'button'
|
||||
- if can_run_dependent_build_lists?(@build_list)
|
||||
= link_to t('layout.build_lists.run_build_lists'),
|
||||
project_build_lists_path(@build_list.project, origin: @build_list.id),
|
||||
method: :post,
|
||||
class: 'button',
|
||||
data: { confirm: t('layout.build_lists.are_you_sure_to_run_build_lists') }
|
||||
|
||||
= link_to t('projects.build_lists.dependent_projects.title'),
|
||||
dependent_projects_build_list_path(@build_list),
|
||||
class: 'button'
|
||||
|
||||
%div{'ng-show' => "build_list.status == #{BuildList::BUILD_STARTED}"}
|
||||
= render 'shared/log', { build_started: true, get_log_path: log_build_list_path(@build_list) }
|
||||
|
@ -295,12 +292,6 @@
|
|||
%a{'ng-href' => '{{project.new_url}}' }
|
||||
= t('layout.build_lists.create_build_list')
|
||||
.both
|
||||
= link_to t('layout.build_lists.run_build_list'),
|
||||
'',
|
||||
method: :post,
|
||||
data: { confirm: t('layout.build_lists.are_you_sure_to_run_build_lists') },
|
||||
'ng-href' => '{{project.run_url}}'
|
||||
.both
|
||||
|
||||
- if @build_list.new_core?
|
||||
.hr
|
||||
|
|
|
@ -60,7 +60,6 @@ json.build_list do
|
|||
json.name project.name_with_owner
|
||||
json.dependent_packages packages
|
||||
json.new_url new_project_build_list_path(project)
|
||||
json.run_url project_build_lists_path(@build_list.project, origin: @build_list.id, project_id: project.id)
|
||||
end if @build_list.save_to_platform.main?
|
||||
|
||||
end if @build_list.packages.present?
|
||||
|
|
|
@ -64,12 +64,20 @@ en:
|
|||
release: Release
|
||||
version: Version
|
||||
|
||||
projects:
|
||||
build_lists:
|
||||
dependent_projects:
|
||||
title: Create Build Lists of dependent projects
|
||||
projects: Projects
|
||||
packages: "Packages:"
|
||||
architecture: Architecture
|
||||
preferences: Preferences
|
||||
are_you_sure: Are you sure what would like to run build lists? Release tag will be increased automatically.
|
||||
|
||||
layout:
|
||||
build_lists:
|
||||
create_container: Create container
|
||||
create_build_list: Create Build List
|
||||
run_build_list: Run Build List
|
||||
run_build_lists: Run Build Lists of dependent projects
|
||||
are_you_sure_to_run_build_lists: Are you sure what would like to run build lists? Release tag will be increased automatically.
|
||||
platform_deleted: platform has been deleted
|
||||
filter_header: Filter
|
||||
|
@ -214,4 +222,4 @@ en:
|
|||
wrong_include_repos: Include repos have to belongs to build for platform
|
||||
wrong_commit_hash: "Unable find commit '%{commit_hash}' in project"
|
||||
not_all_build_lists_success: 'Project has been builded successfully not for all default arches'
|
||||
run_build_lists_job_added_to_queue: Task for creation of build lists has been added to queue.
|
||||
dependent_projects_job_added_to_queue: Task for creation of build lists has been added to queue.
|
||||
|
|
|
@ -63,13 +63,20 @@ ru:
|
|||
release: Релиз
|
||||
version: Версия
|
||||
|
||||
projects:
|
||||
build_lists:
|
||||
dependent_projects:
|
||||
title: Создать сборку зависимых проектов
|
||||
projects: Проекты
|
||||
packages: "Пакеты:"
|
||||
architecture: Архитектура
|
||||
preferences: Настройки
|
||||
are_you_sure: Вы уверены что хотите запустить сборку? Release тег будет увеличен автоматически.
|
||||
|
||||
layout:
|
||||
build_lists:
|
||||
create_container: Создать контейнер
|
||||
create_build_list: Создать сборку
|
||||
run_build_list: Запустить сборку
|
||||
run_build_lists: Запустить сборку зависимых проектов
|
||||
are_you_sure_to_run_build_lists: Вы уверены что хотите запустить сборку? Release тег будет увеличен автоматически.
|
||||
platform_deleted: платформа была удалена
|
||||
filter_header: Фильтр
|
||||
current: Текущие
|
||||
|
@ -214,4 +221,4 @@ ru:
|
|||
wrong_include_repos: Включаемые репозитории должны принадлежать платформе для сборки
|
||||
wrong_commit_hash: "Невозможно найти коммит '%{commit_hash}' в проекте"
|
||||
not_all_build_lists_success: Проект собран успешно не для всех дефолтных архитектур
|
||||
run_build_lists_job_added_to_queue: Задача на создание билд листов добавлена в очередь.
|
||||
dependent_projects_job_added_to_queue: Задача на создание билд листов добавлена в очередь.
|
||||
|
|
|
@ -284,6 +284,8 @@ Rosa::Application.routes.draw do
|
|||
put :reject_publish
|
||||
put :publish_into_testing
|
||||
put :update_type
|
||||
get :dependent_projects
|
||||
post :dependent_projects
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue