This commit is contained in:
Timothy N. Tsvetkov 2011-04-11 14:52:37 +04:00
commit e3b12e4a1a
12 changed files with 116 additions and 1 deletions

View File

@ -0,0 +1,26 @@
class ProductsController < ApplicationController
before_filter :authenticate_user!, :except => [:product_begin, :product_end]
before_filter :find_product_by_name, :only => [:product_begin, :product_end]
def product_begin
@product.build_status = Product::STATUS::BUILDING
@product.build_path = params[:path]
@product.save!
render :nothing => true, :status => 200
end
def product_end
@product.build_status = ((params[:status] == BuildServer::SUCCESS) ? Product::BUILD_COMPLETED : Product::BUILD_FAILED)
@product.build_path = params[:path]
@product.save!
render :nothing => true, :status => 200
end
protected
def find_product_by_name
@product = Product.find_by_name params[:product_name]
end
end

View File

@ -0,0 +1,2 @@
module ProductsHelper
end

View File

@ -1,6 +1,7 @@
class Platform < ActiveRecord::Base class Platform < ActiveRecord::Base
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
has_many :repositories, :dependent => :destroy has_many :repositories, :dependent => :destroy
has_many :products, :dependent => :destroy
validates :name, :presence => true, :uniqueness => true validates :name, :presence => true, :uniqueness => true
validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9\-.]+$/ }, :allow_nil => false, :allow_blank => false
@ -8,6 +9,7 @@ class Platform < ActiveRecord::Base
before_create :xml_rpc_create before_create :xml_rpc_create
before_destroy :xml_rpc_destroy before_destroy :xml_rpc_destroy
def path def path
build_path(unixname) build_path(unixname)
end end

11
app/models/product.rb Normal file
View File

@ -0,0 +1,11 @@
class Product < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
validates :platform_id, :presence => true
validates :build_status, :inclusion => { :in => [ NEVER_BUILT, BUILD_COMPLETED, BUILD_FAILED ] }
belongs_to :platform
NEVER_BUILT = 2
BUILD_COMPLETED = 0
BUILD_FAILED = 1
end

View File

@ -7,6 +7,8 @@ Rosa::Application.routes.draw do
get 'unfreeze' get 'unfreeze'
end end
resources :products
resources :repositories do resources :repositories do
resources :projects do resources :projects do
resource :repo, :controller => "git/repositories", :only => [:show] resource :repo, :controller => "git/repositories", :only => [:show]
@ -26,6 +28,9 @@ Rosa::Application.routes.draw do
match 'build_lists/post_build', :to => "build_lists#post_build" match 'build_lists/post_build', :to => "build_lists#post_build"
match 'build_lists/circle_build', :to => "build_lists#circle_build" match 'build_lists/circle_build', :to => "build_lists#circle_build"
match 'product_begin', :to => 'products#product_begin'
match 'product_end', :to => 'products#product_end'
# Tree # 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 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

View File

@ -0,0 +1,16 @@
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.string :name, :null => false
t.integer :platform_id, :null => false
t.integer :build_status, :default => 2, :null => false ### NOTE :default => 2 comes from Product::NEVER_BUILT status which we unable to use here
t.string :build_path
t.timestamps
end
end
def self.down
drop_table :products
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110408134718) do ActiveRecord::Schema.define(:version => 20110411082826) do
create_table "arches", :force => true do |t| create_table "arches", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
@ -67,6 +67,15 @@ ActiveRecord::Schema.define(:version => 20110408134718) do
t.boolean "released", :default => false t.boolean "released", :default => false
end end
create_table "products", :force => true do |t|
t.string "name", :null => false
t.integer "platform_id", :null => false
t.integer "build_status", :default => 2, :null => false
t.string "build_path"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "projects", :force => true do |t| create_table "projects", :force => true do |t|
t.string "name" t.string "name"
t.string "unixname" t.string "unixname"

View File

@ -71,4 +71,8 @@ class BuildServer
def self.add_build_list project_name, branch_name, platform_name, arch_name def self.add_build_list project_name, branch_name, platform_name, arch_name
self.client.call('add_build_list', project_name, branch_name, platform_name, arch_name) self.client.call('add_build_list', project_name, branch_name, platform_name, arch_name)
end end
def self.freeze platform_name, new_repo_name = nil
self.client.call('freeze_platform', platform_name, new_repo_name)
end
end end

15
lib/product_builder.rb Normal file
View File

@ -0,0 +1,15 @@
require 'xmlrpc/client'
class ProductBuilder
SUCCESS = 0
ERROR = 1
def self.client
@@client ||= XMLRPC::Client.new3(:host => APP_CONFIG['product_builder_ip'], :port => APP_CONFIG['product_builder_port'], :path => APP_CONFIG['product_builder_path'])
end
def self.create_product name, platform_name, params, packages, post_install, path, repos
self.client.call('create_product', name, platform_name, params, packages, post_install, path, repos)
end
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe ProductsController do
end

View File

@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the ProductsHelper. For example:
#
# describe ProductsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe ProductsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Product do
pending "add some examples to (or delete) #{__FILE__}"
end