Merge pull request #91 from warpc/72-auto_publish
Автоматическая публикация сборки
This commit is contained in:
commit
86ebaa7817
|
@ -6,7 +6,7 @@ class BuildListsController < ApplicationController
|
|||
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
|
||||
before_filter :find_project, :only => NESTED_ACTIONS
|
||||
before_filter :find_build_list, :only => [:show, :publish, :cancel]
|
||||
before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build]
|
||||
before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build, :circle_build]
|
||||
|
||||
load_and_authorize_resource :project, :only => NESTED_ACTIONS
|
||||
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
|
||||
|
@ -113,6 +113,8 @@ class BuildListsController < ApplicationController
|
|||
@build_list.notified_at = Time.current
|
||||
@build_list.save
|
||||
|
||||
@build_list.publish if @build_list.auto_publish # && @build_list.can_publish?
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
|
@ -130,10 +132,9 @@ class BuildListsController < ApplicationController
|
|||
@build_list.name = params[:name]
|
||||
@build_list.additional_repos = ActiveSupport::JSON.decode(params[:additional_repos])
|
||||
@build_list.set_items(ActiveSupport::JSON.decode(params[:items]))
|
||||
@build_list.notified_at = Time.current
|
||||
@build_list.is_circle = (params[:is_circular] != "0")
|
||||
@build_list.is_circle = (params[:is_circular].to_i != 0)
|
||||
@build_list.bs_id = params[:id]
|
||||
params[:arch]
|
||||
@build_list.notified_at = Time.current
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
|
|
|
@ -110,7 +110,7 @@ class BuildList < ActiveRecord::Base
|
|||
def publish
|
||||
return false unless can_publish?
|
||||
has_published = BuildServer.publish_container bs_id
|
||||
update_attribute(:status, BUILD_PUBLISH) if has_published == 0
|
||||
update_attribute(:status, has_published == 0 ? BUILD_PUBLISH : FAILED_PUBLISH)
|
||||
return has_published == 0
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
%th= t("activerecord.attributes.build_list.project")
|
||||
%th= t("activerecord.attributes.build_list.arch")
|
||||
%th= t("activerecord.attributes.build_list.user")
|
||||
%th= t("activerecord.attributes.build_list.is_circle")
|
||||
- unless @project
|
||||
%th= t("layout.build_lists.cancel_button_header")
|
||||
%th.last= t("activerecord.attributes.build_list.notified_at")
|
||||
|
@ -19,7 +18,6 @@
|
|||
%td= link_to build_list.project.name, project_path(build_list.project)
|
||||
%td= build_list.arch.name
|
||||
%td= build_list.user.try(:fullname)
|
||||
%td= t("layout.#{build_list.is_circle?}_")
|
||||
- unless @project
|
||||
%td= link_to t("layout.build_lists.cancel_button"), cancel_build_list_path(build_list), :method => "put", :confirm => t("layout.confirm") if build_list.can_cancel?
|
||||
%td.last= build_list.notified_at
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
= f.label :include_repos, t("activerecord.attributes.build_list.include_repos"), :class => :label
|
||||
#include_repos
|
||||
|
||||
.group
|
||||
= f.check_box :auto_publish
|
||||
= f.label :auto_publish, t("activerecord.attributes.build_list.auto_publish")
|
||||
|
||||
.group.navform.wat-cf
|
||||
%button.button{:type => "submit"}
|
||||
= image_tag("web-app-theme/icons/tick.png", :alt => t("layout.projects.build_button"))
|
||||
|
|
|
@ -49,6 +49,11 @@
|
|||
= t("activerecord.attributes.build_list.build_requires")
|
||||
\:
|
||||
= @build_list.build_requires
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.auto_publish")
|
||||
\:
|
||||
= @build_list.auto_publish
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.status")
|
||||
|
|
|
@ -637,6 +637,7 @@ ru:
|
|||
bpl_id: Платформа
|
||||
update_type: Критичность обновления
|
||||
build_requires: Пересборка с зависимостями
|
||||
auto_publish: Автоматическая публикация
|
||||
project_version: Версия
|
||||
user: Пользователь
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddAutoPublishToBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :build_lists, :auto_publish, :boolean, :default => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :build_lists, :auto_publish
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20111221194422) do
|
||||
ActiveRecord::Schema.define(:version => 20111228182425) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -71,6 +71,7 @@ ActiveRecord::Schema.define(:version => 20111221194422) do
|
|||
t.integer "pl_id"
|
||||
t.text "include_repos"
|
||||
t.integer "user_id"
|
||||
t.boolean "auto_publish", :default => true
|
||||
end
|
||||
|
||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||
|
|
|
@ -50,10 +50,10 @@ describe BuildListsController do
|
|||
end
|
||||
end
|
||||
|
||||
before { stub_rsync_methods }
|
||||
|
||||
context 'crud' do
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
|
||||
platform = Factory(:platform_with_repos)
|
||||
@create_params = {
|
||||
:build_list => {
|
||||
|
@ -257,7 +257,6 @@ describe BuildListsController do
|
|||
context 'filter' do
|
||||
|
||||
before(:each) do
|
||||
stub_rsync_methods
|
||||
set_session_for Factory(:admin)
|
||||
|
||||
@build_list1 = Factory(:build_list_core)
|
||||
|
@ -297,5 +296,99 @@ describe BuildListsController do
|
|||
end
|
||||
|
||||
context 'callbacks' do
|
||||
let(:build_list) { Factory(:build_list_core) }
|
||||
|
||||
describe 'publish_build' do
|
||||
def do_get(status)
|
||||
get :publish_build, :id => build_list.bs_id, :status => status
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildList::FAILED_PUBLISH) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :notified_at) }
|
||||
end
|
||||
|
||||
describe 'status_build' do
|
||||
before { @item = build_list.items.create(:name => build_list.project.name, :version => build_list.project_version, :level => 0) }
|
||||
|
||||
def do_get
|
||||
get :status_build, :id => build_list.bs_id, :package_name => build_list.project.name, :status => BuildServer::SUCCESS, :container_path => '/path/to'
|
||||
build_list.reload
|
||||
@item.reload
|
||||
end
|
||||
|
||||
it { do_get; response.should be_ok }
|
||||
it { lambda{ do_get }.should change(@item, :status) }
|
||||
it { lambda{ do_get }.should change(build_list, :container_path) }
|
||||
it { lambda{ do_get }.should change(build_list, :notified_at) }
|
||||
end
|
||||
|
||||
describe 'pre_build' do
|
||||
def do_get
|
||||
get :pre_build, :id => build_list.bs_id
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get; response.should be_ok }
|
||||
it { lambda{ do_get }.should change(build_list, :status).to(BuildServer::BUILD_STARTED) }
|
||||
it { lambda{ do_get }.should change(build_list, :notified_at) }
|
||||
end
|
||||
|
||||
describe 'post_build' do
|
||||
def do_get(status)
|
||||
get :post_build, :id => build_list.bs_id, :status => status, :container_path => '/path/to'
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :container_path) }
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :notified_at) }
|
||||
|
||||
context 'with auto_publish' do
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISH) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
||||
end
|
||||
|
||||
context 'without auto_publish' do
|
||||
before { build_list.update_attribute(:auto_publish, false) }
|
||||
|
||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildServer::SUCCESS) }
|
||||
it { lambda{ do_get(BuildServer::ERROR) }.should change(build_list, :status).to(BuildServer::ERROR) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'circle_build' do
|
||||
def do_get
|
||||
get :circle_build, :id => build_list.bs_id, :container_path => '/path/to'
|
||||
build_list.reload
|
||||
end
|
||||
|
||||
it { do_get; response.should be_ok }
|
||||
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
||||
it { lambda{ do_get }.should change(build_list, :container_path) }
|
||||
it { lambda{ do_get }.should change(build_list, :notified_at) }
|
||||
end
|
||||
|
||||
describe 'new_bbdt' do
|
||||
before { @items = build_list.items }
|
||||
|
||||
def do_get
|
||||
get :new_bbdt, :id => 123, :web_id => build_list.id, :name => build_list.project.name, :is_circular => 1,
|
||||
:additional_repos => ActiveSupport::JSON.encode([{:name => 'build_repos'}, {:name => 'main'}]),
|
||||
:items => ActiveSupport::JSON.encode(0 => [{:name => build_list.project.name, :version => build_list.project_version}])
|
||||
build_list.reload
|
||||
@items.reload
|
||||
end
|
||||
|
||||
it { do_get; response.should be_ok }
|
||||
it { lambda{ do_get }.should change(build_list, :name).to(build_list.project.name) }
|
||||
it { lambda{ do_get }.should change(build_list, :additional_repos) }
|
||||
it { lambda{ do_get }.should change(@items, :first) }
|
||||
it { lambda{ do_get }.should change(build_list, :is_circle).to(true) }
|
||||
it { lambda{ do_get }.should change(build_list, :bs_id).to(123) }
|
||||
it { lambda{ do_get }.should change(build_list, :notified_at) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue