Merge pull request #106 from warpc/103-bl_publish_new_params
Сохранение сборочного коммита, добавление неподписанного тега на сохраненный коммит после публикации
This commit is contained in:
commit
62d0419bdd
|
@ -39,6 +39,7 @@ class BuildListsController < ApplicationController
|
||||||
Arch.where(:id => params[:arches]).each do |arch|
|
Arch.where(:id => params[:arches]).each do |arch|
|
||||||
Platform.main.where(:id => params[:bpls]).each do |bpl|
|
Platform.main.where(:id => params[:bpls]).each do |bpl|
|
||||||
@build_list = @project.build_lists.build(params[:build_list])
|
@build_list = @project.build_lists.build(params[:build_list])
|
||||||
|
@build_list.commit_hash = @project.git_repository.commits(@build_list.project_version.match(/(.+)_latest$/).to_a.last || @build_list.project_version).first.id
|
||||||
@build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user
|
@build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user
|
||||||
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl}
|
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl}
|
||||||
if @build_list.save
|
if @build_list.save
|
||||||
|
@ -83,6 +84,8 @@ class BuildListsController < ApplicationController
|
||||||
if params[:status].to_i == 0 # ok
|
if params[:status].to_i == 0 # ok
|
||||||
@build_list.status = BuildList::BUILD_PUBLISHED
|
@build_list.status = BuildList::BUILD_PUBLISHED
|
||||||
@build_list.package_version = "#{params[:version]}-#{params[:release]}"
|
@build_list.package_version = "#{params[:version]}-#{params[:release]}"
|
||||||
|
system("cd #{@build_list.project.git_repository.path} &&
|
||||||
|
git tag -a -m '#{@build_list.package_version}' #{@build_list.package_version} #{@build_list.commit_hash}") # TODO REDO through grit
|
||||||
else
|
else
|
||||||
@build_list.status = BuildList::FAILED_PUBLISH
|
@build_list.status = BuildList::FAILED_PUBLISH
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
class AddCommitHashToBuildLists < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :build_lists, :commit_hash, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :build_lists, :commit_hash
|
||||||
|
end
|
||||||
|
end
|
|
@ -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 => 20120113151305) do
|
ActiveRecord::Schema.define(:version => 20120113212924) 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
|
||||||
|
@ -73,6 +73,7 @@ ActiveRecord::Schema.define(:version => 20120113151305) do
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.boolean "auto_publish", :default => true
|
t.boolean "auto_publish", :default => true
|
||||||
t.string "package_version"
|
t.string "package_version"
|
||||||
|
t.string "commit_hash"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||||
|
|
|
@ -27,6 +27,8 @@ describe BuildListsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'create build list' do
|
shared_examples_for 'create build list' do
|
||||||
|
before {test_git_commit(@project)}
|
||||||
|
|
||||||
it 'should be able to perform new action' do
|
it 'should be able to perform new action' do
|
||||||
get :new, :project_id => @project.id
|
get :new, :project_id => @project.id
|
||||||
response.should render_template(:new)
|
response.should render_template(:new)
|
||||||
|
@ -36,6 +38,17 @@ describe BuildListsController do
|
||||||
post :create, {:project_id => @project.id}.merge(@create_params)
|
post :create, {:project_id => @project.id}.merge(@create_params)
|
||||||
response.should redirect_to(@project)
|
response.should redirect_to(@project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should save correct commit_hash for branch based build' do
|
||||||
|
post :create, {:project_id => @project.id}.merge(@create_params).deep_merge(:build_list => {:project_version => "master_latest"})
|
||||||
|
@project.build_lists.last.commit_hash.should == @project.git_repository.commits('master').last.id
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should save correct commit_hash for tag based build' do
|
||||||
|
system("cd #{@project.git_repository.path} && git tag -a -m '4.7.5.3' 4.7.5.3") # TODO REDO through grit
|
||||||
|
post :create, {:project_id => @project.id}.merge(@create_params).deep_merge(:build_list => {:project_version => "4.7.5.3"})
|
||||||
|
@project.build_lists.last.commit_hash.should == @project.git_repository.commits('4.7.5.3').last.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shared_examples_for 'not create build list' do
|
shared_examples_for 'not create build list' do
|
||||||
|
@ -57,7 +70,7 @@ describe BuildListsController do
|
||||||
platform = Factory(:platform_with_repos)
|
platform = Factory(:platform_with_repos)
|
||||||
@create_params = {
|
@create_params = {
|
||||||
:build_list => {
|
:build_list => {
|
||||||
:project_version => 'v1.0',
|
:project_version => 'master_latest',
|
||||||
:pl_id => platform.id,
|
:pl_id => platform.id,
|
||||||
:update_type => 'security',
|
:update_type => 'security',
|
||||||
:include_repos => [platform.repositories.first.id]
|
:include_repos => [platform.repositories.first.id]
|
||||||
|
@ -299,12 +312,14 @@ describe BuildListsController do
|
||||||
let(:build_list) { Factory(:build_list_core) }
|
let(:build_list) { Factory(:build_list_core) }
|
||||||
|
|
||||||
describe 'publish_build' do
|
describe 'publish_build' do
|
||||||
|
before {test_git_commit(build_list.project); build_list.update_attribute :commit_hash, build_list.project.git_repository.commits.last.id}
|
||||||
|
|
||||||
def do_get(status)
|
def do_get(status)
|
||||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
||||||
build_list.reload
|
build_list.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it { do_get(BuildServer::SUCCESS); response.should be_ok }
|
it { do_get(BuildServer::SUCCESS); build_list.project.git_repository.tags.last.name.should == build_list.package_version; response.should be_ok }
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :status).to(BuildList::BUILD_PUBLISHED) }
|
||||||
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to('4.7.5.3-1') }
|
it { lambda{ do_get(BuildServer::SUCCESS) }.should change(build_list, :package_version).to('4.7.5.3-1') }
|
||||||
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, :status).to(BuildList::FAILED_PUBLISH) }
|
||||||
|
|
|
@ -8,6 +8,7 @@ Factory.define(:build_list) do |p|
|
||||||
p.build_requires true
|
p.build_requires true
|
||||||
p.update_type 'security'
|
p.update_type 'security'
|
||||||
p.include_repos {|bl| bl.pl.repositories.map(&:id)}
|
p.include_repos {|bl| bl.pl.repositories.map(&:id)}
|
||||||
|
p.commit_hash 'e681644ed702fae285483d2ca73d85ee2930b8de'
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define(:build_list_core, :parent => :build_list) do |p|
|
Factory.define(:build_list_core, :parent => :build_list) do |p|
|
||||||
|
|
|
@ -37,6 +37,11 @@ def stub_rsync_methods
|
||||||
any_instance_of(Platform, :umount_directory_for_rsync => true)
|
any_instance_of(Platform, :umount_directory_for_rsync => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_git_commit(project)
|
||||||
|
project.git_repository.repo.index.add('test', 'TEST')
|
||||||
|
project.git_repository.repo.index.commit('Test commit')
|
||||||
|
end
|
||||||
|
|
||||||
Delayed::Worker.delay_jobs = false # Execute all jobs realtime
|
Delayed::Worker.delay_jobs = false # Execute all jobs realtime
|
||||||
|
|
||||||
# Add testing root_path
|
# Add testing root_path
|
||||||
|
|
Loading…
Reference in New Issue