From 0c5e8c012c497019f2b5fcdf35a8478641f83b34 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Sat, 24 May 2014 00:29:24 +0400 Subject: [PATCH] #392: added use_extra_tests field to BuildList, MassBuild --- app/controllers/projects/build_lists_controller.rb | 9 ++++++--- app/models/build_list.rb | 3 ++- app/models/mass_build.rb | 5 +++-- app/models/project.rb | 5 +++-- app/views/api/v1/build_lists/show.json.jbuilder | 2 +- app/views/platforms/mass_builds/index.html.haml | 2 +- app/views/platforms/mass_builds/new.html.haml | 2 +- app/views/projects/build_lists/_new_form.html.haml | 2 +- app/views/projects/build_lists/show.html.haml | 3 +++ config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + config/locales/models/mass_build.en.yml | 1 + config/locales/models/mass_build.ru.yml | 1 + ...se_extra_tests_to_build_lists_and_mass_builds.rb | 13 +++++++++++++ db/schema.rb | 4 +++- 15 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20140523192643_add_use_extra_tests_to_build_lists_and_mass_builds.rb diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 216ca58ba..e82e76b29 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -199,9 +199,12 @@ class Projects::BuildListsController < Projects::BaseController build_list = @project.build_lists.find(params[:build_list_id]) params[:build_list] ||= {} - keys = [:save_to_repository_id, :auto_publish_status, :include_repos, :extra_params, - :project_version, :update_type, :auto_create_container, - :extra_repositories, :extra_build_lists, :build_for_platform_id, :use_cached_chroot] + keys = [ + :save_to_repository_id, :auto_publish_status, :include_repos, + :extra_params, :project_version, :update_type, :auto_create_container, + :extra_repositories, :extra_build_lists, :build_for_platform_id, + :use_cached_chroot, :use_extra_tests + ] keys.each { |key| params[:build_list][key] = build_list.send(key) } params[:arches] = [build_list.arch_id.to_s] [:owner_filter, :status_filter].each { |t| params[t] = 'true' if %w(true undefined).exclude? params[t] } diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 432cd38ce..3082851a7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -71,7 +71,7 @@ class BuildList < ActiveRecord::Base :save_to_platform_id, :project_version, :auto_create_container, :extra_repositories, :extra_build_lists, :extra_params, :external_nodes, :include_testing_subrepository, :auto_publish_status, - :use_cached_chroot + :use_cached_chroot, :use_extra_tests LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -531,6 +531,7 @@ class BuildList < ActiveRecord::Base cmd_params = { 'GIT_PROJECT_ADDRESS' => git_project_address, 'COMMIT_HASH' => commit_hash, + 'USE_EXTRA_TESTS' => use_extra_tests?, 'EXTRA_CFG_OPTIONS' => extra_params['cfg_options'], 'EXTRA_CFG_URPM_OPTIONS' => extra_params['cfg_urpm_options'], 'EXTRA_BUILD_SRC_RPM_OPTIONS' => extra_params['build_src_rpm'], diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 279beba84..096ccb748 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -14,7 +14,7 @@ class MassBuild < ActiveRecord::Base attr_accessor :arches attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id, :extra_repositories, :extra_build_lists, :increase_release_tag, - :use_cached_chroot + :use_cached_chroot, :use_extra_tests validates :save_to_platform_id, :build_for_platform_id, @@ -30,6 +30,7 @@ class MassBuild < ActiveRecord::Base validates :auto_publish, :increase_release_tag, :use_cached_chroot, + :use_extra_tests, inclusion: { in: [true, false] } after_commit :build_all, on: :create @@ -60,7 +61,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, use_cached_chroot) + project.build_for(self, rep_id, arch, 0, increase_rt) increase_rt = false end rescue RuntimeError, Exception diff --git a/app/models/project.rb b/app/models/project.rb index 0d95ad6e4..0eef27df0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -167,7 +167,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, use_cached_chroot = false) + def build_for(mass_build, repository_id, arch = Arch.find_by(name: 'i586'), priority = 0, increase_rt = false) build_for_platform = mass_build.build_for_platform save_to_platform = mass_build.save_to_platform user = mass_build.user @@ -195,7 +195,8 @@ 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 + bl.use_cached_chroot = mass_build.use_cached_chroot + bl.use_extra_tests = mass_build.use_extra_tests end build_list.save end diff --git a/app/views/api/v1/build_lists/show.json.jbuilder b/app/views/api/v1/build_lists/show.json.jbuilder index 0d8d119c3..794f92e0f 100644 --- a/app/views/api/v1/build_lists/show.json.jbuilder +++ b/app/views/api/v1/build_lists/show.json.jbuilder @@ -2,7 +2,7 @@ json.build_list do json.(@build_list, :id, :container_status, :status, :duration) json.(@build_list, :update_type, :priority, :new_core) json.(@build_list, :advisory, :mass_build) - json.(@build_list, :auto_publish_status, :package_version, :commit_hash, :last_published_commit_hash, :auto_create_container, :use_cached_chroot) + json.(@build_list, :auto_publish_status, :package_version, :commit_hash, :last_published_commit_hash, :auto_create_container, :use_cached_chroot, :use_extra_tests) json.build_log_url log_build_list_path(@build_list) if @build_list.container_published? diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 46f62e70b..3644856d7 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -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 - - %i(arch_names auto_publish increase_release_tag use_cached_chroot created_at).each do |field| + - %i(arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at).each do |field| .both = t("activerecord.attributes.mass_build.#{field}") + ": " = mass_build.send field diff --git a/app/views/platforms/mass_builds/new.html.haml b/app/views/platforms/mass_builds/new.html.haml index aea876e77..bf8b62bed 100644 --- a/app/views/platforms/mass_builds/new.html.haml +++ b/app/views/platforms/mass_builds/new.html.haml @@ -40,7 +40,7 @@ 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).each do |field| + - %i(auto_publish increase_release_tag use_cached_chroot use_extra_tests).each do |field| .both = f.check_box field = f.label field diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index 7ecb3a86e..c1d0c1eea 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -46,7 +46,7 @@ - selected = params[:build_list].try(:[], :auto_publish_status) ? {selected: params[:build_list][:auto_publish_status]} : {} = f.select :auto_publish_status, auto_publish_statuses, selected = f.label :auto_publish_status - - %i(auto_create_container include_testing_subrepository use_cached_chroot).each do |kind| + - %i(auto_create_container include_testing_subrepository use_cached_chroot use_extra_tests).each do |kind| .both - checked = params[:build_list].try(:[], kind) - checked = @build_list.send(kind) if checked.nil? diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 224771806..8059167ee 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -66,6 +66,9 @@ .leftlist= t("activerecord.attributes.build_list.use_cached_chroot") .rightlist= t("layout.#{@build_list.use_cached_chroot?}_") .both + .leftlist= t("activerecord.attributes.build_list.use_extra_tests") + .rightlist= t("layout.#{@build_list.use_extra_tests?}_") + .both .leftlist= t("activerecord.attributes.build_list.project_version") .rightlist= link_to @build_list.project_version, tree_path(@build_list.project, @build_list.project_version) .both diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 7ff3cdd5e..b6d94abc9 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -11,6 +11,7 @@ en: extra_build_lists: Extra build lists auto_create_container: Create container automatically use_cached_chroot: Use cached chroot + use_extra_tests: Use extra tests container_path: Container path status: Status project_id: Project diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index f04d0b488..f546c29a6 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -11,6 +11,7 @@ ru: extra_build_lists: Дополнительные сборки auto_create_container: Создать контейнер автоматически use_cached_chroot: Использовать кэшированный chroot + use_extra_tests: Использовать дополнительные тесты container_path: Путь до контейнера status: Статус project_id: Проект diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index 497a038a1..107f6d4b0 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -28,5 +28,6 @@ en: auto_publish: Automated publishing increase_release_tag: Increase release tag use_cached_chroot: Use cached chroot + use_extra_tests: Use extra tests repositories: Repositories projects_list: Projects list diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index 62db8514b..7ec4bd4ab 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -28,5 +28,6 @@ ru: auto_publish: Автоматическая публикация increase_release_tag: Увеличить release тег use_cached_chroot: Использовать кэшированный chroot + use_extra_tests: Использовать дополнительные тесты repositories: Репозитории projects_list: Список проектов diff --git a/db/migrate/20140523192643_add_use_extra_tests_to_build_lists_and_mass_builds.rb b/db/migrate/20140523192643_add_use_extra_tests_to_build_lists_and_mass_builds.rb new file mode 100644 index 000000000..95b1f3c84 --- /dev/null +++ b/db/migrate/20140523192643_add_use_extra_tests_to_build_lists_and_mass_builds.rb @@ -0,0 +1,13 @@ +class AddUseExtraTestsToBuildListsAndMassBuilds < ActiveRecord::Migration + def up + add_column :mass_builds, :use_extra_tests, :boolean, default: false, null: false + # Make existing build_lists 'false', but default to 'true' in the future. + add_column :build_lists, :use_extra_tests, :boolean, default: false, null: false + change_column :build_lists, :use_extra_tests, :boolean, default: true, null: false + end + + def down + remove_column :mass_builds, :use_extra_tests + remove_column :build_lists, :use_extra_tests + end +end diff --git a/db/schema.rb b/db/schema.rb index 88e153f11..edd024789 100644 --- a/db/schema.rb +++ b/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: 20140512183926) do +ActiveRecord::Schema.define(version: 20140523192643) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -141,6 +141,7 @@ ActiveRecord::Schema.define(version: 20140512183926) do t.boolean "include_testing_subrepository" t.string "auto_publish_status", default: "default", null: false t.boolean "use_cached_chroot", default: false, null: false + t.boolean "use_extra_tests", default: true, null: false t.index ["advisory_id"], :name => "index_build_lists_on_advisory_id" t.index ["arch_id"], :name => "index_build_lists_on_arch_id" t.index ["mass_build_id", "status"], :name => "index_build_lists_on_mass_build_id_and_status" @@ -324,6 +325,7 @@ ActiveRecord::Schema.define(version: 20140512183926) do 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 end create_table "users", force: true do |t|