#373: added use_cached_chroot field to MassBuild

This commit is contained in:
Vokhmin Alexey V 2014-05-12 23:55:13 +04:00
parent b90aa0f50e
commit 44cbfe6191
9 changed files with 52 additions and 24 deletions

View File

@ -8,30 +8,42 @@ class MassBuild < ActiveRecord::Base
serialize :extra_build_lists, Array
scope :recent, -> { order(created_at: :desc) }
scope :by_platform, ->(platform) { where(save_to_platform_id: platform.id) }
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) }
attr_accessor :arches
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
:extra_repositories, :extra_build_lists, :increase_release_tag
:extra_repositories, :extra_build_lists, :increase_release_tag,
:use_cached_chroot
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, presence: true
validates :projects_list, length: {maximum: 500_000}, presence: true
validates_inclusion_of :auto_publish, :increase_release_tag, in: [true, false]
validates :save_to_platform_id,
:build_for_platform_id,
:arch_names,
:name,
:user_id, presence: true
validates :projects_list,
presence: true,
length: { maximum: 500_000 }
validates :auto_publish,
:increase_release_tag,
:use_cached_chroot,
inclusion: { in: [true, false] }
after_commit :build_all, on: :create
before_validation :set_data, on: :create
COUNT_STATUSES = [
:build_lists,
:build_published,
:build_pending,
:build_started,
:build_publish,
:build_error,
:success,
:build_canceled
]
COUNT_STATUSES = %i(
build_lists
build_published
build_pending
build_started
build_publish
build_error
success
build_canceled
)
def build_all
# later with resque
@ -47,7 +59,7 @@ class MassBuild < ActiveRecord::Base
increase_rt = increase_release_tag?
arches_list.each do |arch|
rep_id = (project.repository_ids & save_to_platform.repository_ids).first
project.build_for self, rep_id, arch, 0, increase_rt
project.build_for(self, rep_id, arch, 0, increase_rt, use_cached_chroot)
increase_rt = false
end
rescue RuntimeError, Exception

View File

@ -166,7 +166,7 @@ class Project < ActiveRecord::Base
#path #share by NFS
end
def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false)
def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false, use_cached_chroot = false)
build_for_platform = mass_build.build_for_platform
save_to_platform = mass_build.save_to_platform
user = mass_build.user
@ -194,6 +194,7 @@ class Project < ActiveRecord::Base
bl.priority = priority
bl.mass_build_id = mass_build.id
bl.save_to_repository_id = repository_id
bl.use_cached_chroot = use_cached_chroot
end
build_list.save
end

View File

@ -53,7 +53,7 @@
.toggle{id: "toggle_#{ mass_build.id }"}
= t('activerecord.attributes.mass_build.user') + ": "
= link_to mass_build.user.fullname, mass_build.user
- [:arch_names, :auto_publish, :increase_release_tag, :created_at].each do |field|
- %i(arch_names auto_publish increase_release_tag use_cached_chroot created_at).each do |field|
.both
= t("activerecord.attributes.mass_build.#{field}") + ": "
= mass_build.send field

View File

@ -40,7 +40,7 @@
subject: @mass_build,
autocomplete_path: autocomplete_extra_build_list_autocompletes_path
%h3= t("activerecord.attributes.build_list.preferences")
- [:auto_publish, :increase_release_tag].each do |field|
- %i(auto_publish increase_release_tag use_cached_chroot).each do |field|
.both
= f.check_box field
= f.label field

View File

@ -27,5 +27,6 @@ en:
user: User
auto_publish: Automated publishing
increase_release_tag: Increase release tag
use_cached_chroot: Use cached chroot
repositories: Repositories
projects_list: Projects list

View File

@ -27,5 +27,6 @@ ru:
user: Пользователь
auto_publish: Автоматическая публикация
increase_release_tag: Увеличить release тег
use_cached_chroot: Использовать кэшированный chroot
repositories: Репозитории
projects_list: Список проектов

View File

@ -1,5 +1,5 @@
class AddUseCachedChrootToBuildList < ActiveRecord::Migration
def change
def up
# Make existing build_lists 'false', but default to 'true' in the future.
add_column :build_lists, :use_cached_chroot, :boolean, null: false, default: false
change_column :build_lists, :use_cached_chroot, :boolean, null: false, default: true

View File

@ -0,0 +1,12 @@
class AddUseCachedChrootToMassBuild < ActiveRecord::Migration
def up
# Make existing mass_builds 'false', but default to 'true' in the future.
add_column :mass_builds, :use_cached_chroot, :boolean, null: false, default: false
change_column :mass_builds, :use_cached_chroot, :boolean, null: false, default: true
end
def down
remove_column :mass_builds, :use_cached_chroot
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140512091135) do
ActiveRecord::Schema.define(version: 20140512183926) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -323,6 +323,7 @@ ActiveRecord::Schema.define(version: 20140512091135) do
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
end
create_table "users", force: true do |t|