[refs #2161] Add auto build lists functional
This commit is contained in:
parent
b82320a4cd
commit
30564e8e17
|
@ -0,0 +1,37 @@
|
|||
class AutoBuildListsController < ApplicationController
|
||||
before_filter :authenticate_user!, :except => :auto_build
|
||||
|
||||
def index
|
||||
@projects_not_automated = Project.scoped
|
||||
@projects_not_automated = @projects_not_automated.where(:name => params[:name]) unless params[:name].blank?
|
||||
@projects_not_automated = @projects_not_automated.automateable.paginate :page => params[:not_automated_page], :per_page => 15
|
||||
|
||||
@projects_already_automated = Project.joins(:auto_build_lists).paginate :page => params[:already_automated_page], :per_page => 15
|
||||
end
|
||||
|
||||
#def new
|
||||
# @auto_build_list = AutoBuildList.new
|
||||
# # Now user can create auto_build_list only for personal repository and i586 arch.
|
||||
# @bpls = Platform.where(:id => current_user.personal_platform.id)
|
||||
# @pls = Platform.where(:id => current_user.personal_platform.id)
|
||||
# @archs = Arch.where(:name => 'i386')
|
||||
#end
|
||||
|
||||
def create
|
||||
#@auto_build_list = AutoBuildList.new(params[:auto_build_list])
|
||||
|
||||
@auto_build_list = AutoBuildList.new(
|
||||
:bpl_id => current_user.personal_platform.id,
|
||||
:pl_id => current_user.personal_platform.id,
|
||||
:arch_id => Arch.find_by_name('i586').id,
|
||||
:project_id => params[:project_id]
|
||||
)
|
||||
|
||||
if @auto_build_list.save
|
||||
redirect_to auto_build_lists_path(), :notice => t('flash.auto_build_list.success')
|
||||
else
|
||||
#render :action => 'new'
|
||||
redirect_to auto_build_lists_path, :notice => t('flash.auto_build_list.failed')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -53,6 +53,20 @@ class ProjectsController < ApplicationController
|
|||
p = params.delete_if{|k,v| k == 'controller' or k == 'action'}
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :message => p.inspect) # TODO find :object ?
|
||||
# logger.info "Git hook recieved from #{params[:git_user]} to #{params[:git_repo]}"
|
||||
|
||||
unixname = params[:git_repo].split('/')[1]
|
||||
project = Project.find_by_unixname(unixname)
|
||||
auto_build_list = AutoBuildList.find_by_project_id(project.id)
|
||||
|
||||
BuildList.create!(
|
||||
:project_id => project.id,
|
||||
:pl_id => auto_build_list.pl_id,
|
||||
:bpl_id => auto_build_list.bpl_id,
|
||||
:arch_id => auto_build_list.arch_id,
|
||||
:project_version => project.project_versions.last.try(:name),
|
||||
:build_requires => true,
|
||||
:update_type => 'bugfix') if auto_build_list
|
||||
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
|
@ -60,7 +74,7 @@ class ProjectsController < ApplicationController
|
|||
@arches = Arch.recent
|
||||
@bpls = Platform.main
|
||||
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] }
|
||||
@project_versions = @project.project_versions.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ }
|
||||
@project_versions = @project.project_versions.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }
|
||||
end
|
||||
|
||||
def process_build
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module AutoBuildListsHelper
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AutoBuildList < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
belongs_to :arch
|
||||
belongs_to :pl, :class_name => 'Platform'
|
||||
belongs_to :bpl, :class_name => 'Platform'
|
||||
end
|
|
@ -117,7 +117,7 @@ class BuildList < ActiveRecord::Base
|
|||
|
||||
#TODO: Share this checking on product owner.
|
||||
def can_canceled?
|
||||
self.status == BUILD_PENDING
|
||||
self.status == BUILD_PENDING && bs_id
|
||||
end
|
||||
|
||||
def event_log_message
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class EventLogObserver < ActiveRecord::Observer
|
||||
observe :user, :platform, :repository, :project, :product, :build_list
|
||||
observe :user, :platform, :repository, :project, :product, :build_list, :auto_build_list
|
||||
|
||||
def after_create(record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
|
|
|
@ -14,6 +14,7 @@ class Project < ActiveRecord::Base
|
|||
has_many :relations, :as => :target, :dependent => :destroy
|
||||
has_many :collaborators, :through => :relations, :source => :object, :source_type => 'User'
|
||||
has_many :groups, :through => :relations, :source => :object, :source_type => 'Group'
|
||||
has_many :auto_build_lists, :dependent => :destroy
|
||||
|
||||
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :allow_nil => false, :allow_blank => false
|
||||
validates :unixname, :uniqueness => {:scope => [:owner_id, :owner_type]}, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }, :allow_nil => false, :allow_blank => false
|
||||
|
@ -28,6 +29,7 @@ class Project < ActiveRecord::Base
|
|||
scope :by_name, lambda { |name| where('name like ?', '%' + name + '%') }
|
||||
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
||||
scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id != #{ repository_id }))") }
|
||||
scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)")
|
||||
|
||||
before_save :add_owner_rel
|
||||
after_create :attach_to_personal_repository
|
||||
|
@ -36,6 +38,11 @@ class Project < ActiveRecord::Base
|
|||
after_destroy :destroy_git_repo
|
||||
|
||||
def project_versions
|
||||
#tags.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ }
|
||||
tags.select { |tag| tag.name =~ /^v\./ }
|
||||
end
|
||||
|
||||
def tags
|
||||
self.git_repository.tags
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
%h1= t("layout.auto_build_lists.already_automated")
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%th= t("activerecord.attributes.auto_build_list.project")
|
||||
|
||||
- @projects_already_automated.each do |project|
|
||||
%tr{:class => cycle("odd", "even")}
|
||||
%td= link_to project.name, project_path(project)
|
||||
|
||||
= will_paginate @projects_not_automated, :param_name => 'already_automated_page'
|
|
@ -0,0 +1,13 @@
|
|||
%h1= t("layout.auto_build_lists.not_automated")
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%th= t("activerecord.attributes.auto_build_list.project")
|
||||
%th= t("layout.auto_build_lists.action")
|
||||
|
||||
- @projects_not_automated.each do |project|
|
||||
%tr{:class => cycle("odd", "even")}
|
||||
%td= link_to project.name, project_path(project)
|
||||
%td= link_to t("layout.auto_build_lists.automate_btn"), auto_build_lists_path(:project_id => project.id), :method => :post
|
||||
|
||||
= will_paginate @projects_not_automated, :param_name => 'not_automated_page'
|
|
@ -0,0 +1,18 @@
|
|||
.block
|
||||
.content
|
||||
.inner
|
||||
%h2= t('layout.auto_build_lists.header')
|
||||
|
||||
.inner
|
||||
= render :partial => "auto_build_lists/not_automated"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
.inner
|
||||
= render :partial => "auto_build_lists/already_automated"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
|
@ -46,6 +46,9 @@
|
|||
-if current_user.can_perform?('personal_repositories', 'show')
|
||||
%li{:class => controller.controller_path == 'personal_repositories' ? 'active' : '' }
|
||||
%a{:href => personal_repository_path( current_user.personal_repository.id )}= t("layout.menu.personal_repository")
|
||||
-#if current_user.can_perform?('auto_build_lists', 'index')
|
||||
%li{:class => controller.controller_path == 'auto_build_lists' ? 'active' : '' }
|
||||
%a{:href => auto_build_lists_path}= t("layout.menu.auto_build_lists")
|
||||
#wrapper.wat-cf
|
||||
= render :partial => "layouts/flashes"
|
||||
#main
|
||||
|
|
|
@ -31,6 +31,15 @@ ru:
|
|||
downloads:
|
||||
title: Статистика закачек пакетов
|
||||
|
||||
auto_build_lists:
|
||||
header: Проекты с автоматической сборкой
|
||||
message: Все проекты собираются под пользовательский репозиторий и архитектуру i586
|
||||
project: Проект
|
||||
action: Действие
|
||||
automate_btn: Автоматизировать
|
||||
not_automated: Не автоматизированы
|
||||
already_automated: Автоматизированы
|
||||
|
||||
weekdays:
|
||||
Monday: Понедельник
|
||||
Tuesday: Вторник
|
||||
|
@ -55,6 +64,7 @@ ru:
|
|||
roles: Роли
|
||||
users: Пользователи
|
||||
personal_repository: Мой репозиторий
|
||||
auto_build_lists: Авто. сборки
|
||||
|
||||
sessions:
|
||||
sign_in_header: Вход в систему
|
||||
|
@ -261,6 +271,10 @@ ru:
|
|||
project_version_not_found: версия не найден
|
||||
|
||||
flash:
|
||||
auto_build_list:
|
||||
success: Сборка проекта автоматизорована!
|
||||
failed: Не удалось автоматизировать сборку!
|
||||
|
||||
category:
|
||||
saved: Категория успешно сохранена
|
||||
save_error: Не удалось сохранить категорию
|
||||
|
@ -347,6 +361,16 @@ ru:
|
|||
download: Статистика
|
||||
|
||||
attributes:
|
||||
auto_build_list:
|
||||
project_id: Проект
|
||||
project: Проект
|
||||
bpl_id: Репозиторий для сохранения
|
||||
bpl: Репозиторий для сохранения
|
||||
pl_id: Платформа
|
||||
pl: Платформа
|
||||
arch_id: Архитектура
|
||||
arch: Архитектура
|
||||
|
||||
private_user:
|
||||
login: Логин
|
||||
password: Пароль
|
||||
|
|
|
@ -224,6 +224,8 @@
|
|||
- index
|
||||
personal_repositories:
|
||||
- show
|
||||
auto_build_lists:
|
||||
- index
|
||||
repositories:
|
||||
- index
|
||||
platforms:
|
||||
|
|
|
@ -30,6 +30,9 @@ Rosa::Application.routes.draw do
|
|||
match 'build_lists/' => 'build_lists#all', :as => :all_build_lists
|
||||
match 'build_lists/:id/cancel/' => 'build_lists#cancel', :as => :build_list_cancel
|
||||
|
||||
resources :auto_build_lists, :only => [:index, :create] do
|
||||
end
|
||||
|
||||
resources :personal_repositories, :only => [:show] do
|
||||
member do
|
||||
get :settings
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class CreateAutoBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :auto_build_lists do |t|
|
||||
t.integer :project_id
|
||||
t.integer :arch_id
|
||||
t.integer :pl_id
|
||||
t.integer :bpl_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :auto_build_lists
|
||||
end
|
||||
end
|
15
db/schema.rb
15
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20111028070604) do
|
||||
ActiveRecord::Schema.define(:version => 20111029150934) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -31,6 +31,15 @@ ActiveRecord::Schema.define(:version => 20111028070604) do
|
|||
add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true
|
||||
add_index "authentications", ["user_id"], :name => "index_authentications_on_user_id"
|
||||
|
||||
create_table "auto_build_lists", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.integer "arch_id"
|
||||
t.integer "pl_id"
|
||||
t.integer "bpl_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "build_list_items", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "level"
|
||||
|
@ -38,6 +47,7 @@ ActiveRecord::Schema.define(:version => 20111028070604) do
|
|||
t.integer "build_list_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "version"
|
||||
end
|
||||
|
||||
add_index "build_list_items", ["build_list_id"], :name => "index_build_list_items_on_build_list_id"
|
||||
|
@ -263,8 +273,9 @@ ActiveRecord::Schema.define(:version => 20111028070604) do
|
|||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.string "remember_token"
|
||||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe AutoBuildListsController do
|
||||
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the AutoBuildListsHelper. For example:
|
||||
#
|
||||
# describe AutoBuildListsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe AutoBuildListsHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe AutoBuildList do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue