diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb
index 3af59ae1f..433e20732 100644
--- a/app/controllers/projects/build_lists_controller.rb
+++ b/app/controllers/projects/build_lists_controller.rb
@@ -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,53 +55,40 @@ 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])
+ @repository = Repository.find params[:build_list][:save_to_repository_id]
+ @platform = @repository.platform
- flash[:notice] = t('flash.build_list.run_build_lists_job_added_to_queue')
- redirect_to build_list_path(build_list)
- end
- else
+ params[:build_list][:save_to_platform_id] = @platform.id
- @repository = Repository.find params[:build_list][:save_to_repository_id]
- @platform = @repository.platform
+ build_for_platforms = Repository.select(:platform_id).
+ where(id: params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
- params[:build_list][:save_to_platform_id] = @platform.id
+ build_lists = []
+ Arch.where(id: params[:arches]).each do |arch|
+ Platform.main.where(id: build_for_platforms).each do |build_for_platform|
+ @build_list = @project.build_lists.build(params[:build_list])
+ @build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user
+ @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i}
+ @build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
- build_for_platforms = Repository.select(:platform_id).
- where(id: params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
-
- build_lists = []
- Arch.where(id: params[:arches]).each do |arch|
- Platform.main.where(id: build_for_platforms).each do |build_for_platform|
- @build_list = @project.build_lists.build(params[:build_list])
- @build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user
- @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i}
- @build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
-
- flash_options = {project_version: @build_list.project_version, arch: arch.name, build_for_platform: build_for_platform.name}
- if authorize!(:create, @build_list) && @build_list.save
- build_lists << @build_list
- notices << t("flash.build_list.saved", flash_options)
- else
- errors << t("flash.build_list.save_error", flash_options)
- end
+ flash_options = {project_version: @build_list.project_version, arch: arch.name, build_for_platform: build_for_platform.name}
+ if authorize!(:create, @build_list) && @build_list.save
+ build_lists << @build_list
+ notices << t("flash.build_list.saved", flash_options)
+ else
+ errors << t("flash.build_list.save_error", flash_options)
end
end
- errors << t("flash.build_list.no_arch_or_platform_selected") if errors.blank? and notices.blank?
- if errors.present?
- @build_list ||= BuildList.new
- flash[:error] = errors.join('
').html_safe
- render action: :new
- else
- BuildList.where(id: build_lists.map(&:id)).update_all(group_id: build_lists[0].id) if build_lists.size > 1
- flash[:notice] = notices.join('
').html_safe
- redirect_to project_build_lists_path(@project)
- end
+ end
+ errors << t("flash.build_list.no_arch_or_platform_selected") if errors.blank? and notices.blank?
+ if errors.present?
+ @build_list ||= BuildList.new
+ flash[:error] = errors.join('
').html_safe
+ render action: :new
+ else
+ BuildList.where(id: build_lists.map(&:id)).update_all(group_id: build_lists[0].id) if build_lists.size > 1
+ flash[:notice] = notices.join('
').html_safe
+ redirect_to project_build_lists_path(@project)
end
end
@@ -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_')
diff --git a/app/jobs/build_lists/dependent_packages_job.rb b/app/jobs/build_lists/dependent_packages_job.rb
index 5c6aa34ec..a8cb8654a 100644
--- a/app/jobs/build_lists/dependent_packages_job.rb
+++ b/app/jobs/build_lists/dependent_packages_job.rb
@@ -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,30 +21,35 @@ 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")
- bl = project.build_lists.build
- 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
- bl.user = user
- bl.include_repos = [build_for_platform.repositories.main.first.try(:id)].compact
- 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)) }
+ 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
+ bl.user = user
+ bl.include_repos = [build_for_platform.repositories.main.first.try(:id)].compact
+ bl.include_repos |= [save_to_repository.id]
+ %i(
+ build_for_platform
+ update_type
+ save_to_platform
+ extra_build_lists
+ extra_params
+ external_nodes
+ group_id
+ ).each { |field| bl.send("#{field}=", build_list.send(field)) }
- ability.can?(:create, bl) && bl.save
+ %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
diff --git a/app/views/projects/build_lists/dependent_projects.html.haml b/app/views/projects/build_lists/dependent_projects.html.haml
new file mode 100644
index 000000000..e593bc5b4
--- /dev/null
+++ b/app/views/projects/build_lists/dependent_projects.html.haml
@@ -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'
diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml
index 497fe710b..e5cf8fe33 100644
--- a/app/views/projects/build_lists/show.html.haml
+++ b/app/views/projects/build_lists/show.html.haml
@@ -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) }
@@ -294,12 +291,6 @@
%td{ colspan: 3 }
%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?
diff --git a/app/views/projects/build_lists/show.json.jbuilder b/app/views/projects/build_lists/show.json.jbuilder
index 1c9ee4acc..26bec88eb 100644
--- a/app/views/projects/build_lists/show.json.jbuilder
+++ b/app/views/projects/build_lists/show.json.jbuilder
@@ -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?
diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml
index 978c94c89..477e99efd 100644
--- a/config/locales/models/build_list.en.yml
+++ b/config/locales/models/build_list.en.yml
@@ -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.
diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml
index 48a74d3b1..0120ad3aa 100644
--- a/config/locales/models/build_list.ru.yml
+++ b/config/locales/models/build_list.ru.yml
@@ -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: Задача на создание билд листов добавлена в очередь.
diff --git a/config/routes.rb b/config/routes.rb
index 7e1082caa..3337ee9b1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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