fixes + build lists
This commit is contained in:
parent
cd365d4d45
commit
4ac5931f44
|
@ -0,0 +1,55 @@
|
|||
class BuildListsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_platform, :only => [:index, :filter]
|
||||
before_filter :find_repository, :only => [:index, :filter]
|
||||
before_filter :find_project, :only => [:index, :filter]
|
||||
before_filter :find_arches, :only => [:index, :filter]
|
||||
before_filter :find_branches, :only => [:index, :filter]
|
||||
|
||||
def index
|
||||
@build_lists = @project.build_lists.recent.paginate :page => params[:page]
|
||||
@filter = BuildList::Filter.new(@project)
|
||||
end
|
||||
|
||||
def filter
|
||||
@filter = BuildList::Filter.new(@project, params[:filter])
|
||||
@build_lists = @filter.find.paginate :page => params[:page]
|
||||
|
||||
render :action => "index"
|
||||
end
|
||||
|
||||
def status_build
|
||||
@build_list = BuildList.find_by_bs_id!(params[:id])
|
||||
|
||||
@build_list.status = params[:status]
|
||||
@build_list.container_path = params[:container_path]
|
||||
@build_list.notified_at = Time.now
|
||||
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
protected
|
||||
def find_platform
|
||||
@platform = Platform.find params[:platform_id]
|
||||
end
|
||||
|
||||
def find_repository
|
||||
@repository = @platform.repositories.find(params[:repository_id])
|
||||
end
|
||||
|
||||
def find_project
|
||||
@project = @repository.projects.find params[:project_id]
|
||||
end
|
||||
|
||||
def find_arches
|
||||
@arches = Arch.recent
|
||||
end
|
||||
|
||||
def find_branches
|
||||
@git_repository = @project.git_repository
|
||||
@branches = @git_repository.branches
|
||||
end
|
||||
|
||||
end
|
|
@ -37,7 +37,7 @@ class Git::BaseController < ApplicationController
|
|||
end
|
||||
|
||||
def set_treeish
|
||||
@treeish = params[:treeish] ? params[:treeish] : "master"
|
||||
@treeish = params[:treeish].present? ? params[:treeish] : "master"
|
||||
end
|
||||
|
||||
def set_current_tag
|
||||
|
|
|
@ -31,13 +31,15 @@ class Git::BlobsController < Git::BaseController
|
|||
|
||||
def find_tree
|
||||
if @commit_hash
|
||||
puts "1"
|
||||
@tree = @git_repository.tree(@commit_hash)
|
||||
@commit = @git_repository.commits(@treeish, 1).first
|
||||
else
|
||||
puts "2"
|
||||
@tree = @git_repository.tree(@treeish)
|
||||
puts @tree.name.inspect
|
||||
|
||||
@commit = @git_repository.log(@treeish, @path).first
|
||||
@commit_hash = @commit.id if @commit
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,9 +5,9 @@ class Git::TreesController < Git::BaseController
|
|||
|
||||
@tree = @git_repository.tree(@treeish)
|
||||
|
||||
@commit = @git_repository.commits(@treeish, 1).first
|
||||
# @commit = @git_repository.commits(@treeish, 1).first
|
||||
# Raises Grit::Git::GitTimeout
|
||||
# @commit = @git_repository.log(@treeish).first
|
||||
@commit = @git_repository.log(@treeish, @path).first
|
||||
|
||||
@tree = @tree / @path if @path
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@current_build_lists = @project.build_lists.current.recent.paginate :page => params[:page]
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
class Arch < ActiveRecord::Base
|
||||
validate :name, :presence => true, :uniqueness => true
|
||||
has_many :build_lists, :dependent => :destroy
|
||||
|
||||
validates :name, :presence => true, :uniqueness => true
|
||||
|
||||
scope :recent, order("name ASC")
|
||||
end
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
class BuildList < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
belongs_to :arch
|
||||
|
||||
validates :project_id, :presence => true
|
||||
validates :branch_name, :presence => true
|
||||
|
||||
STATUSES = [BuildServer::SUCCESS, BuildServer::BUILD_PENDING, BuildServer::BUILD_ERROR, BuildServer::DEPENDENCIES_FAIL, BuildServer::SRPM_NOT_FOUND, BuildServer::MOCK_NOT_FOUND]
|
||||
BUILD_ERROR_STATUSES = [ BuildServer::BUILD_ERROR, BuildServer::MOCK_NOT_FOUND, BuildServer::DEPENDENCIES_FAIL, BuildServer::SRPM_NOT_FOUND]
|
||||
HUMAN_STATUSES = { BuildServer::BUILD_ERROR => :build_error,
|
||||
BuildServer::MOCK_NOT_FOUND => :mock_not_found,
|
||||
BuildServer::DEPENDENCIES_FAIL => :dependencies_fail,
|
||||
BuildServer::SRPM_NOT_FOUND => :srpm_not_found,
|
||||
BuildServer::BUILD_PENDING => :build_pending,
|
||||
BuildServer::SUCCESS => :success
|
||||
}
|
||||
|
||||
scope :recent, order("created_at DESC")
|
||||
scope :current, lambda { where(["status in (?) OR (status = ? AND notified_at >= ?)", BUILD_ERROR_STATUSES + [BuildServer::BUILD_PENDING], BuildServer::SUCCESS, Time.now - 2.days]) }
|
||||
scope :for_status, lambda {|status| where(:status => status) }
|
||||
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) }
|
||||
scope :scoped_to_branch, lambda {|branch| where(:branch_name => branch) }
|
||||
scope :for_creation_date_period, lambda{|start_date, end_date|
|
||||
if start_date && end_date
|
||||
where(["created_at BETWEEN ? AND ?", start_date, end_date])
|
||||
elsif start_date && !end_date
|
||||
where(["created_at >= ?", start_date])
|
||||
elsif !start_date && end_date
|
||||
where(["created_at <= ?", end_date])
|
||||
end
|
||||
}
|
||||
scope :for_notified_date_period, lambda{|start_date, end_date|
|
||||
if start_date && end_date
|
||||
where(["notified_at BETWEEN ? AND ?", start_date, end_date])
|
||||
elsif start_date && !end_date
|
||||
where(["notified_at >= ?", start_date])
|
||||
elsif !start_date && end_date
|
||||
where(["notified_at <= ?", end_date])
|
||||
end
|
||||
}
|
||||
|
||||
def self.human_status(status)
|
||||
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
||||
end
|
||||
|
||||
def human_status
|
||||
self.class.human_status(status)
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,65 @@
|
|||
class BuildList::Filter
|
||||
|
||||
def initialize(project, options = {})
|
||||
@project = project
|
||||
|
||||
set_options(options)
|
||||
end
|
||||
|
||||
def find
|
||||
build_lists = @project.build_lists.recent
|
||||
|
||||
build_lists = build_lists.for_status(@options[:status]) if @options[:status]
|
||||
build_lists = build_lists.scoped_to_arch(@options[:arch_id]) if @options[:arch_id]
|
||||
build_lists = build_lists.scoped_to_branch(@options[:branch_name]) if @options[:branch_name]
|
||||
|
||||
if @options[:created_at_start] || @options[:created_at_end]
|
||||
build_lists = build_lists.for_creation_date_period(@options[:created_at_start], @options[:created_at_end])
|
||||
end
|
||||
|
||||
if @options[:notified_at_start] || @options[:notified_at_end]
|
||||
build_lists = build_lists.for_notified_date_period(@options[:notified_at_start], @options[:notified_at_end])
|
||||
end
|
||||
|
||||
build_lists
|
||||
end
|
||||
|
||||
def respond_to?(name)
|
||||
return true if @options.has_key?(name)
|
||||
super
|
||||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
@options.has_key?(name) ? @options[name] : super
|
||||
end
|
||||
|
||||
private
|
||||
def set_options(options)
|
||||
@options = HashWithIndifferentAccess.new(options.reverse_merge({
|
||||
:status => nil,
|
||||
:created_at_start => nil,
|
||||
:created_at_end => nil,
|
||||
:notified_at_start => nil,
|
||||
:notified_at_end => nil,
|
||||
:arch_id => nil,
|
||||
:branch_name => nil
|
||||
}))
|
||||
|
||||
@options[:status] = @options[:status].present? ? @options[:status].to_i : nil
|
||||
@options[:created_at_start] = build_date_from_params(:created_at_start, @options)
|
||||
@options[:created_at_end] = build_date_from_params(:created_at_end, @options)
|
||||
@options[:notified_at_start] = build_date_from_params(:notified_at_start, @options)
|
||||
@options[:notified_at_end] = build_date_from_params(:notified_at_end, @options)
|
||||
@options[:branch_name] = @options[:branch_name].present? ? @options[:branch_name] : nil
|
||||
@options[:arch_id] = @options[:arch_id].present? ? @options[:arch_id].to_i : nil
|
||||
end
|
||||
|
||||
def build_date_from_params(field_name, params)
|
||||
if params["#{field_name.to_s}(1i)"].present? || params["#{field_name.to_s}(2i)"].present? || params["#{field_name.to_s}(3i)"].present?
|
||||
Date.civil(params["#{field_name.to_s}(1i)"].to_i, params["#{field_name.to_s}(2i)"].to_i, params["#{field_name.to_s}(3i)"].to_i)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,8 +1,8 @@
|
|||
class Container < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id'
|
||||
|
||||
validates :name, :presence => true
|
||||
validates :project_id, :presence => true
|
||||
validates :onwer_id, :presence => true
|
||||
|
||||
belongs_to :project
|
||||
belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id'
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Project < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
has_many :build_lists, :dependent => :destroy
|
||||
|
||||
validates :name, :uniqueness => true, :presence => true, :allow_nil => false, :allow_blank => false
|
||||
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
%table.table
|
||||
%tr
|
||||
%th.first= t("activerecord.attributes.build_list.bs_id")
|
||||
%th= t("activerecord.attributes.build_list.status")
|
||||
%th= t("activerecord.attributes.build_list.branch_name")
|
||||
%th= t("activerecord.attributes.build_list.project")
|
||||
%th= t("activerecord.attributes.build_list.arch")
|
||||
%th.last= t("activerecord.attributes.build_list.notified_at")
|
||||
|
||||
- build_lists.each do |build_list|
|
||||
%tr{:class => cycle("odd", "even")}
|
||||
%td= build_list.bs_id
|
||||
%td= build_list.human_status
|
||||
%td= link_to build_list.branch_name, "#"
|
||||
%td= link_to build_list.project.name, platform_repository_project_path(@platform, @repository, @project)
|
||||
%td= build_list.arch.name
|
||||
%td.last= build_list.notified_at
|
||||
|
||||
= will_paginate build_lists
|
|
@ -0,0 +1,45 @@
|
|||
%h2.title= t("layout.build_lists.filter_header")
|
||||
|
||||
= form_for :filter, :url => filter_platform_repository_project_build_lists_path(@platform, @repository, @project) , :html => { :method => :post, :class => :form } do |f|
|
||||
.columns.wat-cf
|
||||
.column.left
|
||||
|
||||
.group
|
||||
= f.label :status, t("activerecord.attributes.build_list.status"), :class => :label
|
||||
= f.select :status, BuildList::STATUSES.collect{|status| [BuildList.human_status(status), status]}, :include_blank => true, :selected => @filter.status
|
||||
|
||||
.group
|
||||
= f.label :arch_id, t("activerecord.attributes.build_list.arch"), :class => :label
|
||||
= f.select :arch_id, @arches.collect{|arch| [arch.name, arch.id]}, :include_blank => true, :selected => @filter.arch_id
|
||||
|
||||
.column.right
|
||||
|
||||
.group
|
||||
= f.label :branch_name, "Branch", :class => :label
|
||||
= f.select :branch_name, @branches.collect{|branch| [branch.name, branch.name]}, :include_blank => true, :selected => @filter.branch_name
|
||||
|
||||
.columns.wat-cf
|
||||
.column.left
|
||||
|
||||
.group
|
||||
= f.label :status, t("layout.build_lists.created_at_start"), :class => :label
|
||||
= date_select("filter", :created_at_start, :include_blank => true, :selected => @filter.created_at_start)
|
||||
|
||||
.group
|
||||
= f.label :status, t("layout.build_lists.notified_at_start"), :class => :label
|
||||
= date_select("filter", :notified_at_start, :include_blank => true, :selected => @filter.notified_at_start)
|
||||
|
||||
.column.right
|
||||
|
||||
.group
|
||||
= f.label :status, t("layout.build_lists.created_at_end"), :class => :label
|
||||
= date_select("filter", :created_at_end, :include_blank => true, :selected => @filter.created_at_end)
|
||||
|
||||
.group
|
||||
= f.label :status, t("layout.build_lists.notified_at_end"), :class => :label
|
||||
= date_select("filter", :notified_at_end, :include_blank => true, :selected => @filter.notified_at_end)
|
||||
|
||||
.grou.navform.wat-cf
|
||||
%button.button{ :type => "submit" }
|
||||
= image_tag("web-app-theme/icons/tick.png", :alt => "Save")
|
||||
= t("layout.search")
|
|
@ -0,0 +1,15 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.build_lists.current"), platform_repository_project_path(@platform, @repository, @project) + "#build_lists"
|
||||
%li.active= link_to t("layout.build_lists.all"), platform_repository_project_build_lists_path(@platform, @repository, @project)
|
||||
|
||||
.content
|
||||
|
||||
.inner
|
||||
= render :partial => "build_lists/filter"
|
||||
|
||||
.inner
|
||||
= render :partial => "build_lists/build_lists", :object => @build_lists
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
|
@ -17,7 +17,10 @@
|
|||
.blob_header
|
||||
.size #{(@blob.size / 1024.0).round(3)} Kb
|
||||
.buttons
|
||||
- if @commit_hash
|
||||
#{link_to "Raw", raw_commit_path(@platform, @repository, @project, @commit_hash, @path)} #{link_to "Blame", blame_commit_path(@platform, @repository, @project, @commit_hash, @path)} #{link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)}
|
||||
- else
|
||||
#{link_to "Raw", raw_path(@platform, @repository, @project, @treeish, @path)} #{link_to "Blame", blame_path(@platform, @repository, @project, @treeish, @path)} #{link_to "History", commits_path(@platform, @repository, @project, @treeish, @path)}
|
||||
.clear
|
||||
%table.table.blob
|
||||
%tr
|
||||
|
|
|
@ -25,5 +25,16 @@
|
|||
= @project.repository.name
|
||||
.wat-cf
|
||||
= link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_project_path(@platform, @repository, @project), :method => "delete", :class => "button", :confirm => t("layout.projects.confirm_delete")
|
||||
- content_for :sidebar, render(:partial => 'sidebar')
|
||||
|
||||
%a{ :name => "build_lists"}
|
||||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first.active= link_to t("layout.build_lists.current"), platform_repository_project_path(@platform, @repository, @project) + "#build_lists"
|
||||
%li= link_to t("layout.build_lists.all"), platform_repository_project_build_lists_path(@platform, @repository, @project)
|
||||
|
||||
.content
|
||||
|
||||
= render :partial => "build_lists/build_lists", :object => @current_build_lists
|
||||
|
||||
- content_for :sidebar, render(:partial => 'sidebar')
|
||||
|
|
|
@ -10,6 +10,7 @@ ru:
|
|||
create: Создать
|
||||
delete: Удалить
|
||||
save: Сохранить
|
||||
search: Искать
|
||||
are_you_sure: "Вы уверены?"
|
||||
login: Войти
|
||||
or: или
|
||||
|
@ -61,6 +62,7 @@ ru:
|
|||
git_repo_location: Путь к git-репозиторию
|
||||
back_to_the_list: ⇐ К списку проектов репозитория
|
||||
current_project_header: Текущий проект
|
||||
current_build_lists: Текущие сборки
|
||||
users:
|
||||
list: Список
|
||||
new: Создать
|
||||
|
@ -78,6 +80,21 @@ ru:
|
|||
commits: Commits
|
||||
tags: Tags
|
||||
branches: Branches
|
||||
build_lists:
|
||||
filter_header: Фильтр
|
||||
current: Текущие
|
||||
all: Все
|
||||
created_at_start: "Время постановки на сборку с:"
|
||||
created_at_end: "Время постановки на сборку по:"
|
||||
notified_at_start: "Время последнего обновления от BS с:"
|
||||
notified_at_end: "Время последнего обновления от BS по:"
|
||||
statuses:
|
||||
build_error: ошибка сборки
|
||||
mock_not_found: mock не найден
|
||||
dependencies_fail: dependencies fail
|
||||
srpm_not_found: srpm не найден
|
||||
build_pending: собирается
|
||||
success: собран
|
||||
|
||||
flash:
|
||||
project:
|
||||
|
@ -108,6 +125,7 @@ ru:
|
|||
remember_me: Запомнить
|
||||
name: Название
|
||||
parent_platform_id: Родительская платформа
|
||||
build_list: Сборочный лист
|
||||
|
||||
|
||||
activerecord:
|
||||
|
@ -174,3 +192,16 @@ ru:
|
|||
email: Email
|
||||
created_at: Создан
|
||||
updated_at: Обновлен
|
||||
|
||||
build_list:
|
||||
bs_id: Id
|
||||
container_path: Путь до контейнера
|
||||
status: Статус
|
||||
branch_name: Branch
|
||||
project_id: Проект
|
||||
project: Проект
|
||||
arch_id: Архитектура
|
||||
arch: Архитектура
|
||||
notified_at: Информация получена
|
||||
updated_at: Обновлен
|
||||
created_at: Создан
|
||||
|
|
|
@ -10,12 +10,21 @@ Rosa::Application.routes.draw do
|
|||
resources :repositories do
|
||||
resources :projects do
|
||||
resource :repo, :controller => "git/repositories", :only => [:show]
|
||||
resources :build_lists, :only => [:index] do
|
||||
collection do
|
||||
get :recent
|
||||
post :filter
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resources :users
|
||||
|
||||
match 'build_lists/status_build', :to => "build_lists#status_build"
|
||||
|
||||
|
||||
# Tree
|
||||
match 'platforms/:platform_id/repositories/:repository_id/projects/:project_id/git/tree/:treeish(/*path)', :controller => "git/trees", :action => :show, :treeish => /[0-9a-zA-Z_.\-]*/, :defaults => { :treeish => :master }, :as => :tree
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
class CreateBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :build_lists, :force => true do |t|
|
||||
t.integer :bs_id
|
||||
t.string :container_path
|
||||
t.integer :status
|
||||
|
||||
t.string :branch_name
|
||||
t.integer :project_id
|
||||
t.integer :arch_id
|
||||
|
||||
t.timestamp :notified_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :build_lists, :bs_id, :unique => true
|
||||
add_index :build_lists, :project_id
|
||||
add_index :build_lists, :arch_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :build_lists, :bs_id
|
||||
remove_index :build_lists, :project_id
|
||||
remove_index :build_lists, :arch_id
|
||||
|
||||
drop_table :build_lists
|
||||
end
|
||||
end
|
18
db/schema.rb
18
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110317130503) do
|
||||
ActiveRecord::Schema.define(:version => 20110405161609) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -20,6 +20,22 @@ ActiveRecord::Schema.define(:version => 20110317130503) do
|
|||
|
||||
add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true
|
||||
|
||||
create_table "build_lists", :force => true do |t|
|
||||
t.integer "bs_id"
|
||||
t.string "container_path"
|
||||
t.integer "status"
|
||||
t.string "branch_name"
|
||||
t.integer "project_id"
|
||||
t.integer "arch_id"
|
||||
t.datetime "notified_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||
add_index "build_lists", ["bs_id"], :name => "index_build_lists_on_bs_id", :unique => true
|
||||
add_index "build_lists", ["project_id"], :name => "index_build_lists_on_project_id"
|
||||
|
||||
create_table "containers", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
|
|
|
@ -9,6 +9,7 @@ class BuildServer
|
|||
PROJECT_NOT_FOUND = 3
|
||||
BRANCH_NOT_FOUND = 4
|
||||
|
||||
BUILD_PENDING = 1
|
||||
BUILD_ERROR = 2500
|
||||
MOCK_NOT_FOUND = 256
|
||||
DEPENDENCIES_FAIL = 7680
|
||||
|
@ -28,22 +29,18 @@ class BuildServer
|
|||
self.client.call('delete_platform', name)
|
||||
end
|
||||
|
||||
|
||||
def self.clone_platform new_name, old_name, new_root_folder
|
||||
self.client.call('clone_platform', new_name, old_name, new_root_folder)
|
||||
end
|
||||
|
||||
|
||||
def self.create_repo name, platform_name
|
||||
self.client.call('create_repo', name, platform_name)
|
||||
end
|
||||
|
||||
|
||||
def self.clone_repo new_name, old_name, new_platform_name
|
||||
self.client.call('clone_repo', new_name, old_name, new_platform_name)
|
||||
end
|
||||
|
||||
|
||||
def self.publish_container container_id
|
||||
self.client.call('publish_container', container_id)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue