Save commit_hash during build_list create. Tag git repo during build_list publish. Write and fix specs. Refs #103
This commit is contained in:
parent
712ca8d95a
commit
a687a6601b
|
@ -39,6 +39,7 @@ class BuildListsController < ApplicationController
|
|||
Arch.where(:id => params[:arches]).each do |arch|
|
||||
Platform.main.where(:id => params[:bpls]).each do |bpl|
|
||||
@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
|
||||
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl}
|
||||
if @build_list.save
|
||||
|
@ -83,6 +84,8 @@ class BuildListsController < ApplicationController
|
|||
if params[:status].to_i == 0 # ok
|
||||
@build_list.status = BuildList::BUILD_PUBLISHED
|
||||
@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
|
||||
@build_list.status = BuildList::FAILED_PUBLISH
|
||||
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.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120113151305) do
|
||||
ActiveRecord::Schema.define(:version => 20120113212924) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -73,6 +73,7 @@ ActiveRecord::Schema.define(:version => 20120113151305) do
|
|||
t.integer "user_id"
|
||||
t.boolean "auto_publish", :default => true
|
||||
t.string "package_version"
|
||||
t.string "commit_hash"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||
|
|
|
@ -27,6 +27,8 @@ describe BuildListsController do
|
|||
end
|
||||
|
||||
shared_examples_for 'create build list' do
|
||||
before {test_git_commit(@project)}
|
||||
|
||||
it 'should be able to perform new action' do
|
||||
get :new, :project_id => @project.id
|
||||
response.should render_template(:new)
|
||||
|
@ -34,6 +36,7 @@ describe BuildListsController do
|
|||
|
||||
it 'should be able to perform create action' do
|
||||
post :create, {:project_id => @project.id}.merge(@create_params)
|
||||
@project.build_lists.last.commit_hash.should == @project.git_repository.commits.last.id
|
||||
response.should redirect_to(@project)
|
||||
end
|
||||
end
|
||||
|
@ -57,7 +60,7 @@ describe BuildListsController do
|
|||
platform = Factory(:platform_with_repos)
|
||||
@create_params = {
|
||||
:build_list => {
|
||||
:project_version => 'v1.0',
|
||||
:project_version => 'master_latest',
|
||||
:pl_id => platform.id,
|
||||
:update_type => 'security',
|
||||
:include_repos => [platform.repositories.first.id]
|
||||
|
@ -299,12 +302,14 @@ describe BuildListsController do
|
|||
let(:build_list) { Factory(:build_list_core) }
|
||||
|
||||
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)
|
||||
get :publish_build, :id => build_list.bs_id, :status => status, :version => '4.7.5.3', :release => '1'
|
||||
build_list.reload
|
||||
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, :package_version).to('4.7.5.3-1') }
|
||||
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.update_type 'security'
|
||||
p.include_repos {|bl| bl.pl.repositories.map(&:id)}
|
||||
p.commit_hash 'e681644ed702fae285483d2ca73d85ee2930b8de'
|
||||
end
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
# Add testing root_path
|
||||
|
|
Loading…
Reference in New Issue