From c7f8b2587daf7d65bcd4471597553fe7e77c2a6e Mon Sep 17 00:00:00 2001 From: Wedge Date: Mon, 8 Feb 2016 17:47:15 +0300 Subject: [PATCH] Added hostname field to buildlists, changed commit_hash logic, removed yandex and google counters, initial work on iso building --- Gemfile.lock | 2 +- .../product_build_lists_controller.rb | 1 + app/helpers/git_helper.rb | 4 +-- app/jobs/abf_worker/rpm_worker_observer.rb | 11 ++++++- app/models/build_list.rb | 2 +- app/models/concerns/commit_and_version.rb | 29 ------------------- .../product_build_lists/abf_workerable.rb | 16 ++-------- app/models/product_build_list.rb | 5 ---- app/views/layouts/application.html.slim | 1 - app/views/layouts/sessions.html.slim | 3 +- .../projects/build_lists/index.json.jbuilder | 2 +- app/views/projects/build_lists/show.html.slim | 4 +++ .../projects/build_lists/show.json.jbuilder | 1 - config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + ...60208083149_add_hostname_to_build_lists.rb | 5 ++++ 16 files changed, 31 insertions(+), 57 deletions(-) create mode 100644 db/migrate/20160208083149_add_hostname_to_build_lists.rb diff --git a/Gemfile.lock b/Gemfile.lock index c6ba884f1..88945e952 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -502,7 +502,7 @@ GEM sexp_processor (~> 4.1) rufus-scheduler (2.0.24) tzinfo (>= 0.3.22) - rugged (0.21.4) + rugged (0.21.0) russian (0.6.0) i18n (>= 0.5.0) rvm-capistrano (1.5.6) diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index 78e32bb8a..6791805b1 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -57,6 +57,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController flash[:notice] = t('flash.product.build_started') redirect_to [@platform, @product] else + puts pbl.errors.messages flash[:error] = t('flash.product.build_error') @product_build_list = pbl render action: :new diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index 756ad10ff..c735e4625 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -90,8 +90,8 @@ module GitHelper def versions_for_group_select(project) return [] unless project [ - [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&:name).sort], - [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name).sort] + [I18n.t('layout.git.repositories.branches'), project.github_branches.map(&:name).sort], + [I18n.t('layout.git.repositories.tags'), project.github_tags.map(&:name).sort] ] end diff --git a/app/jobs/abf_worker/rpm_worker_observer.rb b/app/jobs/abf_worker/rpm_worker_observer.rb index 0d23ddb0e..018d91b7b 100644 --- a/app/jobs/abf_worker/rpm_worker_observer.rb +++ b/app/jobs/abf_worker/rpm_worker_observer.rb @@ -30,6 +30,15 @@ module AbfWorker return end + if options['hostname'] + subject.update_attribute(:hostname, options['hostname']) + end + + if options['commit_hash'] + item.update_attribute(:version, options['commit_hash']) + subject.update_attribute(:commit_hash, options['commit_hash']) + end + rerunning_tests = subject.rerunning_tests? case status @@ -69,7 +78,7 @@ module AbfWorker def find_or_create_item subject.items.first || subject.items.create({ - version: subject.commit_hash, + version: '', name: subject.project.name, status: BuildList::BUILD_STARTED, level: 0 diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 7da13c0bc..dab7f6188 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -567,7 +567,7 @@ class BuildList < ActiveRecord::Base cmd_params = { 'PACKAGE' => project.name, 'GIT_REPO' => git_project_address, - 'COMMIT_HASH' => commit_hash, + 'PROJECT_VERSION' => project_version, 'USE_EXTRA_TESTS' => use_extra_tests?, 'SAVE_BUILDROOT' => save_buildroot?, 'EXTRA_CFG_OPTIONS' => extra_params['cfg_options'], diff --git a/app/models/concerns/commit_and_version.rb b/app/models/concerns/commit_and_version.rb index e2d120da1..2317bc5b6 100644 --- a/app/models/concerns/commit_and_version.rb +++ b/app/models/concerns/commit_and_version.rb @@ -2,40 +2,11 @@ module CommitAndVersion extend ActiveSupport::Concern included do - - validate -> { - if project && (commit_hash.blank? || (not project.github_get_commit(commit_hash))) - errors.add :commit_hash, I18n.t('flash.build_list.wrong_commit_hash', commit_hash: commit_hash) - end - } - - before_validation :set_commit_and_version before_create :set_last_published_commit end protected - def set_commit_and_version - if project && project_version.present? && commit_hash.blank? - res = "" - project.github_branches.each do |br| - if br.name == project_version - res = br.commit.sha - end - end - if res.empty? - project.github_tags.each do |br| - if br.name == project_version - res = br.commit.sha - end - end - end - self.commit_hash = res - elsif project_version.blank? && commit_hash.present? - self.project_version = commit_hash - end - end - def set_last_published_commit return unless self.respond_to? :last_published_commit_hash # product? last_commit = self.last_published.first.try :commit_hash diff --git a/app/models/concerns/product_build_lists/abf_workerable.rb b/app/models/concerns/product_build_lists/abf_workerable.rb index 4c9c2abe4..575d11260 100644 --- a/app/models/concerns/product_build_lists/abf_workerable.rb +++ b/app/models/concerns/product_build_lists/abf_workerable.rb @@ -42,8 +42,7 @@ module ProductBuildLists::AbfWorkerable main_script: main_script, platform: { type: product.platform.distrib_type, - name: product.platform.name, - arch: arch.name + name: product.platform.name }, user: {uname: user.try(:uname), email: user.try(:email)} } @@ -53,15 +52,7 @@ module ProductBuildLists::AbfWorkerable # # Returns the String. def abf_worker_srcpath - file_name = "#{project.name}-#{commit_hash}" - opts = default_url_options - opts.merge!({user: user.authentication_token, password: ''}) if user.present? - url_helpers.archive_url( - project.name_with_owner, - file_name, - 'tar.gz', - opts - ) + "https://github.com/" + project.github_get_organization + "/" + project.name + "/archive/" + project_version + ".tar.gz" end # Private: Get params for ABF worker task. @@ -71,8 +62,7 @@ module ProductBuildLists::AbfWorkerable p = { 'BUILD_ID' => id, 'PROJECT' => project.name_with_owner, - 'PROJECT_VERSION' => project_version, - 'COMMIT_HASH' => commit_hash, + 'PROJECT_VERSION' => project_version } if product.platform.hidden? token = product.platform.tokens.by_active.where(description: CACHED_CHROOT_TOKEN_DESCRIPTION).first diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 610c98ef1..9b0a746f0 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -1,5 +1,4 @@ class ProductBuildList < ActiveRecord::Base - include CommitAndVersion include TimeLiving include FileStoreClean include UrlHelper @@ -12,18 +11,14 @@ class ProductBuildList < ActiveRecord::Base belongs_to :product belongs_to :project - belongs_to :arch belongs_to :user - # see: Issue #6 - before_validation -> { self.arch_id = Arch.find_by(name: 'x86_64').id }, on: :create # field "not_delete" can be changed only if build has been completed before_validation -> { self.not_delete = false unless build_completed?; true } validates :product, :product_id, :project, :project_id, :main_script, - :arch, :arch_id, presence: true validates :main_script, :params, length: { maximum: 255 } diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 9e7d383f9..c28a821e7 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -36,4 +36,3 @@ html == yield :additional_scripts if content_for?(:additional_scripts) == render '/layouts/scroller' - == render 'layouts/counters' if Rails.env.production? diff --git a/app/views/layouts/sessions.html.slim b/app/views/layouts/sessions.html.slim index a8a1b397b..5c36f0851 100644 --- a/app/views/layouts/sessions.html.slim +++ b/app/views/layouts/sessions.html.slim @@ -26,5 +26,4 @@ html - if I18n.locale == :ru == javascript_include_tag 'moment/ru.js', cache: 'moment' == javascript_include_tag 'angular-locale_ru-ru', cache: 'angular-locale' - == yield :additional_scripts if content_for?(:additional_scripts) - == render 'layouts/counters' if Rails.env.production? + == yield :additional_scripts if content_for?(:additional_scripts) \ No newline at end of file diff --git a/app/views/projects/build_lists/index.json.jbuilder b/app/views/projects/build_lists/index.json.jbuilder index 131945e93..17cc54a9e 100644 --- a/app/views/projects/build_lists/index.json.jbuilder +++ b/app/views/projects/build_lists/index.json.jbuilder @@ -2,7 +2,7 @@ now = Time.now.utc users, projects, platforms, repositories = [], [], [], [] json.build_lists @build_lists do |build_list| json.(build_list, :id, :status, :project_id, :project_version, :save_to_platform_id, :save_to_repository_id, :user_id, :project_id, :build_for_platform_id, :arch_id, :group_id) - json.commit_hash build_list.commit_hash.first(5) + json.commit_hash build_list.commit_hash.to_s.first(5) json.last_published_commit_hash build_list.last_published_commit_hash.first(5) if build_list.last_published_commit_hash if BuildList::HUMAN_STATUSES[build_list.status].in? [:build_pending, :build_started, :build_publish] diff --git a/app/views/projects/build_lists/show.html.slim b/app/views/projects/build_lists/show.html.slim index 27251eeba..4c70cbde5 100644 --- a/app/views/projects/build_lists/show.html.slim +++ b/app/views/projects/build_lists/show.html.slim @@ -128,6 +128,10 @@ row[ ng-controller='BuildListController' td= t('activerecord.attributes.build_list.arch') td= @build_list.arch.name + tr + td= t('activerecord.attributes.build_list.hostname') + td= @build_list.hostname + tr td= t('activerecord.attributes.build_list.updated_at') td diff --git a/app/views/projects/build_lists/show.json.jbuilder b/app/views/projects/build_lists/show.json.jbuilder index 7ad4e9fd6..62ebb5387 100644 --- a/app/views/projects/build_lists/show.json.jbuilder +++ b/app/views/projects/build_lists/show.json.jbuilder @@ -22,7 +22,6 @@ json.build_list do json.can_publish_in_future can_publish_in_future?(@build_list) json.can_publish_into_repository @build_list.can_publish_into_repository? - json.container_path container_url if @build_list.container_published? json.publisher do diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 443dd6dba..2e378eb6a 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -21,6 +21,7 @@ en: arch_id: Architecture arch_short: Arch arch: Architecture + hostname: Hostname new_core: New core is_circle: Recurrent build updated_at: Notified at diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index a8fe4da20..69e2e6885 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -20,6 +20,7 @@ ru: project: Проект arch_id: Архитектура arch: Архитектура + hostname: Хост arch_short: Архит-ра new_core: Новое ядро is_circle: Циклическая сборка diff --git a/db/migrate/20160208083149_add_hostname_to_build_lists.rb b/db/migrate/20160208083149_add_hostname_to_build_lists.rb new file mode 100644 index 000000000..86d998aef --- /dev/null +++ b/db/migrate/20160208083149_add_hostname_to_build_lists.rb @@ -0,0 +1,5 @@ +class AddHostnameToBuildLists < ActiveRecord::Migration + def change + add_column :build_lists, :hostname, :string + end +end