Merge branch 'master' into 921-task-monitoring
Conflicts: app/assets/javascripts/extra/build_list.js
This commit is contained in:
commit
3dda72a0ac
|
@ -12,9 +12,11 @@ $(document).ready(function() {
|
|||
var use_save_to_repository = $('#build_list_use_save_to_repository');
|
||||
|
||||
if (build_platform.size() == 0) {
|
||||
$('#extra-repos-and-containers').slideDown();
|
||||
all_repositories.removeAttr('disabled');
|
||||
use_save_to_repository.removeAttr('disabled');
|
||||
} else {
|
||||
$('#extra-repos-and-containers').slideUp();
|
||||
use_save_to_repository.attr('disabled', 'disabled').attr('checked', 'checked');
|
||||
all_repositories.attr('disabled', 'disabled');
|
||||
var parent = build_platform.parent();
|
||||
|
@ -35,6 +37,21 @@ $(document).ready(function() {
|
|||
|
||||
$('#build_list_save_to_repository_id').trigger('change');
|
||||
|
||||
$('#extra-repos-and-containers #add').click(function() {
|
||||
var id = $('#extra_repo_field').val();
|
||||
if (id.length > 0) {
|
||||
$.get("/build_lists/add_extra_repos_and_containers", { extra_id: id })
|
||||
.done(function(data) {
|
||||
$("#extra-repos-and-containers table tbody").append(data);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '#extra-repos-and-containers .delete', function() {
|
||||
$(this)[0].parentElement.parentElement.remove();
|
||||
});
|
||||
|
||||
function setBranchSelected(selected_option) {
|
||||
var pl_name = selected_option.text().match(/([\w-.]+)\/[\w-.]+/)[1];
|
||||
var bl_version_sel = $('#build_list_project_version');
|
||||
|
|
|
@ -1767,21 +1767,7 @@ table#myTable thead tr.search th form.button_to div input {
|
|||
border: 1px solid #DDDDDD;
|
||||
}
|
||||
|
||||
table.tablesorter {
|
||||
th.lpadding6 {
|
||||
padding-left: 6px;
|
||||
}
|
||||
|
||||
td a {
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
div.right.slim {
|
||||
padding-right: 5px;
|
||||
width: 705px;
|
||||
|
||||
table.tablesorter {
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
#extra-repos-and-containers {
|
||||
width: 330px;
|
||||
.actions { width: 15px; }
|
||||
}
|
|
@ -114,6 +114,33 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
}
|
||||
end
|
||||
|
||||
def autocomplete_to_extra_repos_and_containers
|
||||
platforms = Platform.includes(:repositories).search(params[:term]).
|
||||
accessible_by(current_ability, :read).search_order.limit(5)
|
||||
results = []
|
||||
platforms.each{ |p| p.repositories.each{ |r| results << {:id => r.id, :label => "#{p.name}/#{r.name}", :value => "#{p.name}/#{r.name}"} } }
|
||||
|
||||
bl = BuildList.where(:id => params[:term]).published_container.
|
||||
accessible_by(current_ability, :read).first
|
||||
results << {:id => "#{bl.id}-build-list", :value => bl.id, :label => "#{bl.id} (#{bl.project.name} - #{bl.arch.name})"} if bl
|
||||
render json: results.to_json
|
||||
end
|
||||
|
||||
def add_extra_repos_and_containers
|
||||
if params[:extra_id] =~ /-build-list$/
|
||||
id = params[:extra_id].gsub(/-build-list$/, '')
|
||||
subject = BuildList.where(:id => id).published_container
|
||||
else
|
||||
subject = Repository.where(:id => params[:extra_id])
|
||||
end
|
||||
subject = subject.accessible_by(current_ability, :read).first
|
||||
if subject
|
||||
render :partial => 'extra', :locals => {:subject => subject}
|
||||
else
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_build_list
|
||||
|
|
|
@ -77,11 +77,11 @@ module BuildListsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def container_url(full_path = true)
|
||||
def container_url(full_path = true, build_list = @build_list)
|
||||
p = ''
|
||||
p << "http://#{request.host_with_port}" if full_path
|
||||
p << "/downloads/#{@build_list.save_to_platform.name}/container/#{@build_list.id}"
|
||||
p << "/#{@build_list.arch.name}/#{@build_list.save_to_repository.name}/release" if full_path && @build_list.build_for_platform.distrib_type == 'mdv'
|
||||
p << "/downloads/#{build_list.save_to_platform.name}/container/#{build_list.id}"
|
||||
p << "/#{build_list.arch.name}/#{build_list.save_to_repository.name}/release" if full_path && build_list.build_for_platform.distrib_type == 'mdv'
|
||||
p.html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -42,12 +42,16 @@ class BuildList < ActiveRecord::Base
|
|||
validate lambda {
|
||||
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
|
||||
}
|
||||
validate :check_extra_repositories, :on => :create
|
||||
validate :check_extra_containers, :on => :create
|
||||
before_validation :prepare_extra_repositories_and_containers, :on => :create
|
||||
|
||||
before_create :use_save_to_repository_for_main_platforms
|
||||
|
||||
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
|
||||
:arch_id, :project_id, :save_to_repository_id, :update_type,
|
||||
:save_to_platform_id, :project_version, :use_save_to_repository
|
||||
:save_to_platform_id, :project_version, :use_save_to_repository,
|
||||
:auto_create_container, :extra_repositories, :extra_containers
|
||||
LIVE_TIME = 4.week # for unpublished
|
||||
MAX_LIVE_TIME = 3.month # for published
|
||||
|
||||
|
@ -123,10 +127,13 @@ class BuildList < ActiveRecord::Base
|
|||
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
|
||||
scope :scoped_to_new_core, lambda {|new_core| where(:new_core => new_core)}
|
||||
scope :outdated, where('created_at < ? AND status <> ? OR created_at < ?', Time.now - LIVE_TIME, BUILD_PUBLISHED, Time.now - MAX_LIVE_TIME)
|
||||
scope :published_container, where(:container_status => BUILD_PUBLISHED)
|
||||
|
||||
serialize :additional_repos
|
||||
serialize :include_repos
|
||||
serialize :results, Array
|
||||
serialize :extra_repositories, Array
|
||||
serialize :extra_containers, Array
|
||||
|
||||
after_commit :place_build
|
||||
after_destroy :remove_container
|
||||
|
@ -149,8 +156,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
after_transition :on => :published,
|
||||
:do => [:set_version_and_tag, :actualize_packages, :destroy_container]
|
||||
after_transition :on => :reject_publish, :do => :destroy_container
|
||||
:do => [:set_version_and_tag, :actualize_packages]
|
||||
after_transition :on => :cancel, :do => :cancel_job
|
||||
|
||||
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users
|
||||
|
@ -269,7 +275,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def can_create_container?
|
||||
(success? || tests_failed?) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status)
|
||||
(can_publish? || build_publish?) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status)
|
||||
end
|
||||
|
||||
#TODO: Share this checking on product owner.
|
||||
|
@ -398,8 +404,7 @@ class BuildList < ActiveRecord::Base
|
|||
repos = include_repos
|
||||
repos |= ['146'] if build_for_platform_id == 376
|
||||
include_repos_hash = {}.tap do |h|
|
||||
repos.each do |r|
|
||||
repo = Repository.find r
|
||||
Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo|
|
||||
path = repo.platform.public_downloads_url(nil, arch.name, repo.name)
|
||||
# path.gsub!(/^http:\/\/(0\.0\.0\.0|localhost)\:[\d]+/, 'https://abf.rosalinux.ru') unless Rails.env.production?
|
||||
# Path looks like:
|
||||
|
@ -408,9 +413,15 @@ class BuildList < ActiveRecord::Base
|
|||
# - release
|
||||
# - updates
|
||||
h["#{repo.platform.name}_#{repo.name}_release"] = path + 'release'
|
||||
h["#{repo.platform.name}_#{repo.name}_updates"] = path + 'updates'
|
||||
h["#{repo.platform.name}_#{repo.name}_updates"] = path + 'updates' if repo.platform.main?
|
||||
end
|
||||
end
|
||||
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
|
||||
BuildList.where(:id => extra_containers).each do |bl|
|
||||
path = "http://#{host}/downloads/#{bl.save_to_platform.name}/container/"
|
||||
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
|
||||
include_repos_hash["container_#{bl.id}"] = path
|
||||
end
|
||||
if save_to_platform.personal? && use_save_to_repository
|
||||
include_repos_hash["#{save_to_platform.name}_release"] = save_to_platform.
|
||||
urpmi_list(nil, nil, false, save_to_repository.name)["#{build_for_platform.name}"]["#{arch.name}"]
|
||||
|
@ -459,4 +470,33 @@ class BuildList < ActiveRecord::Base
|
|||
def use_save_to_repository_for_main_platforms
|
||||
self.use_save_to_repository = true if save_to_platform.main?
|
||||
end
|
||||
|
||||
def current_ability
|
||||
@current_ability ||= Ability.new(user)
|
||||
end
|
||||
|
||||
def check_extra_repositories
|
||||
if extra_repositories.present? && user
|
||||
repos_count = Repository.where(:id => extra_repositories).
|
||||
accessible_by(current_ability, :read).count
|
||||
errors.add(:extra_repositories, I18n.t('flash.build_list.wrong_extra_repositories')) if repos_count != extra_repositories.count
|
||||
end
|
||||
end
|
||||
|
||||
def check_extra_containers
|
||||
if extra_containers.present? && user
|
||||
bls_count = BuildList.where(:id => extra_containers).
|
||||
published_container.accessible_by(current_ability, :read).count
|
||||
errors.add(:extra_containers, I18n.t('flash.build_list.wrong_extra_containers')) if bls_count != extra_containers.count
|
||||
end
|
||||
end
|
||||
|
||||
def prepare_extra_repositories_and_containers
|
||||
if save_to_repository && save_to_repository.platform.main?
|
||||
self.extra_repositories = self.extra_containers = nil
|
||||
end
|
||||
self.extra_repositories = extra_repositories.uniq if extra_repositories.present?
|
||||
self.extra_containers = extra_containers.uniq if extra_containers.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,6 @@ class BuildList::Filter
|
|||
build_lists = build_lists.scoped_to_arch(@options[:arch_id]) if @options[:arch_id]
|
||||
build_lists = build_lists.scoped_to_save_platform(@options[:platform_id]) if @options[:platform_id]
|
||||
build_lists = build_lists.scoped_to_project_version(@options[:project_version]) if @options[:project_version]
|
||||
build_lists = build_lists.scoped_to_is_circle(@options[:is_circle]) if @options[:is_circle].present?
|
||||
build_lists = build_lists.scoped_to_project_name(@options[:project_name]) if @options[:project_name]
|
||||
build_lists = build_lists.by_mass_build(@options[:mass_build_id]) if @options[:mass_build_id]
|
||||
build_lists = build_lists.for_notified_date_period(@options[:updated_at_start], @options[:updated_at_end]) if @options[:updated_at_start] || @options[:updated_at_end]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
json.partial! 'api/v1/repositories/repository',
|
||||
:repository => repository,
|
||||
:json => json
|
||||
|
||||
json.platform do |json_str_platform|
|
||||
json.partial! 'api/v1/platforms/platform',
|
||||
:platform => repository.platform,
|
||||
:json => json
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
json.build_lists @build_lists do |json, build_list|
|
||||
json.(build_list, :id, :name, :status)
|
||||
json.(build_list, :id, :status)
|
||||
json.url api_v1_build_list_path(build_list, :format => :json)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
json.build_list do |json|
|
||||
json.(@build_list, :id, :name, :container_status, :status, :duration)
|
||||
json.(@build_list, :is_circle, :update_type, :priority, :new_core)
|
||||
json.(@build_list, :id, :container_status, :status, :duration)
|
||||
json.(@build_list, :update_type, :priority, :new_core)
|
||||
json.(@build_list, :advisory, :mass_build, :use_save_to_repository)
|
||||
json.(@build_list, :auto_publish, :package_version, :commit_hash, :last_published_commit_hash)
|
||||
json.(@build_list, :auto_publish, :package_version, :commit_hash, :last_published_commit_hash, :auto_create_container)
|
||||
json.build_log_url log_build_list_path(@build_list)
|
||||
|
||||
if @build_list.container_published?
|
||||
|
@ -44,17 +44,26 @@ json.build_list do |json|
|
|||
|
||||
inc_repos = Repository.includes(:platform).where(:id => @build_list.include_repos)
|
||||
json.include_repos inc_repos do |json_include_repos, repo|
|
||||
json.partial! 'api/v1/repositories/repository',
|
||||
:repository => repo,
|
||||
:json => json_include_repos
|
||||
|
||||
json_include_repos.platform do |json_str_platform|
|
||||
json.partial! 'api/v1/platforms/platform',
|
||||
:platform => repo.platform,
|
||||
:json => json_str_platform
|
||||
end
|
||||
json.partial! 'repositories',
|
||||
:repository => repo,
|
||||
:json => json_include_repos
|
||||
end
|
||||
|
||||
extra_repos = Repository.includes(:platform).where(:id => @build_list.extra_repositories)
|
||||
json.extra_repos extra_repos do |json_extra_repos, repo|
|
||||
json.partial! 'repositories',
|
||||
:repository => repo,
|
||||
:json => json_extra_repos
|
||||
end
|
||||
|
||||
extra_containers = BuildList.where(:id => @build_list.extra_containers)
|
||||
json.extra_containers extra_containers do |json_extra_containers, bl|
|
||||
json_extra_containers.(bl, :id, :status)
|
||||
json_extra_containers.container_path container_url(false, bl)
|
||||
json_extra_containers.url api_v1_build_list_path(bl, :format => :json)
|
||||
end
|
||||
|
||||
|
||||
json.advisory do |json_advisory|
|
||||
json_advisory.name @build_list.advisory.advisory_id
|
||||
json_advisory.(@build_list.advisory, :description)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
%tr
|
||||
- if subject.is_a?(BuildList)
|
||||
%td= link_to "#{subject.id} (#{subject.project.name} - #{subject.arch.name})", subject
|
||||
- else
|
||||
%td= link_to "#{subject.platform.name}/#{subject.name}", [subject.platform, subject]
|
||||
%td.actions
|
||||
- field = subject.is_a?(BuildList) ? 'extra_containers' : 'extra_repositories'
|
||||
= hidden_field_tag "build_list[#{field}][]", subject.id
|
||||
%span.delete
|
|
@ -22,13 +22,25 @@
|
|||
= label_tag "arches_#{arch.id}", arch.name
|
||||
%h3= t("activerecord.attributes.build_list.update_type")
|
||||
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES
|
||||
|
||||
#extra-repos-and-containers
|
||||
%h3= t("activerecord.attributes.build_list.extra_repos")
|
||||
= autocomplete_field_tag 'extra_repos', nil, autocomplete_to_extra_repos_and_containers_build_lists_path, :id_element => '#extra_repo_field'
|
||||
= hidden_field_tag 'extra_repo', nil, :id => 'extra_repo_field'
|
||||
= submit_tag t("layout.add"), :class => 'button', :id => 'add'
|
||||
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
%tbody
|
||||
- Repository.where(id: @build_list.extra_repositories).each do |repo|
|
||||
= render 'extra', :subject => repo
|
||||
|
||||
- BuildList.where(id: @build_list.extra_containers).each do |bl|
|
||||
= render 'extra', :subject => bl
|
||||
|
||||
%h3= t("activerecord.attributes.build_list.preferences")
|
||||
.both
|
||||
= f.check_box :auto_publish
|
||||
= f.label :auto_publish
|
||||
.both
|
||||
= f.check_box :use_save_to_repository
|
||||
= f.label :use_save_to_repository
|
||||
- [:auto_publish, :auto_create_container, :use_save_to_repository].each do |kind|
|
||||
.both
|
||||
= f.check_box kind
|
||||
= f.label kind
|
||||
%br
|
||||
= f.submit t("layout.projects.build_button")
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
= raw "%s %s" % [t("layout.build_lists.container_published"),
|
||||
link_to("#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}",
|
||||
[@build_list.save_to_platform, @build_list.save_to_repository])]
|
||||
- elsif @build_list.container_published?
|
||||
- if @build_list.container_published?
|
||||
= link_to container_url, container_url
|
||||
- elsif @build_list.container_publish?
|
||||
= t("layout.build_lists.creating")
|
||||
|
@ -53,6 +53,9 @@
|
|||
.leftlist= t("activerecord.attributes.build_list.auto_publish")
|
||||
.rightlist= t("layout.#{@build_list.auto_publish}_")
|
||||
.both
|
||||
.leftlist= t("activerecord.attributes.build_list.auto_create_container")
|
||||
.rightlist= t("layout.#{@build_list.auto_create_container?}_")
|
||||
.both
|
||||
.leftlist= t("diff")
|
||||
.rightlist= build_list_version_link(@build_list, true)
|
||||
.both
|
||||
|
@ -69,6 +72,15 @@
|
|||
.rightlist= t("layout.#{@build_list.new_core?}_")
|
||||
.both
|
||||
|
||||
- if @build_list.extra_containers.present? || @build_list.extra_repositories.present?
|
||||
.leftlist= t("activerecord.attributes.build_list.extra_repos")
|
||||
.rightlist
|
||||
- Repository.where(:id => @build_list.extra_repositories).each do |repo|
|
||||
%p= link_to "#{repo.platform.name}/#{repo.name}", [repo.platform, repo]
|
||||
- BuildList.where(:id => @build_list.extra_containers).each do |bl|
|
||||
%p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl
|
||||
.both
|
||||
|
||||
- if @build_list.mass_build_id.present?
|
||||
.leftlist= t("activerecord.attributes.mass_build_id")
|
||||
.rightlist= link_to @build_list.mass_build.name, platform_mass_builds_path(@build_list.save_to_platform)
|
||||
|
|
|
@ -7,6 +7,8 @@ en:
|
|||
build_list:
|
||||
bs_id: Id
|
||||
name: Name
|
||||
extra_repos: Extra repositories and containers
|
||||
auto_create_container: Create container automatically
|
||||
container_path: Container path
|
||||
status: Status
|
||||
project_id: Project
|
||||
|
@ -161,3 +163,5 @@ en:
|
|||
frozen_platform: In case of a repository for package storage with frozen platform allowed only bugfix and security updates
|
||||
wrong_include_repos: Include repos have to belongs to build for platform
|
||||
wrong_commit_hash: Unable find commit '%{commit_hash}' in project
|
||||
wrong_extra_repositories: Some repositories does not exist
|
||||
wrong_extra_containers: Some containers does not exist
|
||||
|
|
|
@ -7,6 +7,8 @@ ru:
|
|||
build_list:
|
||||
bs_id: Id
|
||||
name: Название
|
||||
extra_repos: Дополнительные репозитории и контейнеры
|
||||
auto_create_container: Создать контейнер автоматически
|
||||
container_path: Путь до контейнера
|
||||
status: Статус
|
||||
project_id: Проект
|
||||
|
@ -160,3 +162,5 @@ ru:
|
|||
frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления
|
||||
wrong_include_repos: Включаемые репозитории должны принадлежать платформе для сборки
|
||||
wrong_commit_hash: Невозможно найти коммит '%{commit_hash}' в проекте
|
||||
wrong_extra_repositories: Некоторые репозитории не существуют
|
||||
wrong_extra_containers: Некоторые контейнеры не существуют
|
||||
|
|
|
@ -220,7 +220,11 @@ Rosa::Application.routes.draw do
|
|||
put :create_container
|
||||
get :log
|
||||
end
|
||||
collection { post :search }
|
||||
collection {
|
||||
get :autocomplete_to_extra_repos_and_containers
|
||||
get :add_extra_repos_and_containers
|
||||
post :search
|
||||
}
|
||||
end
|
||||
|
||||
resources :projects, :only => [:index, :new, :create]
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class AddExtraRepositoriesAndContainersToBuildList < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :build_lists, :auto_create_container, :boolean, :default => false
|
||||
add_column :build_lists, :extra_repositories, :text
|
||||
add_column :build_lists, :extra_containers, :text
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130214101404) do
|
||||
ActiveRecord::Schema.define(:version => 20130218135847) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -134,6 +134,9 @@ ActiveRecord::Schema.define(:version => 20130214101404) do
|
|||
t.string "last_published_commit_hash"
|
||||
t.integer "container_status"
|
||||
t.boolean "use_save_to_repository", :default => true
|
||||
t.boolean "auto_create_container", :default => false
|
||||
t.text "extra_repositories"
|
||||
t.text "extra_containers"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"
|
||||
|
|
|
@ -55,7 +55,7 @@ module AbfWorker
|
|||
|
||||
def update_results(build_list = subject)
|
||||
results = (build_list.results || []).
|
||||
select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-worker.*\.log$/ }
|
||||
select{ |r| r['file_name'] !~ /^abfworker\:\:publish\-(container\-)*worker.*\.log$/ }
|
||||
results |= options['results']
|
||||
sort_results_and_save results, build_list
|
||||
end
|
||||
|
|
|
@ -30,7 +30,10 @@ module AbfWorker
|
|||
subject.tests_failed
|
||||
end
|
||||
|
||||
item.update_attributes({:status => BuildList::SUCCESS}) if [TESTS_FAILED, COMPLETED].include?(status)
|
||||
if [TESTS_FAILED, COMPLETED].include?(status)
|
||||
item.update_attributes({:status => BuildList::SUCCESS})
|
||||
subject.publish_container if subject.auto_create_container?
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Reference in New Issue