Merge pull request #410 from abf/rosa-build:405-smart-build-scenarios-2
#405: Smart build scenarios 2
This commit is contained in:
commit
94605f5ace
|
@ -1182,11 +1182,12 @@ div#advisory_search_block div.continue_input {
|
|||
form.mass_build {
|
||||
section.left {
|
||||
margin-left: 10px;
|
||||
width: 350px;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
section.right {
|
||||
margin-right: 50px;
|
||||
width: 300px;
|
||||
}
|
||||
input[type="submit"] {
|
||||
margin: 10px 0 10px 0;
|
||||
|
|
|
@ -14,6 +14,17 @@ class AutocompletesController < ApplicationController
|
|||
render json: results.to_json
|
||||
end
|
||||
|
||||
def autocomplete_extra_mass_build
|
||||
mb = MassBuild.where(id: params[:term]).first
|
||||
results << {
|
||||
id: mb.id,
|
||||
value: mb.id,
|
||||
label: "#{mb.id} - #{mb.name}",
|
||||
path: platform_mass_build_path(mb.save_to_platform, mb)
|
||||
} if mb && can?(:show, mb)
|
||||
render json: results.to_json
|
||||
end
|
||||
|
||||
def autocomplete_extra_repositories
|
||||
# Only personal and build for platform repositories can be attached to the build
|
||||
Platform.includes(:repositories).search(params[:term]).search_order
|
||||
|
|
|
@ -32,10 +32,11 @@ class BuildList < ActiveRecord::Base
|
|||
EXTRA_PARAMS = %w[cfg_options cfg_urpm_options build_src_rpm build_rpm]
|
||||
EXTERNAL_NODES = %w[owned everything]
|
||||
|
||||
AUTO_PUBLISH_STATUS_NONE = 'none'
|
||||
AUTO_PUBLISH_STATUS_DEFAULT = 'default'
|
||||
AUTO_PUBLISH_STATUS_TESTING = 'testing'
|
||||
AUTO_PUBLISH_STATUSES = [AUTO_PUBLISH_STATUS_NONE, AUTO_PUBLISH_STATUS_DEFAULT, AUTO_PUBLISH_STATUS_TESTING]
|
||||
AUTO_PUBLISH_STATUSES = [
|
||||
AUTO_PUBLISH_STATUS_NONE = 'none',
|
||||
AUTO_PUBLISH_STATUS_DEFAULT = 'default',
|
||||
AUTO_PUBLISH_STATUS_TESTING = 'testing'
|
||||
]
|
||||
|
||||
validates :project_id,
|
||||
:project_version,
|
||||
|
@ -688,6 +689,11 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def prepare_extra_build_lists
|
||||
if mass_build && mass_build.extra_mass_builds.present?
|
||||
extra_build_lists ||= []
|
||||
extra_build_lists << BuildList.where(mass_build_id: mass_build.extra_mass_builds, arch_id: arch_id).pluck(:id)
|
||||
extra_build_lists.flatten!
|
||||
end
|
||||
return if extra_build_lists.blank?
|
||||
bls = BuildList.for_extra_build_lists(extra_build_lists, current_ability, save_to_platform)
|
||||
if save_to_platform
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class MassBuild < ActiveRecord::Base
|
||||
|
||||
AUTO_PUBLISH_STATUSES = %w(none default testing)
|
||||
|
||||
belongs_to :build_for_platform, -> { where(platform_type: 'main') }, class_name: 'Platform'
|
||||
belongs_to :save_to_platform, class_name: 'Platform'
|
||||
belongs_to :user
|
||||
|
@ -6,16 +9,17 @@ class MassBuild < ActiveRecord::Base
|
|||
|
||||
serialize :extra_repositories, Array
|
||||
serialize :extra_build_lists, Array
|
||||
serialize :extra_mass_builds, Array
|
||||
|
||||
scope :recent, -> { order(created_at: :desc) }
|
||||
scope :by_platform, -> (platform) { where(save_to_platform_id: platform.id) }
|
||||
scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) }
|
||||
scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? }
|
||||
scope :recent, -> { order(created_at: :desc) }
|
||||
scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) }
|
||||
scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? }
|
||||
|
||||
attr_accessor :arches
|
||||
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
|
||||
attr_accessible :arches, :auto_publish_status, :projects_list, :build_for_platform_id,
|
||||
:extra_repositories, :extra_build_lists, :increase_release_tag,
|
||||
:use_cached_chroot, :use_extra_tests, :description
|
||||
:use_cached_chroot, :use_extra_tests, :description, :extra_mass_builds,
|
||||
:include_testing_subrepository
|
||||
|
||||
validates :save_to_platform_id,
|
||||
:build_for_platform_id,
|
||||
|
@ -31,8 +35,10 @@ class MassBuild < ActiveRecord::Base
|
|||
validates :description,
|
||||
length: { maximum: 255 }
|
||||
|
||||
validates :auto_publish,
|
||||
:increase_release_tag,
|
||||
validates :auto_publish_status,
|
||||
inclusion: { in: AUTO_PUBLISH_STATUSES }
|
||||
|
||||
validates :increase_release_tag,
|
||||
:use_cached_chroot,
|
||||
:use_extra_tests,
|
||||
inclusion: { in: [true, false] }
|
||||
|
|
|
@ -182,21 +182,22 @@ class Project < ActiveRecord::Base
|
|||
increase_release_tag(project_version, user, "MassBuild##{mass_build.id}: Increase release tag") if increase_rt
|
||||
|
||||
build_list = build_lists.build do |bl|
|
||||
bl.save_to_platform = save_to_platform
|
||||
bl.build_for_platform = build_for_platform
|
||||
bl.update_type = 'newpackage'
|
||||
bl.arch = arch
|
||||
bl.project_version = project_version
|
||||
bl.user = user
|
||||
bl.auto_publish_status = mass_build.auto_publish? ? BuildList::AUTO_PUBLISH_STATUS_DEFAULT : BuildList::AUTO_PUBLISH_STATUS_NONE
|
||||
bl.include_repos = include_repos
|
||||
bl.extra_repositories = mass_build.extra_repositories
|
||||
bl.extra_build_lists = mass_build.extra_build_lists
|
||||
bl.priority = priority
|
||||
bl.mass_build_id = mass_build.id
|
||||
bl.save_to_repository_id = repository_id
|
||||
bl.use_cached_chroot = mass_build.use_cached_chroot?
|
||||
bl.use_extra_tests = mass_build.use_extra_tests?
|
||||
bl.save_to_platform = save_to_platform
|
||||
bl.build_for_platform = build_for_platform
|
||||
bl.update_type = 'newpackage'
|
||||
bl.arch = arch
|
||||
bl.project_version = project_version
|
||||
bl.user = user
|
||||
bl.auto_publish_status = mass_build.auto_publish_status
|
||||
bl.include_repos = include_repos
|
||||
bl.extra_repositories = mass_build.extra_repositories
|
||||
bl.extra_build_lists = mass_build.extra_build_lists
|
||||
bl.priority = priority
|
||||
bl.mass_build_id = mass_build.id
|
||||
bl.save_to_repository_id = repository_id
|
||||
bl.include_testing_subrepository = mass_build.include_testing_subrepository?
|
||||
bl.use_cached_chroot = mass_build.use_cached_chroot?
|
||||
bl.use_extra_tests = mass_build.use_extra_tests?
|
||||
end
|
||||
build_list.save
|
||||
end
|
||||
|
|
|
@ -60,5 +60,24 @@ module AbfWorkerService
|
|||
end
|
||||
end
|
||||
|
||||
def filter_build_lists_without_packages(*build_lists)
|
||||
ids = []
|
||||
build_lists = build_lists.flatten.select do |build_list|
|
||||
sha1 = build_list.packages.pluck(:sha1).find do |sha1|
|
||||
!FileStoreService::File.new(sha1: sha1).exist?
|
||||
end
|
||||
if sha1.present?
|
||||
ids << build_list.id
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL)
|
||||
|
||||
build_lists
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -9,6 +9,12 @@ module AbfWorkerService
|
|||
|
||||
def create!
|
||||
cleanup_folder
|
||||
|
||||
if filter_build_lists_without_packages(build_list).blank?
|
||||
build_list.fail_publish_container
|
||||
return
|
||||
end
|
||||
|
||||
Resque.push(
|
||||
'publish_worker', # Low priority
|
||||
'class' => 'AbfWorker::PublishWorker',
|
||||
|
|
|
@ -237,24 +237,5 @@ module AbfWorkerService
|
|||
end
|
||||
end
|
||||
|
||||
def filter_build_lists_without_packages(build_lists)
|
||||
ids = []
|
||||
build_lists = build_lists.select do |build_list|
|
||||
sha1 = build_list.packages.pluck(:sha1).find do |sha1|
|
||||
!FileStoreService::File.new(sha1: sha1).exist?
|
||||
end
|
||||
if sha1.present?
|
||||
ids << build_list.id
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL)
|
||||
|
||||
build_lists
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -36,6 +36,12 @@
|
|||
placeholder: 'uxteam_personal',
|
||||
subject: @mass_build,
|
||||
autocomplete_path: autocomplete_extra_repositories_autocompletes_path
|
||||
= render 'shared/autocomplete_form',
|
||||
field: :extra_mass_builds,
|
||||
field_class: MassBuild,
|
||||
placeholder: '1000000',
|
||||
subject: @mass_build,
|
||||
autocomplete_path: autocomplete_extra_mass_build_autocompletes_path
|
||||
= render 'shared/autocomplete_form',
|
||||
field: :extra_build_lists,
|
||||
field_class: BuildList,
|
||||
|
@ -43,7 +49,10 @@
|
|||
subject: @mass_build,
|
||||
autocomplete_path: autocomplete_extra_build_list_autocompletes_path
|
||||
%h3= t("activerecord.attributes.build_list.preferences")
|
||||
- %i(auto_publish increase_release_tag use_cached_chroot use_extra_tests).each do |field|
|
||||
.both
|
||||
= f.select :auto_publish_status, auto_publish_statuses
|
||||
= f.label :auto_publish_status
|
||||
- %i(increase_release_tag include_testing_subrepository use_cached_chroot use_extra_tests).each do |field|
|
||||
.both
|
||||
= f.check_box field
|
||||
= f.label field
|
||||
|
|
|
@ -10,12 +10,79 @@
|
|||
%td
|
||||
%b= t('activerecord.attributes.mass_build.name')
|
||||
%td= link_to_mass_build(@mass_build)
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.id')
|
||||
%td= @mass_build.id
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.arch_names')
|
||||
%td= @mass_build.arch_names
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.build_for_platform')
|
||||
%td= link_to @mass_build.build_for_platform.name, platform_path(@mass_build.build_for_platform)
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.auto_publish_status')
|
||||
%td= t("layout.build_lists.auto_publish_status.#{@mass_build.auto_publish_status}")
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.increase_release_tag')
|
||||
%td= t("layout.#{@mass_build.increase_release_tag?}_")
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.include_testing_subrepository')
|
||||
%td= t("layout.#{@mass_build.include_testing_subrepository?}_")
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.use_cached_chroot')
|
||||
%td= t("layout.#{@mass_build.use_cached_chroot?}_")
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.use_extra_tests')
|
||||
%td= t("layout.#{@mass_build.use_extra_tests?}_")
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.created_at')
|
||||
%td= @mass_build.created_at
|
||||
%tr
|
||||
%td
|
||||
%b= t('activerecord.attributes.mass_build.description')
|
||||
%td= @mass_build.description
|
||||
|
||||
- %i(id arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at description).each do |field|
|
||||
%tr
|
||||
%td
|
||||
%b= t("activerecord.attributes.mass_build.#{field}")
|
||||
%td= @mass_build.send field
|
||||
%tr
|
||||
%td
|
||||
%b= t("activerecord.attributes.build_list.extra_repositories")
|
||||
%td
|
||||
- if @mass_build.extra_repositories.present?
|
||||
- Repository.where(id: @mass_build.extra_repositories).each do |repo|
|
||||
%p= link_to "#{repo.platform.name}/#{repo.name}", [repo.platform, repo]
|
||||
.both
|
||||
- else
|
||||
= t('layout.false_')
|
||||
|
||||
%tr
|
||||
%td
|
||||
%b= t("activerecord.attributes.build_list.extra_mass_builds")
|
||||
%td
|
||||
- if @mass_build.extra_mass_builds.present?
|
||||
- MassBuild.where(id: @mass_build.extra_mass_builds).each do |mb|
|
||||
%p= link_to "#{mb.id} - #{mb.name}", platform_mass_build_path(mb.save_to_platform, mb)
|
||||
.both
|
||||
- else
|
||||
= t('layout.false_')
|
||||
|
||||
%tr
|
||||
%td
|
||||
%b= t("activerecord.attributes.build_list.extra_build_lists")
|
||||
%td
|
||||
- if @mass_build.extra_build_lists.present?
|
||||
- BuildList.where(id: @mass_build.extra_build_lists).each do |bl|
|
||||
%p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl
|
||||
.both
|
||||
- else
|
||||
= t('layout.false_')
|
||||
|
||||
%tr
|
||||
%td
|
||||
|
@ -49,7 +116,7 @@
|
|||
|
||||
.buttons_block
|
||||
- if can?(:publish, @mass_build)
|
||||
- unless @mass_build.auto_publish?
|
||||
- unless @mass_build.auto_publish_status == BuildList::AUTO_PUBLISH_STATUS_DEFAULT
|
||||
= link_to t('layout.mass_builds.publish_success'),
|
||||
publish_platform_mass_build_path(@platform, @mass_build.id),
|
||||
method: :post, data: { confirm: t("layout.confirm") }, class: 'button'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
:markdown
|
||||
|
||||
__Ability to attach at assembly packages of mass builds as additional sources of packages.__
|
|
@ -0,0 +1,3 @@
|
|||
:markdown
|
||||
|
||||
__Возможность подключить для сборки пакеты из массовой сборки как дополнительные источники пакетов.__
|
|
@ -9,6 +9,7 @@ en:
|
|||
name: Name
|
||||
extra_repositories: Extra repositories
|
||||
extra_build_lists: Extra build lists
|
||||
extra_mass_builds: Extra mass builds
|
||||
auto_create_container: Create container automatically
|
||||
use_cached_chroot: Use cached chroot
|
||||
use_extra_tests: Use extra tests
|
||||
|
|
|
@ -9,6 +9,7 @@ ru:
|
|||
name: Название
|
||||
extra_repositories: Дополнительные репозитории
|
||||
extra_build_lists: Дополнительные сборки
|
||||
extra_mass_builds: Дополнительные массовые сборки
|
||||
auto_create_container: Создать контейнер автоматически
|
||||
use_cached_chroot: Использовать кэшированный chroot
|
||||
use_extra_tests: Использовать дополнительные тесты
|
||||
|
|
|
@ -31,9 +31,11 @@ en:
|
|||
updated_at: Updated
|
||||
arch_names: Architectures
|
||||
user: User
|
||||
auto_publish: Automated publishing
|
||||
auto_publish_status: Automated publishing
|
||||
increase_release_tag: Increase release tag
|
||||
use_cached_chroot: Use cached chroot
|
||||
use_extra_tests: Use extra tests
|
||||
include_testing_subrepository: "Include 'testing' subrepository"
|
||||
repositories: Repositories
|
||||
projects_list: Projects list
|
||||
build_for_platform: Build for platform
|
||||
|
|
|
@ -32,9 +32,11 @@ ru:
|
|||
updated_at: Обновлен
|
||||
arch_names: Архитектуры
|
||||
user: Пользователь
|
||||
auto_publish: Автоматическая публикация
|
||||
auto_publish_status: Автоматическая публикация
|
||||
increase_release_tag: Увеличить release тег
|
||||
use_cached_chroot: Использовать кэшированный chroot
|
||||
use_extra_tests: Использовать дополнительные тесты
|
||||
include_testing_subrepository: "Подключить 'testing' подрепозиторий"
|
||||
repositories: Репозитории
|
||||
projects_list: Список проектов
|
||||
build_for_platform: Собрано для платформы
|
||||
|
|
|
@ -230,6 +230,7 @@ Rosa::Application.routes.draw do
|
|||
get :autocomplete_user_uname
|
||||
get :autocomplete_group_uname
|
||||
get :autocomplete_extra_build_list
|
||||
get :autocomplete_extra_mass_build
|
||||
get :autocomplete_extra_repositories
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
class AddAutoPublishStatusToMassBuilds < ActiveRecord::Migration
|
||||
class MassBuild < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :mass_builds, :auto_publish_status, :string, default: 'none', null: false
|
||||
MassBuild.where(auto_publish: true).update_all(auto_publish_status: :default)
|
||||
remove_column :mass_builds, :auto_publish
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :mass_builds, :auto_publish, :boolean, default: false
|
||||
MassBuild.where(auto_publish_status: :default).update_all(auto_publish: true)
|
||||
remove_column :mass_builds, :auto_publish_status
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddExtraMassBuildsToMassBuilds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :extra_mass_builds, :text
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddIncludeTestingSubrepositoryToMassBuilds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :include_testing_subrepository, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
28
db/schema.rb
28
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140626195741) do
|
||||
ActiveRecord::Schema.define(version: 20140630205045) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -308,26 +308,28 @@ ActiveRecord::Schema.define(version: 20140626195741) do
|
|||
end
|
||||
|
||||
create_table "mass_builds", force: true do |t|
|
||||
t.integer "build_for_platform_id", null: false
|
||||
t.integer "build_for_platform_id", null: false
|
||||
t.string "name"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "arch_names"
|
||||
t.integer "user_id"
|
||||
t.boolean "auto_publish", default: false, null: false
|
||||
t.integer "build_lists_count", default: 0, null: false
|
||||
t.boolean "stop_build", default: false, null: false
|
||||
t.integer "build_lists_count", default: 0, null: false
|
||||
t.boolean "stop_build", default: false, null: false
|
||||
t.text "projects_list"
|
||||
t.integer "missed_projects_count", default: 0, null: false
|
||||
t.integer "missed_projects_count", default: 0, null: false
|
||||
t.text "missed_projects_list"
|
||||
t.boolean "new_core", default: true
|
||||
t.integer "save_to_platform_id", null: false
|
||||
t.boolean "new_core", default: true
|
||||
t.integer "save_to_platform_id", null: false
|
||||
t.text "extra_repositories"
|
||||
t.text "extra_build_lists"
|
||||
t.boolean "increase_release_tag", default: false, null: false
|
||||
t.boolean "use_cached_chroot", default: true, null: false
|
||||
t.boolean "use_extra_tests", default: false, null: false
|
||||
t.boolean "increase_release_tag", default: false, null: false
|
||||
t.boolean "use_cached_chroot", default: true, null: false
|
||||
t.boolean "use_extra_tests", default: false, null: false
|
||||
t.string "description"
|
||||
t.string "auto_publish_status", default: "none", null: false
|
||||
t.text "extra_mass_builds"
|
||||
t.boolean "include_testing_subrepository", default: false, null: false
|
||||
end
|
||||
|
||||
create_table "users", force: true do |t|
|
||||
|
|
|
@ -130,7 +130,6 @@ describe Platforms::MassBuildsController do
|
|||
@create_params = {
|
||||
mass_build: {
|
||||
:projects_list => @repository.projects.map(&:name).join("\n"),
|
||||
:auto_publish => true,
|
||||
:build_for_platform_id => @platform
|
||||
},
|
||||
:platform_id => @platform,
|
||||
|
|
|
@ -4,7 +4,6 @@ FactoryGirl.define do
|
|||
association :user
|
||||
projects_list "first"
|
||||
arches { [ Arch.where(name: 'x86_64').first_or_create.id ] }
|
||||
auto_publish true
|
||||
stop_build false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,10 +12,18 @@ describe AbfWorkerService::Container do
|
|||
context '#create!' do
|
||||
|
||||
it 'creates task' do
|
||||
expect(build_list).to_not receive(:fail_publish_container)
|
||||
expect(Resque).to receive(:push)
|
||||
subject.create!
|
||||
end
|
||||
|
||||
it 'fails when no packages on FS' do
|
||||
expect(subject).to receive(:filter_build_lists_without_packages).and_return([])
|
||||
expect(build_list).to receive(:fail_publish_container)
|
||||
expect(Resque).to_not receive(:push)
|
||||
subject.create!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue