From 590c2fbb009270812117069186c5efef1eba8732 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 16 Nov 2012 21:05:05 +0600 Subject: [PATCH 01/48] [file-store-4] optimize searching --- bin/remove_archives.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bin/remove_archives.rb b/bin/remove_archives.rb index 1bfa40322..89e98fc61 100755 --- a/bin/remove_archives.rb +++ b/bin/remove_archives.rb @@ -33,12 +33,8 @@ Dir.glob(owners).each do |owner| system "cd #{path} && git config --bool core.bare false && git checkout -f HEAD" #-- Dir.chdir(path) - archives_exists = false - %w(tar.bz2 tar.gz bz2 rar gz tar tbz2 tgz zip Z 7z tar.xz).each do |ext| - archives_exists=true and break unless `git log --all --format='%H' -- *.#{ext}`.empty? - end - if archives_exists + unless `git log --all --format='%H' -- *.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz}`.empty? system "git filter-branch -d /dev/shm/git_task --tree-filter \"/home/rosa/git_task/file-store.rb #{token}\" --prune-empty --tag-name-filter cat -- --all" ##### # This is dangerous !!! From eeab207ae3b67871365532b350ebb8b6108e92e2 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 19 Nov 2012 15:35:22 +0600 Subject: [PATCH 02/48] [file-store-4] add lzma file support --- bin/file-store.rb | 2 +- bin/remove_archives.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/file-store.rb b/bin/file-store.rb index 4f3ef9aa1..8bc3c1484 100755 --- a/bin/file-store.rb +++ b/bin/file-store.rb @@ -13,7 +13,7 @@ url = 'http://file-store.rosalinux.ru/api/v1/file_stores.json' #url = 'http://localhost:3001/api/v1/file_stores.json' rclient = RestClient::Resource.new(url, :user => ARGF.argv[0]) # user auth token -Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz}").uniq.sort.each do |file| +Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz,tar\.lzma}").uniq.sort.each do |file| begin #next if File.size(file) < MAX_SIZE diff --git a/bin/remove_archives.rb b/bin/remove_archives.rb index 89e98fc61..e37972944 100755 --- a/bin/remove_archives.rb +++ b/bin/remove_archives.rb @@ -34,7 +34,7 @@ Dir.glob(owners).each do |owner| #-- Dir.chdir(path) - unless `git log --all --format='%H' -- *.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz}`.empty? + unless `git log --all --format='%H' -- *.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz,tar\.lzma}`.empty? system "git filter-branch -d /dev/shm/git_task --tree-filter \"/home/rosa/git_task/file-store.rb #{token}\" --prune-empty --tag-name-filter cat -- --all" ##### # This is dangerous !!! From 97ea1b909ad051a22b32c54e4339e8455f4e413e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 19 Nov 2012 15:37:15 +0600 Subject: [PATCH 03/48] [file-store-4] small refactoring --- bin/file-store.rb | 2 +- bin/remove_archives.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/file-store.rb b/bin/file-store.rb index 8bc3c1484..40d04af06 100755 --- a/bin/file-store.rb +++ b/bin/file-store.rb @@ -13,7 +13,7 @@ url = 'http://file-store.rosalinux.ru/api/v1/file_stores.json' #url = 'http://localhost:3001/api/v1/file_stores.json' rclient = RestClient::Resource.new(url, :user => ARGF.argv[0]) # user auth token -Dir.glob("*.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz,tar\.lzma}").uniq.sort.each do |file| +Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file| begin #next if File.size(file) < MAX_SIZE diff --git a/bin/remove_archives.rb b/bin/remove_archives.rb index e37972944..bda3288b6 100755 --- a/bin/remove_archives.rb +++ b/bin/remove_archives.rb @@ -34,7 +34,7 @@ Dir.glob(owners).each do |owner| #-- Dir.chdir(path) - unless `git log --all --format='%H' -- *.{tar\.bz2,tar\.gz,bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,tar\.xz,tar\.lzma}`.empty? + unless `git log --all --format='%H' -- *.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}`.empty? system "git filter-branch -d /dev/shm/git_task --tree-filter \"/home/rosa/git_task/file-store.rb #{token}\" --prune-empty --tag-name-filter cat -- --all" ##### # This is dangerous !!! From ebbf47f818b9d5e4878c8a9a7b9f9110cae65ced Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 19:11:07 +0400 Subject: [PATCH 04/48] show file size, and in_queue status for ProductBuildList --- app/models/product_build_list.rb | 21 ++++++++++++------- .../product_build_lists/show.html.haml | 2 ++ .../locales/models/product_build_list.en.yml | 7 ++++++- .../locales/models/product_build_list.ru.yml | 7 ++++++- lib/abf_worker/iso_worker_observer.rb | 2 +- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index eb54f1c62..dc8dc0d8f 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -3,18 +3,24 @@ class ProductBuildList < ActiveRecord::Base include Modules::Models::CommitAndVersion delegate :url_helpers, to: 'Rails.application.routes' - BUILD_STARTED = 2 BUILD_COMPLETED = 0 - BUILD_FAILED = 1 + BUILD_FAILED = 1 + BUILD_IN_QUEUE = 2 + BUILD_STARTED = 3 + BUILD_CANCELED = 4 STATUSES = [ BUILD_STARTED, BUILD_COMPLETED, - BUILD_FAILED + BUILD_FAILED, + BUILD_IN_QUEUE, + BUILD_CANCELED ] HUMAN_STATUSES = { BUILD_STARTED => :build_started, BUILD_COMPLETED => :build_completed, - BUILD_FAILED => :build_failed + BUILD_FAILED => :build_failed, + BUILD_IN_QUEUE => :in_queue, + BUILD_CANCELED => :build_canceled } belongs_to :product @@ -28,7 +34,7 @@ class ProductBuildList < ActiveRecord::Base :main_script, :time_living, :arch_id, :presence => true - validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] } + validates :status, :inclusion => { :in => STATUSES } attr_accessor :base_url attr_accessible :status, @@ -84,6 +90,7 @@ class ProductBuildList < ActiveRecord::Base end def stop + update_attributes({:status => BUILD_CANCELED}) Resque.redis.setex( "abfworker::iso-worker-#{id}::live-inspector", 120, # Data will be removed from Redis after 120 sec. @@ -105,8 +112,8 @@ class ProductBuildList < ActiveRecord::Base options = { :id => id, # TODO: remove comment - # :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', - :srcpath => srcpath, + :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', + # :srcpath => srcpath, :params => params, :time_living => time_living, :main_script => main_script, diff --git a/app/views/platforms/product_build_lists/show.html.haml b/app/views/platforms/product_build_lists/show.html.haml index 57a506398..930dd9ad6 100644 --- a/app/views/platforms/product_build_lists/show.html.haml +++ b/app/views/platforms/product_build_lists/show.html.haml @@ -39,12 +39,14 @@ %tr %th= t("activerecord.attributes.product_build_list/results.file_name") %th= t("activerecord.attributes.product_build_list/results.sha1") + %th= t("activerecord.attributes.product_build_list/results.size") %tbody - pbl.results.each do |item| %tr - sha1 = item['sha1'] %td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" %td= sha1 + %td= item['size'] .both diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index 595419b22..e5e660300 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -17,10 +17,14 @@ en: statuses: '0': 'build' '1': 'build error' - '2': 'build in progress' + '2': 'in queue' + '3': 'build in progress' + '4': 'build canceled' build_failed: Build failed build_started: Build in progress build_completed: Built + build_canceled: Build canceled + in_queue: In queue ownership: header: Build list ownership @@ -46,6 +50,7 @@ en: product_build_list/results: file_name: File name sha1: SHA1 + size: Size (MB) flash: product_build_list: diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 24175cc0a..5748df31f 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -17,10 +17,14 @@ ru: statuses: '0': 'собран' '1': 'ошибка сборки' - '2': 'собирается' + '2': 'в очереди' + '3': 'собирается' + '4': 'отменен' build_failed: Ошибка сборки build_started: Собирается build_completed: Собран + build_canceled: Отменен + in_queue: В очереди ownership: header: Принадлежность заданий @@ -46,6 +50,7 @@ ru: product_build_list/results: file_name: Имя файла sha1: SHA1 + size: Размер (МБ) flash: product_build_list: diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index 026874368..88222b12b 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -5,7 +5,7 @@ module AbfWorker def self.perform(options) status = options['status'].to_i pbl = ProductBuildList.find options['id'] - pbl.status = status + pbl.status = status if pbl.status != ProductBuildList::BUILD_CANCELED pbl.results = options['results'] if status != ProductBuildList::BUILD_STARTED pbl.save! end From 75596c3e2d56e5d546c7cdc4fa1a0a78f406c1a8 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 19:19:05 +0400 Subject: [PATCH 05/48] revert path to data --- app/models/product_build_list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index dc8dc0d8f..6480ea73e 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -112,8 +112,8 @@ class ProductBuildList < ActiveRecord::Base options = { :id => id, # TODO: remove comment - :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', - # :srcpath => srcpath, + # :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', + :srcpath => srcpath, :params => params, :time_living => time_living, :main_script => main_script, From 846aedf49d908cfdc43b5e94a8251e37bf5e4d16 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 19:41:59 +0400 Subject: [PATCH 06/48] add canceling status --- app/models/product_build_list.rb | 17 ++++++++++++----- .../product_build_lists/show.html.haml | 2 +- config/locales/models/product_build_list.en.yml | 2 ++ config/locales/models/product_build_list.ru.yml | 2 ++ lib/abf_worker/iso_worker_observer.rb | 3 ++- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 6480ea73e..6621ff653 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -8,19 +8,22 @@ class ProductBuildList < ActiveRecord::Base BUILD_IN_QUEUE = 2 BUILD_STARTED = 3 BUILD_CANCELED = 4 + BUILD_CANCELING = 5 STATUSES = [ BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED, BUILD_IN_QUEUE, - BUILD_CANCELED + BUILD_CANCELED, + BUILD_CANCELING ] HUMAN_STATUSES = { BUILD_STARTED => :build_started, BUILD_COMPLETED => :build_completed, BUILD_FAILED => :build_failed, BUILD_IN_QUEUE => :in_queue, - BUILD_CANCELED => :build_canceled + BUILD_CANCELED => :build_canceled, + BUILD_CANCELING => :canceling } belongs_to :product @@ -65,6 +68,10 @@ class ProductBuildList < ActiveRecord::Base status == BUILD_STARTED end + def build_canceling? + status == BUILD_CANCELING + end + def container_path "/downloads/#{product.platform.name}/product/#{id}/" end @@ -90,7 +97,7 @@ class ProductBuildList < ActiveRecord::Base end def stop - update_attributes({:status => BUILD_CANCELED}) + update_attributes({:status => BUILD_CANCELING}) Resque.redis.setex( "abfworker::iso-worker-#{id}::live-inspector", 120, # Data will be removed from Redis after 120 sec. @@ -112,8 +119,8 @@ class ProductBuildList < ActiveRecord::Base options = { :id => id, # TODO: remove comment - # :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', - :srcpath => srcpath, + :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', + # :srcpath => srcpath, :params => params, :time_living => time_living, :main_script => main_script, diff --git a/app/views/platforms/product_build_lists/show.html.haml b/app/views/platforms/product_build_lists/show.html.haml index 930dd9ad6..399792035 100644 --- a/app/views/platforms/product_build_lists/show.html.haml +++ b/app/views/platforms/product_build_lists/show.html.haml @@ -23,7 +23,7 @@ = render 'show_field', :key => :notified_at, :value => l(pbl.updated_at, :format => :long) -- if pbl.build_started? +- if pbl.build_started? || pbl.build_canceling? - if can? :stop, pbl .leftlist= t("layout.product_build_lists.action") .rightlist= link_to t("layout.product_build_lists.stop"), stop_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index e5e660300..aaa0cf823 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -20,11 +20,13 @@ en: '2': 'in queue' '3': 'build in progress' '4': 'build canceled' + '5': 'canceling' build_failed: Build failed build_started: Build in progress build_completed: Built build_canceled: Build canceled in_queue: In queue + canceling: Canceling ownership: header: Build list ownership diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 5748df31f..3f16c7615 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -20,11 +20,13 @@ ru: '2': 'в очереди' '3': 'собирается' '4': 'отменен' + '5': 'отменется' build_failed: Ошибка сборки build_started: Собирается build_completed: Собран build_canceled: Отменен in_queue: В очереди + canceling: Отменяется ownership: header: Принадлежность заданий diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index 88222b12b..5af94c571 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -5,7 +5,8 @@ module AbfWorker def self.perform(options) status = options['status'].to_i pbl = ProductBuildList.find options['id'] - pbl.status = status if pbl.status != ProductBuildList::BUILD_CANCELED + pbl.status = pbl.status == ProductBuildList::BUILD_CANCELING ? + ProductBuildList::BUILD_CANCELED : status pbl.results = options['results'] if status != ProductBuildList::BUILD_STARTED pbl.save! end From 223cf774f65eaed7f965026681be0e232f60c1eb Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 19:48:14 +0400 Subject: [PATCH 07/48] revert path to data --- app/models/product_build_list.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 6621ff653..245a6992c 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -119,8 +119,8 @@ class ProductBuildList < ActiveRecord::Base options = { :id => id, # TODO: remove comment - :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', - # :srcpath => srcpath, + # :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz', + :srcpath => srcpath, :params => params, :time_living => time_living, :main_script => main_script, From edc6638b1e1ebbb00f6a74a3ce1ab8682dac5537 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 20:05:12 +0400 Subject: [PATCH 08/48] update statuses --- config/locales/models/product_build_list.en.yml | 16 ++++++++-------- config/locales/models/product_build_list.ru.yml | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index aaa0cf823..493270c5c 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -15,18 +15,18 @@ en: main_data: Main data show: Show statuses: - '0': 'build' + '0': 'build complete' '1': 'build error' - '2': 'in queue' - '3': 'build in progress' + '2': 'build is waiting' + '3': 'build started' '4': 'build canceled' - '5': 'canceling' + '5': 'build is canceling' + build_completed: Build complete build_failed: Build failed - build_started: Build in progress - build_completed: Built + in_queue: Build is waiting + build_started: Build started build_canceled: Build canceled - in_queue: In queue - canceling: Canceling + canceling: Build is canceling ownership: header: Build list ownership diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 3f16c7615..5fad63486 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -17,16 +17,16 @@ ru: statuses: '0': 'собран' '1': 'ошибка сборки' - '2': 'в очереди' + '2': 'ожидает сборки' '3': 'собирается' - '4': 'отменен' - '5': 'отменется' - build_failed: Ошибка сборки - build_started: Собирается + '4': 'сборка отменена' + '5': 'сборка отменяется' build_completed: Собран - build_canceled: Отменен - in_queue: В очереди - canceling: Отменяется + build_failed: Ошибка сборки + in_queue: Ожидает сборки + build_started: Собирается + build_canceled: Сборка отменена + canceling: Сборка отменяется ownership: header: Принадлежность заданий From 894f8651d92a4b5ca66673303a4e0a7642ef5428 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 20:38:08 +0400 Subject: [PATCH 09/48] rename BUILD_IN_QUEUE to BUILD_PENDING --- app/models/product_build_list.rb | 15 +++++++++++---- config/locales/models/product_build_list.en.yml | 6 +++--- config/locales/models/product_build_list.ru.yml | 4 ++-- lib/abf_worker/iso_worker_observer.rb | 3 +-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 245a6992c..2697fb584 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -5,7 +5,7 @@ class ProductBuildList < ActiveRecord::Base BUILD_COMPLETED = 0 BUILD_FAILED = 1 - BUILD_IN_QUEUE = 2 + BUILD_PENDING = 2 BUILD_STARTED = 3 BUILD_CANCELED = 4 BUILD_CANCELING = 5 @@ -13,7 +13,7 @@ class ProductBuildList < ActiveRecord::Base STATUSES = [ BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED, - BUILD_IN_QUEUE, + BUILD_PENDING, BUILD_CANCELED, BUILD_CANCELING ] @@ -21,7 +21,7 @@ class ProductBuildList < ActiveRecord::Base HUMAN_STATUSES = { BUILD_STARTED => :build_started, BUILD_COMPLETED => :build_completed, BUILD_FAILED => :build_failed, - BUILD_IN_QUEUE => :in_queue, + BUILD_PENDING => :build_pending, BUILD_CANCELED => :build_canceled, BUILD_CANCELING => :canceling } @@ -63,6 +63,7 @@ class ProductBuildList < ActiveRecord::Base after_create :xml_rpc_create before_destroy :can_destroy? after_destroy :xml_delete_iso_container + before_validation :check_status def build_started? status == BUILD_STARTED @@ -89,7 +90,7 @@ class ProductBuildList < ActiveRecord::Base end def can_destroy? - [BUILD_COMPLETED, BUILD_FAILED].include? status + [BUILD_COMPLETED, BUILD_FAILED, BUILD_CANCELED].include? status end def log @@ -107,6 +108,12 @@ class ProductBuildList < ActiveRecord::Base protected + def check_status + if status_was == BUILD_CANCELING && [BUILD_COMPLETED, BUILD_FAILED].include?(status) + self.status = BUILD_CANCELED + end + end + def xml_rpc_create file_name = "#{project.owner.uname}-#{project.name}-#{commit_hash}" srcpath = url_helpers.archive_url( diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index 493270c5c..f8d7ba84b 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -17,16 +17,16 @@ en: statuses: '0': 'build complete' '1': 'build error' - '2': 'build is waiting' + '2': 'build pending' '3': 'build started' '4': 'build canceled' '5': 'build is canceling' build_completed: Build complete build_failed: Build failed - in_queue: Build is waiting + build_pending: Build pending build_started: Build started build_canceled: Build canceled - canceling: Build is canceling + build_canceling: Build is canceling ownership: header: Build list ownership diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 5fad63486..74af863de 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -17,13 +17,13 @@ ru: statuses: '0': 'собран' '1': 'ошибка сборки' - '2': 'ожидает сборки' + '2': 'ожидает сборку' '3': 'собирается' '4': 'сборка отменена' '5': 'сборка отменяется' build_completed: Собран build_failed: Ошибка сборки - in_queue: Ожидает сборки + build_pending: Ожидает сборку build_started: Собирается build_canceled: Сборка отменена canceling: Сборка отменяется diff --git a/lib/abf_worker/iso_worker_observer.rb b/lib/abf_worker/iso_worker_observer.rb index 5af94c571..026874368 100644 --- a/lib/abf_worker/iso_worker_observer.rb +++ b/lib/abf_worker/iso_worker_observer.rb @@ -5,8 +5,7 @@ module AbfWorker def self.perform(options) status = options['status'].to_i pbl = ProductBuildList.find options['id'] - pbl.status = pbl.status == ProductBuildList::BUILD_CANCELING ? - ProductBuildList::BUILD_CANCELED : status + pbl.status = status pbl.results = options['results'] if status != ProductBuildList::BUILD_STARTED pbl.save! end From 2f0f49d67491520b0dd748c2768bf56c245479f3 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 20:39:57 +0400 Subject: [PATCH 10/48] hot fix --- app/models/product_build_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 2697fb584..07bcf57aa 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -23,7 +23,7 @@ class ProductBuildList < ActiveRecord::Base BUILD_FAILED => :build_failed, BUILD_PENDING => :build_pending, BUILD_CANCELED => :build_canceled, - BUILD_CANCELING => :canceling + BUILD_CANCELING => :build_canceling } belongs_to :product From 2203bb8ad01d33dd8e93276167bfa241fdbc7279 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 21:02:08 +0400 Subject: [PATCH 11/48] update locales --- config/locales/models/product_build_list.ru.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 74af863de..9bc381c7f 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -26,7 +26,7 @@ ru: build_pending: Ожидает сборку build_started: Собирается build_canceled: Сборка отменена - canceling: Сборка отменяется + build_canceling: Сборка отменяется ownership: header: Принадлежность заданий From b7b0ea2f7ad3d9b492ded2eb7c4d4fecbe42e600 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 19 Nov 2012 22:08:02 +0400 Subject: [PATCH 12/48] remove #check_status method --- app/models/product_build_list.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 07bcf57aa..5cfbed662 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -63,7 +63,6 @@ class ProductBuildList < ActiveRecord::Base after_create :xml_rpc_create before_destroy :can_destroy? after_destroy :xml_delete_iso_container - before_validation :check_status def build_started? status == BUILD_STARTED @@ -108,12 +107,6 @@ class ProductBuildList < ActiveRecord::Base protected - def check_status - if status_was == BUILD_CANCELING && [BUILD_COMPLETED, BUILD_FAILED].include?(status) - self.status = BUILD_CANCELED - end - end - def xml_rpc_create file_name = "#{project.owner.uname}-#{project.name}-#{commit_hash}" srcpath = url_helpers.archive_url( From 0f74aaedc1097f358686e6c5cc9dd222a2c2c746 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 20 Nov 2012 16:33:29 +0400 Subject: [PATCH 13/48] #727: remove unnecessary fields --- config/locales/models/product_build_list.en.yml | 6 ------ config/locales/models/product_build_list.ru.yml | 6 ------ 2 files changed, 12 deletions(-) diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index f8d7ba84b..9402287c2 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -15,12 +15,6 @@ en: main_data: Main data show: Show statuses: - '0': 'build complete' - '1': 'build error' - '2': 'build pending' - '3': 'build started' - '4': 'build canceled' - '5': 'build is canceling' build_completed: Build complete build_failed: Build failed build_pending: Build pending diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 9bc381c7f..8411c9461 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -15,12 +15,6 @@ ru: main_data: Основные данные show: Просмотр statuses: - '0': 'собран' - '1': 'ошибка сборки' - '2': 'ожидает сборку' - '3': 'собирается' - '4': 'сборка отменена' - '5': 'сборка отменяется' build_completed: Собран build_failed: Ошибка сборки build_pending: Ожидает сборку From 6fe07d83d6bec5199603b0df67663c044336fca9 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 20 Nov 2012 20:14:51 +0400 Subject: [PATCH 14/48] add validation for build_for_platform field --- app/models/build_list.rb | 3 +++ config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + 3 files changed, 5 insertions(+) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index aa7af138f..b02d231b7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -26,6 +26,9 @@ class BuildList < ActiveRecord::Base validate lambda { errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id } + validate lambda { + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.platform_type == 'main' + } validate lambda { errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id) } diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 962155821..5f9a1e18a 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -143,6 +143,7 @@ en: no_project_version_found: Project version '%{project_version}' not found no_arch_or_platform_selected: At least one of architecture of platform must selected wrong_platform: Only the primary platform can be selected for the main repository! + wrong_build_for_platform: Type of platform in "build_for_platform" should be "main" wrong_repository: Repository to save package to must belongs to platform. cannot_write: You can't build project to this repository. can_not_published: Build can only be published with status "Build complete" diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 4953d08bd..f154a7803 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -140,6 +140,7 @@ ru: no_project_version_found: Выбранная версия '%{project_version}' не найдена no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа! + wrong_build_for_platform: Тип платформы "build_for_platform" должен быть "main" wrong_repository: Репозиторий для сохранения должен принадлежать платформе. cannot_write: Вы не можете собирать пакет в этот репозиторий. can_not_published: Опубликовать сборку можно только со статусом "Собран" From 6b842bb51adf6c24416c4c5880d7a2080216c11b Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Nov 2012 16:09:01 +0400 Subject: [PATCH 15/48] add Search API, some refactoring --- app/controllers/api/v1/search_controller.rb | 27 +++++++++++++++++++ app/controllers/search_controller.rb | 18 ++++++------- app/views/api/v1/search/_groups.json.jbuilder | 3 +++ app/views/api/v1/search/_member.json.jbuilder | 3 +++ .../api/v1/search/_platforms.json.jbuilder | 3 +++ .../api/v1/search/_projects.json.jbuilder | 3 +++ app/views/api/v1/search/_users.json.jbuilder | 3 +++ app/views/api/v1/search/index.json.jbuilder | 6 +++++ app/views/search/_form.html.haml | 2 +- app/views/search/_form_advanced.html.haml | 4 +-- app/views/search/_table.html.haml | 2 +- app/views/search/index.html.haml | 6 ++--- config/routes.rb | 1 + 13 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 app/controllers/api/v1/search_controller.rb create mode 100644 app/views/api/v1/search/_groups.json.jbuilder create mode 100644 app/views/api/v1/search/_member.json.jbuilder create mode 100644 app/views/api/v1/search/_platforms.json.jbuilder create mode 100644 app/views/api/v1/search/_projects.json.jbuilder create mode 100644 app/views/api/v1/search/_users.json.jbuilder create mode 100644 app/views/api/v1/search/index.json.jbuilder diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb new file mode 100644 index 000000000..fbd0902f6 --- /dev/null +++ b/app/controllers/api/v1/search_controller.rb @@ -0,0 +1,27 @@ +# -*- encoding : utf-8 -*- +class Api::V1::SearchController < Api::V1::BaseController + TAGS = ['projects', 'users', 'groups', 'platforms'] + + before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + + def index + @results = {} + @query = params[:query] + type = params[:type] || 'all' + case type + when 'all' + TAGS.each{ |t| @results[t] = find_collection(t) } + when *TAGS + @results[type] = find_collection(type) + end + end + + protected + + def find_collection(type) + type.classify.constantize.opened. + search(@query). + search_order. + paginate(paginate_params) + end +end \ No newline at end of file diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index f4bf67e81..5f32806a4 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,18 +1,18 @@ # -*- encoding : utf-8 -*- class SearchController < ApplicationController + TAGS = ['projects', 'users', 'groups', 'platforms'] + before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] # load_and_authorize_resource def index - params[:type] ||= 'all' - case params[:type] + @type = params[:type] || 'all' + @query = params[:query] + case @type when 'all' - find_collection('projects') - find_collection('users') - find_collection('groups') - find_collection('platforms') - when 'projects', 'users', 'groups', 'platforms' - find_collection(params[:type]) + TAGS.each{ |t| find_collection(t) } + when *TAGS + find_collection(@type) end end @@ -20,6 +20,6 @@ class SearchController < ApplicationController def find_collection(type) var = :"@#{type}" - instance_variable_set var, type.classify.constantize.opened.search(params[:query]).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var) + instance_variable_set var, type.classify.constantize.opened.search(@query).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var) end end diff --git a/app/views/api/v1/search/_groups.json.jbuilder b/app/views/api/v1/search/_groups.json.jbuilder new file mode 100644 index 000000000..56026b009 --- /dev/null +++ b/app/views/api/v1/search/_groups.json.jbuilder @@ -0,0 +1,3 @@ +json.groups results do |group| + json.partial! 'member', :member => group, :json => json +end \ No newline at end of file diff --git a/app/views/api/v1/search/_member.json.jbuilder b/app/views/api/v1/search/_member.json.jbuilder new file mode 100644 index 000000000..48ab5b101 --- /dev/null +++ b/app/views/api/v1/search/_member.json.jbuilder @@ -0,0 +1,3 @@ +json.(member, :id, :uname) +json.(member, :name) if member.is_a?(User) +json.url member_path(member) \ No newline at end of file diff --git a/app/views/api/v1/search/_platforms.json.jbuilder b/app/views/api/v1/search/_platforms.json.jbuilder new file mode 100644 index 000000000..4aa9aff17 --- /dev/null +++ b/app/views/api/v1/search/_platforms.json.jbuilder @@ -0,0 +1,3 @@ +json.platforms results do |platform| + json.partial! 'api/v1/platforms/platform', :platform => platform, :json => json +end \ No newline at end of file diff --git a/app/views/api/v1/search/_projects.json.jbuilder b/app/views/api/v1/search/_projects.json.jbuilder new file mode 100644 index 000000000..79cfaa435 --- /dev/null +++ b/app/views/api/v1/search/_projects.json.jbuilder @@ -0,0 +1,3 @@ +json.projects results do |project| + json.partial! 'api/v1/projects/project', :project => project, :json => json +end \ No newline at end of file diff --git a/app/views/api/v1/search/_users.json.jbuilder b/app/views/api/v1/search/_users.json.jbuilder new file mode 100644 index 000000000..0d23c054d --- /dev/null +++ b/app/views/api/v1/search/_users.json.jbuilder @@ -0,0 +1,3 @@ +json.users results do |user| + json.partial! 'member', :member => user, :json => json +end \ No newline at end of file diff --git a/app/views/api/v1/search/index.json.jbuilder b/app/views/api/v1/search/index.json.jbuilder new file mode 100644 index 000000000..a0301172a --- /dev/null +++ b/app/views/api/v1/search/index.json.jbuilder @@ -0,0 +1,6 @@ +json.results do |json| + @results.each do |tag, results| + json.partial! tag.dup, :results => results, :json => json + end +end +json.url api_v1_search_index_path(params) \ No newline at end of file diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml index e7aed5c1e..eb315bc85 100644 --- a/app/views/search/_form.html.haml +++ b/app/views/search/_form.html.haml @@ -1,4 +1,4 @@ .search = form_tag search_index_path, :method => 'get' do .pic - .field= text_field_tag 'query', params[:query], :placeholder => t("layout.search.header") \ No newline at end of file + .field= text_field_tag 'query', @query, :placeholder => t("layout.search.header") \ No newline at end of file diff --git a/app/views/search/_form_advanced.html.haml b/app/views/search/_form_advanced.html.haml index 8a49e7d2d..ab704ec69 100644 --- a/app/views/search/_form_advanced.html.haml +++ b/app/views/search/_form_advanced.html.haml @@ -1,5 +1,5 @@ = form_tag search_index_path, :method => 'get' do - .leftside= text_field_tag 'query', params[:query], :placeholder => t("layout.search.header"), :class => 'exsearch' - .lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, params[:type]), :class => 'sel80 cusel', :id => 'selSearch' + .leftside= text_field_tag 'query', @query, :placeholder => t("layout.search.header"), :class => 'exsearch' + .lineForm.leftside.rmargin10= select_tag 'type', options_for_select(t('layout.search.types').invert, @type), :class => 'sel80 cusel', :id => 'selSearch' .leftside= submit_tag t("layout.search.header"), :class => 'button width100' .both \ No newline at end of file diff --git a/app/views/search/_table.html.haml b/app/views/search/_table.html.haml index 901427190..048bc6209 100644 --- a/app/views/search/_table.html.haml +++ b/app/views/search/_table.html.haml @@ -7,4 +7,4 @@ - collection.each do |c| %tr %td= render type.singularize, type.singularize.to_sym => c -= link_to t('layout.search.all'), search_index_path(:query => params[:query], :type => type) if collection.present? \ No newline at end of file += link_to t('layout.search.all'), search_index_path(:query => @query, :type => type) if collection.present? \ No newline at end of file diff --git a/app/views/search/index.html.haml b/app/views/search/index.html.haml index 695b1a042..bec080a11 100644 --- a/app/views/search/index.html.haml +++ b/app/views/search/index.html.haml @@ -1,6 +1,6 @@ %h3= title t('layout.search.advanced') = render 'form_advanced' -- if params[:type] == 'all' +- if @type == 'all' #all = render 'table', :type => 'projects' .both @@ -10,8 +10,8 @@ .left.width400 = render 'table', :type => 'platforms' - else - - collection = instance_variable_get("@#{params[:type]}") - .tmargin10{:id => params[:type]}= render :collection => collection, :partial => params[:type].to_s.underscore.singularize + - collection = instance_variable_get("@#{@type}") + .tmargin10{:id => @type}= render :collection => collection, :partial => @type.to_s.underscore.singularize %br = will_paginate collection .both diff --git a/config/routes.rb b/config/routes.rb index 4c0005ff1..b57307f1b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,7 @@ Rosa::Application.routes.draw do namespace :api do namespace :v1 do resources :advisories, :only => [:index, :show, :create, :update] + resources :search, :only => [:index] resources :build_lists, :only => [:index, :create, :show] do member { get :publish From 916a984b6d2c07a5eaa221ca4e8607b30b2c32e0 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Nov 2012 16:32:59 +0400 Subject: [PATCH 16/48] add specs for search API --- .../api/v1/search_controller_spec.rb | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/controllers/api/v1/search_controller_spec.rb diff --git a/spec/controllers/api/v1/search_controller_spec.rb b/spec/controllers/api/v1/search_controller_spec.rb new file mode 100644 index 000000000..d13007543 --- /dev/null +++ b/spec/controllers/api/v1/search_controller_spec.rb @@ -0,0 +1,34 @@ +# -*- encoding : utf-8 -*- +require 'spec_helper' + +shared_examples_for 'able search with api' do + it 'should be able to search' do + get :index, :format => :json + response.should be_success + response.should render_template(:index) + end +end +shared_examples_for 'not able search with api' do + it 'should not be able to search' do + get :index, :format => :json + response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) + end +end + +describe Api::V1::SearchController do + before { stub_symlink_methods } + + context 'as guest' do + if APP_CONFIG['anonymous_access'] + it_should_behave_like 'able search with api' + else + it_should_behave_like 'not able search with api' + end + end + + context 'as user' do + before {set_session_for FactoryGirl.create(:user)} + + it_should_behave_like 'able search with api' + end +end From c629c91bb7498c2be2df1fed59375323130fa409 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Nov 2012 16:55:57 +0400 Subject: [PATCH 17/48] rename constants --- app/controllers/api/v1/search_controller.rb | 6 +++--- app/controllers/search_controller.rb | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index fbd0902f6..862537b57 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- class Api::V1::SearchController < Api::V1::BaseController - TAGS = ['projects', 'users', 'groups', 'platforms'] + TYPES = ['projects', 'users', 'groups', 'platforms'] before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] @@ -10,8 +10,8 @@ class Api::V1::SearchController < Api::V1::BaseController type = params[:type] || 'all' case type when 'all' - TAGS.each{ |t| @results[t] = find_collection(t) } - when *TAGS + TYPES.each{ |t| @results[t] = find_collection(t) } + when *TYPES @results[type] = find_collection(type) end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 5f32806a4..f95ca8021 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- class SearchController < ApplicationController - TAGS = ['projects', 'users', 'groups', 'platforms'] + TYPES = ['projects', 'users', 'groups', 'platforms'] before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] # load_and_authorize_resource @@ -10,8 +10,8 @@ class SearchController < ApplicationController @query = params[:query] case @type when 'all' - TAGS.each{ |t| find_collection(t) } - when *TAGS + TYPES.each{ |t| find_collection(t) } + when *TYPES find_collection(@type) end end From 7fcd3d678054d251250aa9a3c7ace76394c5e87f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Nov 2012 17:49:34 +0400 Subject: [PATCH 18/48] update url for search results --- app/views/api/v1/search/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/api/v1/search/index.json.jbuilder b/app/views/api/v1/search/index.json.jbuilder index a0301172a..4c861bba7 100644 --- a/app/views/api/v1/search/index.json.jbuilder +++ b/app/views/api/v1/search/index.json.jbuilder @@ -3,4 +3,4 @@ json.results do |json| json.partial! tag.dup, :results => results, :json => json end end -json.url api_v1_search_index_path(params) \ No newline at end of file +json.url api_v1_search_index_path(:format => :json) \ No newline at end of file From 4c6acc8702eec082a8c0f5920151b2177a76d740 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 21 Nov 2012 19:54:53 +0600 Subject: [PATCH 19/48] [file-store-6] change upload url --- bin/file-store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/file-store.rb b/bin/file-store.rb index 40d04af06..390121568 100755 --- a/bin/file-store.rb +++ b/bin/file-store.rb @@ -26,7 +26,7 @@ Dir.glob("*.{bz2,rar,gz,tar,tbz2,tgz,zip,Z,7z,xz,lzma}").uniq.sort.each do |file puts " file \"#{file}\" already exists in the file-store" elsif resp == [] # try to put file at file-store - resp = JSON(rclient.post :file_store => {:file => File.new(file, 'rb')}) + resp = JSON `curl --user #{ARGF.argv[0]}: -POST -F "file_store[file]=@#{file}" http://file-store.rosalinux.ru/api/v1/upload` unless resp['sha1_hash'].nil? new_sources << " \"#{file}\": #{sha1}" FileUtils.rm_rf file From af2be3fb09efaaefc7aef5415927b32c0045bef6 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 21 Nov 2012 19:04:41 +0400 Subject: [PATCH 20/48] create logical model for serach by ABF --- app/controllers/api/v1/search_controller.rb | 25 ++++---------------- app/controllers/search_controller.rb | 21 ++++++----------- app/models/search.rb | 26 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 app/models/search.rb diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 862537b57..525b45c4a 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,27 +1,12 @@ # -*- encoding : utf-8 -*- class Api::V1::SearchController < Api::V1::BaseController - TYPES = ['projects', 'users', 'groups', 'platforms'] - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] def index - @results = {} - @query = params[:query] - type = params[:type] || 'all' - case type - when 'all' - TYPES.each{ |t| @results[t] = find_collection(t) } - when *TYPES - @results[type] = find_collection(type) - end - end - - protected - - def find_collection(type) - type.classify.constantize.opened. - search(@query). - search_order. - paginate(paginate_params) + @results = Search.by_term_and_type( + params[:query], + (params[:type] || 'all'), + paginate_params + ) end end \ No newline at end of file diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index f95ca8021..46157d1cd 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,25 +1,18 @@ # -*- encoding : utf-8 -*- class SearchController < ApplicationController - TYPES = ['projects', 'users', 'groups', 'platforms'] - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] # load_and_authorize_resource def index @type = params[:type] || 'all' @query = params[:query] - case @type - when 'all' - TYPES.each{ |t| find_collection(t) } - when *TYPES - find_collection(@type) + Search.by_term_and_type( + @query, + @type, + {:page => params[:page]} + ).each do |k, v| + var = :"@#{k}" + instance_variable_set var, v unless instance_variable_defined?(var) end end - - protected - - def find_collection(type) - var = :"@#{type}" - instance_variable_set var, type.classify.constantize.opened.search(@query).search_order.paginate(:page => params[:page]) unless instance_variable_defined?(var) - end end diff --git a/app/models/search.rb b/app/models/search.rb new file mode 100644 index 000000000..409d246ef --- /dev/null +++ b/app/models/search.rb @@ -0,0 +1,26 @@ +# -*- encoding : utf-8 -*- +class Search + TYPES = ['projects', 'users', 'groups', 'platforms'] + + def self.by_term_and_type(term, type, paginate_params) + results = {} + case type + when 'all' + TYPES.each{ |t| results[t] = find_collection(t, term, paginate_params) } + when *TYPES + results[type] = find_collection(type, term, paginate_params) + end + results + end + + class << self + protected + + def find_collection(type, term, paginate_params) + type.classify.constantize.opened. + search(term). + search_order. + paginate(paginate_params) + end + end +end \ No newline at end of file From fe1e862535530eacb1cb8495ecefaca8b920d151 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Thu, 22 Nov 2012 15:23:04 +0400 Subject: [PATCH 21/48] Change school deploy address. Add new test for project controller --- spec/controllers/projects/projects_controller_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/controllers/projects/projects_controller_spec.rb b/spec/controllers/projects/projects_controller_spec.rb index dc240686a..f6ef63456 100644 --- a/spec/controllers/projects/projects_controller_spec.rb +++ b/spec/controllers/projects/projects_controller_spec.rb @@ -94,6 +94,11 @@ describe Projects::ProjectsController do put :update, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@update_params) response.should redirect_to(new_user_session_path) end + + it 'should not be able to perform create action' do + post :create, @create_params + response.should redirect_to(new_user_session_path) + end end context 'registered user' do From c42fcc824ab7a81ac76b208776d8dc3df97d7eb0 Mon Sep 17 00:00:00 2001 From: vladdruzh Date: Mon, 26 Nov 2012 15:32:23 +0400 Subject: [PATCH 22/48] add to api maintainers index method --- .../api/v1/maintainers_controller.rb | 18 ++++++++++++ .../v1/maintainers/_maintainer.json.jbuilder | 2 ++ .../api/v1/maintainers/_package.json.jbuilder | 3 ++ .../api/v1/maintainers/index.json.jbuilder | 15 ++++++++++ config/routes.rb | 1 + .../api/v1/maintainers_controller_spec.rb | 29 +++++++++++++++++++ 6 files changed, 68 insertions(+) create mode 100644 app/controllers/api/v1/maintainers_controller.rb create mode 100644 app/views/api/v1/maintainers/_maintainer.json.jbuilder create mode 100644 app/views/api/v1/maintainers/_package.json.jbuilder create mode 100644 app/views/api/v1/maintainers/index.json.jbuilder create mode 100644 spec/controllers/api/v1/maintainers_controller_spec.rb diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb new file mode 100644 index 000000000..7aa77de28 --- /dev/null +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -0,0 +1,18 @@ +class Api::V1::MaintainersController < Api::V1::BaseController + before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + before_filter :find_platform + + def index + @maintainers = BuildList::Package.actual.by_platform(@platform) + .order('lower(name) ASC, length(name) ASC') + .includes(:project) + .paginate(paginate_params) + end + + private + + def find_platform + @platform = Platform.find(params[:platform_id]) + end + +end diff --git a/app/views/api/v1/maintainers/_maintainer.json.jbuilder b/app/views/api/v1/maintainers/_maintainer.json.jbuilder new file mode 100644 index 000000000..ee03a5c24 --- /dev/null +++ b/app/views/api/v1/maintainers/_maintainer.json.jbuilder @@ -0,0 +1,2 @@ +json.(maintainer, :id, :uname, :name, :email) +json.url api_v1_user_path(maintainer.id) diff --git a/app/views/api/v1/maintainers/_package.json.jbuilder b/app/views/api/v1/maintainers/_package.json.jbuilder new file mode 100644 index 000000000..a6d452013 --- /dev/null +++ b/app/views/api/v1/maintainers/_package.json.jbuilder @@ -0,0 +1,3 @@ +json.(package, :id, :name, :version, :release) +json.type package.package_type +json.updated_at package.updated_at.to_i diff --git a/app/views/api/v1/maintainers/index.json.jbuilder b/app/views/api/v1/maintainers/index.json.jbuilder new file mode 100644 index 000000000..3113b84af --- /dev/null +++ b/app/views/api/v1/maintainers/index.json.jbuilder @@ -0,0 +1,15 @@ +json.maintainers @maintainers do |json, maintainer| + json.project do |json_project| + json_project.partial! 'api/v1/projects/project', :project => maintainer.project, :json => json + end + + json.package do |json_package| + json_package.partial! 'package', :package => maintainer, :json => json + end + + json.maintainer do |json_maintainer| + if user = maintainer.try(:assignee) + json_maintainer.partial! 'maintainer', :maintainer => user, :json => json + end + end +end diff --git a/config/routes.rb b/config/routes.rb index b57307f1b..4916b02da 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,6 +33,7 @@ Rosa::Application.routes.draw do post :clone put :clear } + resources :maintainers, :only => [ :index ] end resources :repositories, :only => [:show, :update, :destroy] do member { diff --git a/spec/controllers/api/v1/maintainers_controller_spec.rb b/spec/controllers/api/v1/maintainers_controller_spec.rb new file mode 100644 index 000000000..15493e1c2 --- /dev/null +++ b/spec/controllers/api/v1/maintainers_controller_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe Api::V1::MaintainersController do + let(:package) { FactoryGirl.create(:build_list_package) } + + context 'for guest' do + it "should be able to perform index action", :anonymous_access => true do + get :index, :platform_id => package.platform_id, :format => :json + should render_template(:index) + end + + it 'should be able to perform get_id action', :anonymous_access => false do + get :index, :platform_id => package.platform_id, :format => :json + response.status.should == 401 + end + end + + context 'for simple user' do + before do + stub_symlink_methods + http_login(FactoryGirl.create(:user)) + end + + it "should be able to perform index action" do + get :index, :platform_id => package.platform_id, :format => :json + should render_template(:index) + end + end +end From c7ea2f7656facf49448c5a3169692f2c491c5186 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 26 Nov 2012 22:00:29 +0400 Subject: [PATCH 23/48] send task to abf-worker --- app/models/build_list.rb | 33 ++++++++++++++++++++++++++- lib/abf_worker/rpm_worker_observer.rb | 18 +++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 lib/abf_worker/rpm_worker_observer.rb diff --git a/app/models/build_list.rb b/app/models/build_list.rb index b02d231b7..c1d421767 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -243,8 +243,39 @@ class BuildList < ActiveRecord::Base def add_to_queue + include_repos_hash = {}.tap do |h| + include_repos.each do |r| + repo = Repository.find r + h[repo.name] = repo.platform.public_downloads_url(nil, arch, repo.name) + end + end + options = { + :id => id, + :arch => arch.name, + :time_living => 2880, # 2 days + :distrib_type => build_for_platform.distrib_type, + :git_project_address => 'https://abf.rosalinux.ru/import/qtiplot.git', + # :git_project_address => project.git_project_address, + :commit_hash => '9272c173c517178b5c039c4b196c719b472147a7', + # :commit_hash => commit_hash, + :build_requires => build_requires, + :include_repos => include_repos_hash + + + # :project_version => project_version, + # :plname => save_to_platform.name, + # :bplname => (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), + # :update_type => update_type, + # :priority => priority, + } + Resque.push( + 'rpm_worker', + 'class' => 'AbfWorker::RpmWorker', + 'args' => [options] + ) + @status ||= BUILD_PENDING #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address - @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address + # @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address end def self.human_status(status) diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb new file mode 100644 index 000000000..1549b267d --- /dev/null +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -0,0 +1,18 @@ +module AbfWorker + class RpmWorkerObserver + @queue = :rpm_worker_observer + + def self.perform(options) + bl = BuildList.find options['id'] + case options['status'].to_i + when 0 + bl.build_success + when 1 + bl.build_error + when 3 + bl.start_build + end + end + + end +end \ No newline at end of file From 96e8df1b50cccf71acde5be2737ea8781d9f911f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 26 Nov 2012 22:16:34 +0400 Subject: [PATCH 24/48] use Redis for getting log --- app/controllers/projects/build_lists_controller.rb | 14 +++++++++----- app/models/build_list.rb | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 7044b12a8..ca44ce0ec 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -104,12 +104,16 @@ class Projects::BuildListsController < Projects::BaseController end def log - @log = `tail -n #{params[:load_lines].to_i} #{Rails.root + 'public' + @build_list.fs_log_path}` - @log = t("layout.build_lists.log.not_available") unless $?.success? + render :json => { + :log => @build_list.log, + :building => @build_list.build_started? + } + # @log = `tail -n #{params[:load_lines].to_i} #{Rails.root + 'public' + @build_list.fs_log_path}` + # @log = t("layout.build_lists.log.not_available") unless $?.success? - respond_to do |format| - format.json { render :json => { :log => @log, :building => @build_list.build_started? } } - end + # respond_to do |format| + # format.json { render :json => { :log => @log, :building => @build_list.build_started? } } + # end end def publish_build diff --git a/app/models/build_list.rb b/app/models/build_list.rb index c1d421767..156eb0f3a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -345,6 +345,10 @@ class BuildList < ActiveRecord::Base status == BUILD_PUBLISHED end + def log + Resque.redis.get("abfworker::rpm-worker-#{id}") || '' + end + protected def notify_users From c7adea14ce05e8357d2feab1b2299e9f07bfedbb Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 27 Nov 2012 14:59:47 +0400 Subject: [PATCH 25/48] fix the tasks duplication --- app/models/build_list.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 156eb0f3a..6ce3b1df6 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -268,11 +268,13 @@ class BuildList < ActiveRecord::Base # :update_type => update_type, # :priority => priority, } - Resque.push( - 'rpm_worker', - 'class' => 'AbfWorker::RpmWorker', - 'args' => [options] - ) + unless @status + Resque.push( + 'rpm_worker', + 'class' => 'AbfWorker::RpmWorker', + 'args' => [options] + ) + end @status ||= BUILD_PENDING #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address # @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address From 3d6269da9b3a25f894a93abfd14d809c1f6dee60 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 27 Nov 2012 18:22:17 +0400 Subject: [PATCH 26/48] add results column to build_lists table --- app/models/build_list.rb | 3 ++- .../product_build_lists/_results.html.haml | 18 +++++++++++++++++ .../product_build_lists/show.html.haml | 20 +------------------ app/views/projects/build_lists/show.html.haml | 6 ++++-- ...0121127122032_add_results_to_build_list.rb | 5 +++++ db/schema.rb | 3 ++- lib/abf_worker/rpm_worker_observer.rb | 9 ++++++++- 7 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 app/views/platforms/product_build_lists/_results.html.haml create mode 100644 db/migrate/20121127122032_add_results_to_build_list.rb diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 6ce3b1df6..69fabf2d1 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -112,6 +112,7 @@ class BuildList < ActiveRecord::Base serialize :additional_repos serialize :include_repos + serialize :results, Array after_commit :place_build after_destroy :delete_container @@ -246,7 +247,7 @@ class BuildList < ActiveRecord::Base include_repos_hash = {}.tap do |h| include_repos.each do |r| repo = Repository.find r - h[repo.name] = repo.platform.public_downloads_url(nil, arch, repo.name) + h[repo.name] = repo.platform.public_downloads_url(nil, arch.name, repo.name) end end options = { diff --git a/app/views/platforms/product_build_lists/_results.html.haml b/app/views/platforms/product_build_lists/_results.html.haml new file mode 100644 index 000000000..934941585 --- /dev/null +++ b/app/views/platforms/product_build_lists/_results.html.haml @@ -0,0 +1,18 @@ +%h3= t("layout.product_build_lists.results") +- unless pbl.results.present? + %h4.nomargin= t("layout.product_build_lists.no_results") +- else + %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th= t("activerecord.attributes.product_build_list/results.file_name") + %th= t("activerecord.attributes.product_build_list/results.sha1") + %th= t("activerecord.attributes.product_build_list/results.size") + %tbody + - pbl.results.each do |item| + %tr + - sha1 = item['sha1'] + %td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" + %td= sha1 + %td= item['size'] +.both \ No newline at end of file diff --git a/app/views/platforms/product_build_lists/show.html.haml b/app/views/platforms/product_build_lists/show.html.haml index 399792035..8b18b6972 100644 --- a/app/views/platforms/product_build_lists/show.html.haml +++ b/app/views/platforms/product_build_lists/show.html.haml @@ -30,25 +30,7 @@ .both = render 'shared/log', { :build_started => true, :get_log_path => log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) } -%h3= t("layout.product_build_lists.results") -- unless pbl.results.present? - %h4.nomargin= t("layout.product_build_lists.no_results") -- else - %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} - %thead - %tr - %th= t("activerecord.attributes.product_build_list/results.file_name") - %th= t("activerecord.attributes.product_build_list/results.sha1") - %th= t("activerecord.attributes.product_build_list/results.size") - %tbody - - pbl.results.each do |item| - %tr - - sha1 = item['sha1'] - %td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}" - %td= sha1 - %td= item['size'] -.both - += render 'results', :pbl => pbl :javascript $(function(){ diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index cbb5670eb..3dc935547 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -124,8 +124,8 @@ var r = new Rosa.Routers.BuildListsAdvisoriesRouter(); }); - - if BuildList::HUMAN_STATUSES[@build_list.status].in? [:build_started, :build_error, :success] - = render 'shared/log', { :build_started => @build_list.build_started?, :download_log_url => build_list_log_url(:build), :get_log_path => log_build_list_path(@build_list) } + - if BuildList::HUMAN_STATUSES[@build_list.status].in? [:build_started, :build_error] + = render 'shared/log', { :build_started => @build_list.build_started?, :get_log_path => log_build_list_path(@build_list) } - if (can_publish = @build_list.can_publish? && can?(:publish, @build_list)) @@ -173,6 +173,8 @@ %td= package.release .both += render 'platforms/product_build_lists/results', :pbl => @build_list + :javascript $('article .all').addClass('bigpadding'); diff --git a/db/migrate/20121127122032_add_results_to_build_list.rb b/db/migrate/20121127122032_add_results_to_build_list.rb new file mode 100644 index 000000000..0bee2f39e --- /dev/null +++ b/db/migrate/20121127122032_add_results_to_build_list.rb @@ -0,0 +1,5 @@ +class AddResultsToBuildList < ActiveRecord::Migration + def change + add_column :build_lists, :results, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index e0d3376e3..b40e02f98 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121106113338) do +ActiveRecord::Schema.define(:version => 20121127122032) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -130,6 +130,7 @@ ActiveRecord::Schema.define(:version => 20121106113338) do t.integer "advisory_id" t.integer "mass_build_id" t.integer "save_to_repository_id" + t.text "results" end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" diff --git a/lib/abf_worker/rpm_worker_observer.rb b/lib/abf_worker/rpm_worker_observer.rb index 1549b267d..97ab4703e 100644 --- a/lib/abf_worker/rpm_worker_observer.rb +++ b/lib/abf_worker/rpm_worker_observer.rb @@ -4,14 +4,21 @@ module AbfWorker def self.perform(options) bl = BuildList.find options['id'] - case options['status'].to_i + status = options['status'].to_i + case status when 0 bl.build_success when 1 bl.build_error when 3 + bl.bs_id = bl.id + bl.save bl.start_build end + if status != 3 + bl.results = options['results'] + bl.save + end end end From 0545863642b4cc9dd15597f304bf3debb4378fee Mon Sep 17 00:00:00 2001 From: vladdruzh Date: Wed, 28 Nov 2012 10:04:40 +0400 Subject: [PATCH 27/48] refactor --- app/controllers/api/v1/maintainers_controller.rb | 10 +--------- app/controllers/platforms/maintainers_controller.rb | 1 - app/models/build_list/package.rb | 2 ++ 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index 7aa77de28..625a63134 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -1,18 +1,10 @@ class Api::V1::MaintainersController < Api::V1::BaseController before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] - before_filter :find_platform + load_and_authorize_resource :platform def index @maintainers = BuildList::Package.actual.by_platform(@platform) - .order('lower(name) ASC, length(name) ASC') .includes(:project) .paginate(paginate_params) end - - private - - def find_platform - @platform = Platform.find(params[:platform_id]) - end - end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 386e48ae4..5c3e49a84 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -6,7 +6,6 @@ class Platforms::MaintainersController < ApplicationController def index @maintainers = BuildList::Package.actual.by_platform(@platform) - .order('lower(name) ASC, length(name) ASC') .includes(:project) @maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index ce894412b..6a3dcb79c 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -12,6 +12,8 @@ class BuildList::Package < ActiveRecord::Base :presence => true validates :package_type, :inclusion => PACKAGE_TYPES + default_scope order('lower(name) ASC, length(name) ASC') + # Fetches only actual (last publised) packages. scope :actual, where(:actual => true) scope :by_platform, lambda {|platform| where(:platform_id => platform) } From c969d82c9433c927cb24b6c9fccc281f865418a0 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 19:06:31 +0600 Subject: [PATCH 28/48] fix ru translate --- config/locales/title.ru.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/title.ru.yml b/config/locales/title.ru.yml index cbb65e5ca..736eb83c9 100644 --- a/config/locales/title.ru.yml +++ b/config/locales/title.ru.yml @@ -1,7 +1,7 @@ ru: title_editing: 'Редактирование' - at: at + at: в users: settings: profile: From 76606036cba24ff570a50f3b44c32c06b234f9f1 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 19:15:15 +0600 Subject: [PATCH 29/48] [refs #737] remove branch from commit message --- .../git_presenters/commit_as_message_presenter.rb | 7 ++----- app/views/projects/base/_layout.html.haml | 2 +- app/views/projects/git/blobs/blame.html.haml | 2 +- app/views/projects/git/commits/_commits.html.haml | 2 +- app/views/projects/git/commits/_commits_small.html.haml | 2 +- app/views/projects/git/commits/show.html.haml | 2 +- config/locales/layout/messages.en.yml | 1 - config/locales/layout/messages.ru.yml | 1 - 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/presenters/git_presenters/commit_as_message_presenter.rb b/app/presenters/git_presenters/commit_as_message_presenter.rb index 54933746c..1d2604f55 100644 --- a/app/presenters/git_presenters/commit_as_message_presenter.rb +++ b/app/presenters/git_presenters/commit_as_message_presenter.rb @@ -7,15 +7,12 @@ class GitPresenters::CommitAsMessagePresenter < ApplicationPresenter def initialize(commit, opts = {}) @commit = commit - @options = opts#[:branch] if opts[:branch] + @options = opts prepare_message end def header - @header ||= if options[:branch].present? - I18n.t("layout.messages.commits.header_with_branch", - :committer => committer_link, :commit => commit_link, :branch => options[:branch].name) - elsif options[:project].present? + @header ||= if options[:project].present? I18n.t("layout.messages.commits.header", :committer => committer_link, :commit => commit_link, :project => options[:project].name) end.html_safe diff --git a/app/views/projects/base/_layout.html.haml b/app/views/projects/base/_layout.html.haml index bfcce95bb..601a41b28 100644 --- a/app/views/projects/base/_layout.html.haml +++ b/app/views/projects/base/_layout.html.haml @@ -3,7 +3,7 @@ = render 'about_block', :project => @project %h3= t("layout.projects.last_commit") -- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| +- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter| = render 'shared/feed_message', :presenter => presenter, :item_no => 1 .both diff --git a/app/views/projects/git/blobs/blame.html.haml b/app/views/projects/git/blobs/blame.html.haml index 75d54a250..eadbf22c8 100644 --- a/app/views/projects/git/blobs/blame.html.haml +++ b/app/views/projects/git/blobs/blame.html.haml @@ -5,7 +5,7 @@ %h3= t("layout.projects.last_commit") -- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| +- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter| = render 'shared/feed_message', :presenter => presenter, :item_no => 1 .both diff --git a/app/views/projects/git/commits/_commits.html.haml b/app/views/projects/git/commits/_commits.html.haml index cb79b9ffa..e815935a7 100644 --- a/app/views/projects/git/commits/_commits.html.haml +++ b/app/views/projects/git/commits/_commits.html.haml @@ -12,7 +12,7 @@ .date= raw l(commits.first.authored_date, :format => :date_block_format) .messages - commits.each_with_index do |commit| - - GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter| + - GitPresenters::CommitAsMessagePresenter.present(commit, :project => @project) do |presenter| = render 'shared/feed_message', :presenter => presenter, :item_no => counter - counter += 1 .both diff --git a/app/views/projects/git/commits/_commits_small.html.haml b/app/views/projects/git/commits/_commits_small.html.haml index 528f9b3ff..3302753fb 100644 --- a/app/views/projects/git/commits/_commits_small.html.haml +++ b/app/views/projects/git/commits/_commits_small.html.haml @@ -3,7 +3,7 @@ %tbody - commits.each do |commit| - item_no = commit.id - - GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter| + - GitPresenters::CommitAsMessagePresenter.present(commit, :project => @project) do |presenter| %tr %td %img{:height => 16, :alt => "avatar", :src => presenter.image} diff --git a/app/views/projects/git/commits/show.html.haml b/app/views/projects/git/commits/show.html.haml index 7da6e3afb..70a7e3efe 100644 --- a/app/views/projects/git/commits/show.html.haml +++ b/app/views/projects/git/commits/show.html.haml @@ -3,7 +3,7 @@ = render 'about_block', :project => @project %h3= t("layout.projects.last_commit") -- GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| +- GitPresenters::CommitAsMessagePresenter.present(@commit, :project => @project) do |presenter| = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1} .both diff --git a/config/locales/layout/messages.en.yml b/config/locales/layout/messages.en.yml index e0a3b3b3a..d17e6bac3 100644 --- a/config/locales/layout/messages.en.yml +++ b/config/locales/layout/messages.en.yml @@ -2,5 +2,4 @@ en: layout: messages: commits: - header_with_branch: "%{committer} has added %{commit} into %{branch} branch" header: "%{committer} has added %{commit}" diff --git a/config/locales/layout/messages.ru.yml b/config/locales/layout/messages.ru.yml index 8e02db73b..77f43d4f5 100644 --- a/config/locales/layout/messages.ru.yml +++ b/config/locales/layout/messages.ru.yml @@ -2,5 +2,4 @@ ru: layout: messages: commits: - header_with_branch: "%{committer} добавил коммит %{commit} в ветку %{branch}" header: "%{committer} добавил коммит %{commit}" From 663db6e7ff705572154e665a4c2b9fce58ba3ad3 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 20:43:38 +0600 Subject: [PATCH 30/48] [refs #733] add check for correct answer --- app/controllers/api/v1/build_lists_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index d2c4f947e..837a1a6e9 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -52,7 +52,9 @@ class Api::V1::BuildListsController < Api::V1::BaseController private def render_json(action_name) - if @build_list.send(action_name) + if !@build_list.send "can_#{action_name}?" + render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => "Incorrect action for current status"} + elsif @build_list.send(action_name) render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")} else render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")} From b8e6903faa40521bf04cddd58d052ac99170de7f Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 20:52:11 +0600 Subject: [PATCH 31/48] [refs #733] small refactoring --- .../api/v1/build_lists_controller.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index 837a1a6e9..ff3697ec5 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -52,13 +52,14 @@ class Api::V1::BuildListsController < Api::V1::BaseController private def render_json(action_name) - if !@build_list.send "can_#{action_name}?" - render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => "Incorrect action for current status"} - elsif @build_list.send(action_name) - render :json => {:"is_#{action_name}ed" => true, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_success")} - else - render :json => {:"is_#{action_name}ed" => false, :url => api_v1_build_list_path(@build_list, :format => :json), :message => t("layout.build_lists.#{action_name}_fail")} - end - end + res, message = if !@build_list.send "can_#{action_name}?" + [false, "Incorrect action for current status"] + elsif @build_list.send(action_name) + [true, t("layout.build_lists.#{action_name}_success")] + else + [false, t("layout.build_lists.#{action_name}_fail")] + end + render :json => {:"is_#{action_name}ed" => res, :url => api_v1_build_list_path(@build_list, :format => :json), :message => message} + end end From efd29455085932696d69bf3d3b92a086fa212806 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 21:29:34 +0600 Subject: [PATCH 32/48] [refs #733] change error message --- app/controllers/api/v1/build_lists_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index ff3697ec5..b41459394 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -53,7 +53,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController def render_json(action_name) res, message = if !@build_list.send "can_#{action_name}?" - [false, "Incorrect action for current status"] + [false, "Incorrect action for current build list"] elsif @build_list.send(action_name) [true, t("layout.build_lists.#{action_name}_success")] else From 8ca41377fcc41c8c645fe59cc47025644e33f689 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 28 Nov 2012 23:25:28 +0600 Subject: [PATCH 33/48] [refs #736] add git url --- app/views/api/v1/projects/_project.json.jbuilder | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/api/v1/projects/_project.json.jbuilder b/app/views/api/v1/projects/_project.json.jbuilder index a84d904f9..0a56ecc58 100644 --- a/app/views/api/v1/projects/_project.json.jbuilder +++ b/app/views/api/v1/projects/_project.json.jbuilder @@ -1,3 +1,4 @@ json.(project, :id, :name) json.fullname project.name_with_owner -json.url api_v1_project_path(project.id, :format => :json) \ No newline at end of file +json.url api_v1_project_path(project.id, :format => :json) +json.git_url git_repo_url(project.git_repo_name) From 5899d5f28f858327248570ac65d5cece74454093 Mon Sep 17 00:00:00 2001 From: vladdruzh Date: Thu, 29 Nov 2012 09:32:10 +0400 Subject: [PATCH 34/48] add filters to maintainers list api --- app/controllers/api/v1/maintainers_controller.rb | 5 ++++- app/controllers/platforms/maintainers_controller.rb | 2 +- app/models/build_list/package.rb | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index 625a63134..a85203e4b 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -5,6 +5,9 @@ class Api::V1::MaintainersController < Api::V1::BaseController def index @maintainers = BuildList::Package.actual.by_platform(@platform) .includes(:project) - .paginate(paginate_params) + if name = params[:filter].try(:[], :package_name) + @maintainers = @maintainers.like_name(name) + end + @maintainers = @maintainers.paginate(paginate_params) end end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 5c3e49a84..10e200aa3 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -7,7 +7,7 @@ class Platforms::MaintainersController < ApplicationController def index @maintainers = BuildList::Package.actual.by_platform(@platform) .includes(:project) - @maintainers = @maintainers.where('name ILIKE ?', "%#{params[:q]}%") if params[:q].present? + @maintainers = @maintainers.like_name(params[:q]) if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) end diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 6a3dcb79c..108f9ea4e 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -19,6 +19,7 @@ class BuildList::Package < ActiveRecord::Base scope :by_platform, lambda {|platform| where(:platform_id => platform) } scope :by_name, lambda {|name| where(:name => name) } scope :by_package_type, lambda {|type| where(:package_type => type) } + scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%")} def assignee project.maintainer From 791f77dfd59912767bcf9cfdac652f3db0116b26 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 29 Nov 2012 19:12:24 +0400 Subject: [PATCH 35/48] add 'New core' option for creating build_list --- .../projects/build_lists_controller.rb | 2 ++ app/models/build_list.rb | 21 ++++++++++++++----- app/views/projects/build_lists/new.html.haml | 4 ++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index ca44ce0ec..b9dc291e5 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -61,6 +61,8 @@ class Projects::BuildListsController < Projects::BaseController @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_list.new_core = current_user.admin? && params[:build_list][:new_core] == '1' + flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name} if @build_list.save notices << t("flash.build_list.saved", flash_options) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 69fabf2d1..b92b3a6e9 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -117,6 +117,8 @@ class BuildList < ActiveRecord::Base after_commit :place_build after_destroy :delete_container + attr_accessor :new_core + @queue = :clone_and_build state_machine :status, :initial => :waiting_for_response do @@ -242,8 +244,7 @@ class BuildList < ActiveRecord::Base can_publish? and not save_to_repository.publish_without_qa end - - def add_to_queue + def add_to_abf_worker_queue include_repos_hash = {}.tap do |h| include_repos.each do |r| repo = Repository.find r @@ -260,7 +261,9 @@ class BuildList < ActiveRecord::Base :commit_hash => '9272c173c517178b5c039c4b196c719b472147a7', # :commit_hash => commit_hash, :build_requires => build_requires, - :include_repos => include_repos_hash + :include_repos => include_repos_hash, + :bplname => build_for_platform.name + # :project_version => project_version, @@ -277,8 +280,16 @@ class BuildList < ActiveRecord::Base ) end @status ||= BUILD_PENDING - #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address - # @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address + end + + def add_to_queue + if new_core? + add_to_abf_worker_queue + else + #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address + @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address + end + @status end def self.human_status(status) diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 6a0c3fad6..26c7425bc 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -29,6 +29,10 @@ .both = f.check_box :build_requires = f.label :build_requires + - if current_user.admin? + .both + = f.check_box :new_core + = f.label :new_core %br = f.submit t("layout.projects.build_button") From 364e5d9b676a4f718e1ac736c3d550c1b61d2ebc Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Thu, 29 Nov 2012 23:52:15 +0600 Subject: [PATCH 36/48] [refs #736] add to api build lists of the project --- app/controllers/api/v1/build_lists_controller.rb | 2 +- config/routes.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index b41459394..91e8ce058 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -8,7 +8,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController load_and_authorize_resource :build_list, :only => [:show, :create, :cancel, :publish, :reject_publish] def index - filter = BuildList::Filter.new(nil, current_user, params[:filter] || {}) + filter = BuildList::Filter.new(@project, current_user, params[:filter] || {}) @build_lists = filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch]) @build_lists = @build_lists.recent.paginate(paginate_params) end diff --git a/config/routes.rb b/config/routes.rb index b57307f1b..a3a65c2a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,7 @@ Rosa::Application.routes.draw do delete :remove_member put :update_member } + resources :build_lists, :only => :index end resources :users, :only => [:show] get 'user' => 'users#show_current_user' From a5daff3442c6cea91988e9c7d05ed71ebee6dc9f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 29 Nov 2012 21:56:03 +0400 Subject: [PATCH 37/48] update getting logs, some repo generation --- .../projects/build_lists_controller.rb | 5 ++- app/models/build_list.rb | 42 ++++++++++++++----- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index b9dc291e5..36f5c573b 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -55,13 +55,14 @@ class Projects::BuildListsController < Projects::BaseController build_for_platforms = Repository.select(:platform_id). where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id) + new_core = current_user.admin? && params[:build_list][:new_core] == '1' 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_list.new_core = current_user.admin? && params[:build_list][:new_core] == '1' + @build_list.new_core = new_core flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name} if @build_list.save @@ -107,7 +108,7 @@ class Projects::BuildListsController < Projects::BaseController def log render :json => { - :log => @build_list.log, + :log => @build_list.log(params[:load_lines]), :building => @build_list.build_started? } # @log = `tail -n #{params[:load_lines].to_i} #{Rails.root + 'public' + @build_list.fs_log_path}` diff --git a/app/models/build_list.rb b/app/models/build_list.rb index b92b3a6e9..1798a6bbd 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -248,24 +248,41 @@ class BuildList < ActiveRecord::Base include_repos_hash = {}.tap do |h| include_repos.each do |r| repo = Repository.find r - h[repo.name] = repo.platform.public_downloads_url(nil, arch.name, repo.name) + # /release + # /updates + path = repo.platform.public_downloads_url(nil, arch.name, repo.name) + h["#{repo.name}_release"] = path + 'release' + h["#{repo.name}_updates"] = path + 'updates' end end + # include_repos_hash = { + # 'main_release' => 'http://mirror.rosalinux.com/rosa/rosa2012lts/repository/x86_64/main/release', + # 'main_updates' => 'http://mirror.rosalinux.com/rosa/rosa2012lts/repository/x86_64/main/updates' + # # 'main_release' => 'http://mirror.rosalinux.com/rosa/rosa2012.1/repository/x86_64/main', + # # 'main_updates' => 'http://mirror.rosalinux.com/rosa/rosa2012.1/repository/x86_64/main' + # # 'base' => 'http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os' + # } options = { :id => id, :arch => arch.name, :time_living => 2880, # 2 days :distrib_type => build_for_platform.distrib_type, - :git_project_address => 'https://abf.rosalinux.ru/import/qtiplot.git', - # :git_project_address => project.git_project_address, - :commit_hash => '9272c173c517178b5c039c4b196c719b472147a7', - # :commit_hash => commit_hash, + + # mdv example: + # https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git + # bfe6d68cc607238011a6108014bdcfe86c69456a + + # rhel example: + # https://abf.rosalinux.ru/server/gnome-settings-daemon.git + # fbb2549e44d97226fea6748a4f95d1d82ffb8726 + + # :git_project_address => 'https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git', + :git_project_address => project.git_project_address, + # :commit_hash => 'bfe6d68cc607238011a6108014bdcfe86c69456a', + :commit_hash => commit_hash, :build_requires => build_requires, :include_repos => include_repos_hash, :bplname => build_for_platform.name - - - # :project_version => project_version, # :plname => save_to_platform.name, # :bplname => (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), @@ -283,7 +300,7 @@ class BuildList < ActiveRecord::Base end def add_to_queue - if new_core? + if @new_core add_to_abf_worker_queue else #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address @@ -359,8 +376,11 @@ class BuildList < ActiveRecord::Base status == BUILD_PUBLISHED end - def log - Resque.redis.get("abfworker::rpm-worker-#{id}") || '' + def log(load_lines) + log = Resque.redis.get("abfworker::rpm-worker-#{id}") + log ||= `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}` + log = t("layout.build_lists.log.not_available") unless $?.success? + log end protected From b468f0655f01be5b2bc75a8a43088a8befae0002 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 29 Nov 2012 23:42:54 +0400 Subject: [PATCH 38/48] some refactoring of #log method --- app/models/build_list.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 1798a6bbd..b1aa9a576 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -378,9 +378,11 @@ class BuildList < ActiveRecord::Base def log(load_lines) log = Resque.redis.get("abfworker::rpm-worker-#{id}") - log ||= `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}` - log = t("layout.build_lists.log.not_available") unless $?.success? - log + unless log + log = `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}` + log = nil unless $?.success? + end + log || t("layout.build_lists.log.not_available") end protected From fcdbfd45389b69c64eeb02be2161fd863d67c621 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 14:41:39 +0400 Subject: [PATCH 39/48] add new column to build_lists table, some refactoring --- app/controllers/projects/build_lists_controller.rb | 6 ------ app/models/build_list.rb | 9 ++++----- app/views/projects/build_lists/show.html.haml | 9 ++++++--- config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + db/migrate/20121127122032_add_results_to_build_list.rb | 1 + db/schema.rb | 1 + 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 36f5c573b..14338d3fa 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -111,12 +111,6 @@ class Projects::BuildListsController < Projects::BaseController :log => @build_list.log(params[:load_lines]), :building => @build_list.build_started? } - # @log = `tail -n #{params[:load_lines].to_i} #{Rails.root + 'public' + @build_list.fs_log_path}` - # @log = t("layout.build_lists.log.not_available") unless $?.success? - - # respond_to do |format| - # format.json { render :json => { :log => @log, :building => @build_list.build_started? } } - # end end def publish_build diff --git a/app/models/build_list.rb b/app/models/build_list.rb index b1aa9a576..0c16a9a93 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -117,8 +117,6 @@ class BuildList < ActiveRecord::Base after_commit :place_build after_destroy :delete_container - attr_accessor :new_core - @queue = :clone_and_build state_machine :status, :initial => :waiting_for_response do @@ -300,7 +298,7 @@ class BuildList < ActiveRecord::Base end def add_to_queue - if @new_core + if new_core? add_to_abf_worker_queue else #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address @@ -377,8 +375,9 @@ class BuildList < ActiveRecord::Base end def log(load_lines) - log = Resque.redis.get("abfworker::rpm-worker-#{id}") - unless log + if new_core? + log = Resque.redis.get("abfworker::rpm-worker-#{id}") + else log = `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}` log = nil unless $?.success? end diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 3dc935547..3f5236029 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -59,6 +59,9 @@ .leftlist= t("activerecord.attributes.build_list.is_circle") .rightlist= t("layout.#{@build_list.is_circle?}_") .both + .leftlist= t("activerecord.attributes.build_list.new_core") + .rightlist= t("layout.#{@build_list.new_core?}_") + .both - if @build_list.mass_build_id.present? .leftlist= t("activerecord.attributes.mass_build_id") @@ -124,9 +127,9 @@ var r = new Rosa.Routers.BuildListsAdvisoriesRouter(); }); - - if BuildList::HUMAN_STATUSES[@build_list.status].in? [:build_started, :build_error] - = render 'shared/log', { :build_started => @build_list.build_started?, :get_log_path => log_build_list_path(@build_list) } - + - if BuildList::HUMAN_STATUSES[@build_list.status].in? [:build_started, :build_error, :success] + - log_params = { :build_started => @build_list.build_started?, :get_log_path => log_build_list_path(@build_list) } + = render 'shared/log', ( @build_list.new_core? ? log_params : log_params.merge({:download_log_url => build_list_log_url(:build)}) ) - if (can_publish = @build_list.can_publish? && can?(:publish, @build_list)) .hr diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 5f9a1e18a..8d381f75b 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -13,6 +13,7 @@ en: project: Project arch_id: Architecture arch: Architecture + new_core: New core is_circle: Recurrent build updated_at: Notified at additional_repos: Additional repositories diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index f154a7803..a04a52864 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -13,6 +13,7 @@ ru: project: Проект arch_id: Архитектура arch: Архитектура + new_core: Новое ядро is_circle: Циклическая сборка updated_at: Информация получена additional_repos: Дополнительные репозитории diff --git a/db/migrate/20121127122032_add_results_to_build_list.rb b/db/migrate/20121127122032_add_results_to_build_list.rb index 0bee2f39e..dbc8fabfe 100644 --- a/db/migrate/20121127122032_add_results_to_build_list.rb +++ b/db/migrate/20121127122032_add_results_to_build_list.rb @@ -1,5 +1,6 @@ class AddResultsToBuildList < ActiveRecord::Migration def change add_column :build_lists, :results, :text + add_column :build_lists, :new_core, :boolean end end diff --git a/db/schema.rb b/db/schema.rb index b40e02f98..99e93f409 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -131,6 +131,7 @@ ActiveRecord::Schema.define(:version => 20121127122032) do t.integer "mass_build_id" t.integer "save_to_repository_id" t.text "results" + t.boolean "new_core" end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" From bc1ab2f8aaa6c682802a8db7ea64303f63503ac2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 14:55:14 +0400 Subject: [PATCH 40/48] show results-table only for BuildList with new_core --- app/views/projects/build_lists/show.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 3f5236029..e4cf69a9c 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -176,7 +176,8 @@ %td= package.release .both -= render 'platforms/product_build_lists/results', :pbl => @build_list +- if @build_list.new_core? + = render 'platforms/product_build_lists/results', :pbl => @build_list :javascript $('article .all').addClass('bigpadding'); From 1af7b7525ffc6bf826ad643c4868ffe242715446 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 15:19:55 +0400 Subject: [PATCH 41/48] remove some comments --- app/models/build_list.rb | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 0c16a9a93..091a4a952 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -249,34 +249,27 @@ class BuildList < ActiveRecord::Base # /release # /updates path = repo.platform.public_downloads_url(nil, arch.name, repo.name) + # path = path.gsub(/^http:\/\/0\.0\.0\.0\:3000/, 'https://abf.rosalinux.ru') h["#{repo.name}_release"] = path + 'release' h["#{repo.name}_updates"] = path + 'updates' end end - # include_repos_hash = { - # 'main_release' => 'http://mirror.rosalinux.com/rosa/rosa2012lts/repository/x86_64/main/release', - # 'main_updates' => 'http://mirror.rosalinux.com/rosa/rosa2012lts/repository/x86_64/main/updates' - # # 'main_release' => 'http://mirror.rosalinux.com/rosa/rosa2012.1/repository/x86_64/main', - # # 'main_updates' => 'http://mirror.rosalinux.com/rosa/rosa2012.1/repository/x86_64/main' - # # 'base' => 'http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os' - # } + # mdv example: + # https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git + # bfe6d68cc607238011a6108014bdcfe86c69456a + + # rhel example: + # https://abf.rosalinux.ru/server/gnome-settings-daemon.git + # fbb2549e44d97226fea6748a4f95d1d82ffb8726 + options = { :id => id, :arch => arch.name, :time_living => 2880, # 2 days :distrib_type => build_for_platform.distrib_type, - - # mdv example: - # https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git - # bfe6d68cc607238011a6108014bdcfe86c69456a - - # rhel example: - # https://abf.rosalinux.ru/server/gnome-settings-daemon.git - # fbb2549e44d97226fea6748a4f95d1d82ffb8726 - - # :git_project_address => 'https://abf.rosalinux.ru/import/plasma-applet-stackfolder.git', + # :git_project_address => 'https://abf.rosalinux.ru/server/gnome-settings-daemon.git', :git_project_address => project.git_project_address, - # :commit_hash => 'bfe6d68cc607238011a6108014bdcfe86c69456a', + # :commit_hash => 'fbb2549e44d97226fea6748a4f95d1d82ffb8726', :commit_hash => commit_hash, :build_requires => build_requires, :include_repos => include_repos_hash, From ace131209568c1a29ad0f453a7542c8f0655275f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 15:34:08 +0400 Subject: [PATCH 42/48] hot fix --- app/models/build_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 091a4a952..bcfaa8dcd 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -374,7 +374,7 @@ class BuildList < ActiveRecord::Base log = `tail -n #{load_lines.to_i} #{Rails.root + 'public' + fs_log_path}` log = nil unless $?.success? end - log || t("layout.build_lists.log.not_available") + log || I18n.t('layout.build_lists.log.not_available') end protected From 46d465536f02b18237c80eb3a15f3cfd46efa171 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 17:10:17 +0400 Subject: [PATCH 43/48] some refactoring, add comments --- app/models/build_list.rb | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index bcfaa8dcd..9b6e61826 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -246,10 +246,13 @@ class BuildList < ActiveRecord::Base include_repos_hash = {}.tap do |h| include_repos.each do |r| repo = Repository.find r - # /release - # /updates path = repo.platform.public_downloads_url(nil, arch.name, repo.name) # path = path.gsub(/^http:\/\/0\.0\.0\.0\:3000/, 'https://abf.rosalinux.ru') + # Path looks like: + # http://abf.rosalinux.ru/downloads/rosa-server2012/repository/x86_64/base/ + # so, we should append: + # /release + # /updates h["#{repo.name}_release"] = path + 'release' h["#{repo.name}_updates"] = path + 'updates' end @@ -294,8 +297,31 @@ class BuildList < ActiveRecord::Base if new_core? add_to_abf_worker_queue else - #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority, git_project_address - @status ||= BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority, project.git_project_address + # XML-RPC params: + # - project_name + # - project_version + # - plname + # - arch + # - bplname + # - update_type + # - build_requires + # - id_web + # - include_repos + # - priority + # - git_project_address + @status ||= BuildServer.add_build_list( + project.name, + project_version, + save_to_platform.name, + arch.name, + (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), + update_type, + build_requires, + id, + include_repos, + priority, + project.git_project_address + ) end @status end @@ -364,7 +390,7 @@ class BuildList < ActiveRecord::Base !save_to_repository.publish_without_qa && save_to_platform.main? && save_to_platform.released && - status == BUILD_PUBLISHED + build_published? end def log(load_lines) From 5c3514ec0f339ca12c6261ae6fd9a516522927c8 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 30 Nov 2012 17:59:21 +0400 Subject: [PATCH 44/48] add rpm_worker_observer to resque --- lib/recipes/resque.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/recipes/resque.rb b/lib/recipes/resque.rb index b176df9b8..19bb7d23a 100644 --- a/lib/recipes/resque.rb +++ b/lib/recipes/resque.rb @@ -26,7 +26,7 @@ Capistrano::Configuration.instance(:must_exist).load do end def start_workers - run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" + run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=fork_import,hook,clone_build,notification,iso_worker_observer,rpm_worker_observer #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" end end end From bfa538e644405861cbec5558d3ee4a23d8ab06e3 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 30 Nov 2012 23:15:37 +0600 Subject: [PATCH 45/48] [refs #732] small refactoring --- app/controllers/api/v1/maintainers_controller.rb | 10 ++++------ app/controllers/platforms/maintainers_controller.rb | 9 ++++----- app/models/build_list/package.rb | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index a85203e4b..cda1761f1 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -3,11 +3,9 @@ class Api::V1::MaintainersController < Api::V1::BaseController load_and_authorize_resource :platform def index - @maintainers = BuildList::Package.actual.by_platform(@platform) - .includes(:project) - if name = params[:filter].try(:[], :package_name) - @maintainers = @maintainers.like_name(name) - end - @maintainers = @maintainers.paginate(paginate_params) + @maintainers = BuildList::Package.includes(:project) + .actual.by_platform(@platform) + .like_name(params[:filter].try(:[], :package_name)) + .paginate(paginate_params) end end diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 10e200aa3..9abd417de 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -5,10 +5,9 @@ class Platforms::MaintainersController < ApplicationController load_and_authorize_resource :platform def index - @maintainers = BuildList::Package.actual.by_platform(@platform) - .includes(:project) - @maintainers = @maintainers.like_name(params[:q]) if params[:q].present? - @maintainers = @maintainers.paginate(:page => params[:page]) + @maintainers = BuildList::Package.includes(:project) + .actual.by_platform(@platform) + .like_name(params[:q]) + .paginate(:page => params[:page]) end - end diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 108f9ea4e..891fe239b 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -19,7 +19,7 @@ class BuildList::Package < ActiveRecord::Base scope :by_platform, lambda {|platform| where(:platform_id => platform) } scope :by_name, lambda {|name| where(:name => name) } scope :by_package_type, lambda {|type| where(:package_type => type) } - scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%")} + scope :like_name, lambda {|name| where('name ILIKE ?', "%#{name}%") if name.present?} def assignee project.maintainer From cb8b54c6df68f8366e5f487c5b3130d6b36de252 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 30 Nov 2012 23:16:05 +0600 Subject: [PATCH 46/48] [refs #732] fix index test --- spec/controllers/api/v1/maintainers_controller_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/controllers/api/v1/maintainers_controller_spec.rb b/spec/controllers/api/v1/maintainers_controller_spec.rb index 15493e1c2..e98420f20 100644 --- a/spec/controllers/api/v1/maintainers_controller_spec.rb +++ b/spec/controllers/api/v1/maintainers_controller_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe Api::V1::MaintainersController do + before do + stub_symlink_methods + end + let(:package) { FactoryGirl.create(:build_list_package) } context 'for guest' do From 1b8ac5667f5d035944fae8f0e5b6ee73f657e82a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sat, 1 Dec 2012 00:33:19 +0600 Subject: [PATCH 47/48] [refs #732] fix index test forgotten --- spec/controllers/api/v1/maintainers_controller_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/controllers/api/v1/maintainers_controller_spec.rb b/spec/controllers/api/v1/maintainers_controller_spec.rb index e98420f20..837539ec9 100644 --- a/spec/controllers/api/v1/maintainers_controller_spec.rb +++ b/spec/controllers/api/v1/maintainers_controller_spec.rb @@ -21,7 +21,6 @@ describe Api::V1::MaintainersController do context 'for simple user' do before do - stub_symlink_methods http_login(FactoryGirl.create(:user)) end From ee73df5d3a660af5f0ccb2d372dda89957213007 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 3 Dec 2012 15:28:27 +0400 Subject: [PATCH 48/48] disable auto_publish for new_core, some refactoring --- .../projects/build_lists_controller.rb | 1 + app/views/projects/build_lists/show.html.haml | 74 +++++++++---------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 14338d3fa..b9131fe95 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -56,6 +56,7 @@ class Projects::BuildListsController < Projects::BaseController where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id) new_core = current_user.admin? && params[:build_list][:new_core] == '1' + params[:build_list][:auto_publish] = false if new_core 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]) diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index e4cf69a9c..7ab528944 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -131,53 +131,53 @@ - log_params = { :build_started => @build_list.build_started?, :get_log_path => log_build_list_path(@build_list) } = render 'shared/log', ( @build_list.new_core? ? log_params : log_params.merge({:download_log_url => build_list_log_url(:build)}) ) - - if (can_publish = @build_list.can_publish? && can?(:publish, @build_list)) + - if (can_publish = @build_list.can_publish? && can?(:publish, @build_list) && !@build_list.new_core?) .hr = submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' if can_publish - if @build_list.can_reject_publish? && can?(:reject_publish, @build_list) = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' .hr -%h3= t("layout.build_lists.items_header") -- if @item_groups.blank? - %h4.nomargin= t("layout.build_lists.no_items_data") -- @item_groups.each_with_index do |group, level| - - group.each do |item| - %h4.nomargin= "#{item.name} ##{level}" +- if @build_list.new_core? + = render 'platforms/product_build_lists/results', :pbl => @build_list +- else + %h3= t("layout.build_lists.items_header") + - if @item_groups.blank? + %h4.nomargin= t("layout.build_lists.no_items_data") + - @item_groups.each_with_index do |group, level| + - group.each do |item| + %h4.nomargin= "#{item.name} ##{level}" + %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} + %thead + %tr + %th= t("activerecord.attributes.build_list/item.name") + %th= t("activerecord.attributes.build_list/item.version") + %th= t("activerecord.attributes.build_list/item.status") + %tbody + %tr{:class => build_list_item_status_color(item.status)} + %td= item.name + %td= item.version + %td= item.human_status + .both + + - if @build_list.packages.present? + .hr + %h3= t("layout.build_lists.packages_header") %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} %thead %tr - %th= t("activerecord.attributes.build_list/item.name") - %th= t("activerecord.attributes.build_list/item.version") - %th= t("activerecord.attributes.build_list/item.status") + %th= t("activerecord.attributes.build_list/package.fullname") + %th= t("activerecord.attributes.build_list/package.name") + %th= t("activerecord.attributes.build_list/package.version") + %th= t("activerecord.attributes.build_list/package.release") %tbody - %tr{:class => build_list_item_status_color(item.status)} - %td= item.name - %td= item.version - %td= item.human_status -.both - -- if @build_list.packages.present? - .hr - %h3= t("layout.build_lists.packages_header") - %table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"} - %thead - %tr - %th= t("activerecord.attributes.build_list/package.fullname") - %th= t("activerecord.attributes.build_list/package.name") - %th= t("activerecord.attributes.build_list/package.version") - %th= t("activerecord.attributes.build_list/package.release") - %tbody - - @build_list.packages.each do |package| - %tr - %td= package.fullname - %td= package.name - %td= package.version - %td= package.release - .both - -- if @build_list.new_core? - = render 'platforms/product_build_lists/results', :pbl => @build_list + - @build_list.packages.each do |package| + %tr + %td= package.fullname + %td= package.name + %td= package.version + %td= package.release + .both :javascript $('article .all').addClass('bigpadding');