#405: fail builds if no packages
This commit is contained in:
parent
544fc16c96
commit
f4987ad67b
|
@ -60,5 +60,24 @@ module AbfWorkerService
|
|||
end
|
||||
end
|
||||
|
||||
def filter_build_lists_without_packages(*build_lists)
|
||||
ids = []
|
||||
build_lists = build_lists.flatten.select do |build_list|
|
||||
sha1 = build_list.packages.pluck(:sha1).find do |sha1|
|
||||
!FileStoreService::File.new(sha1: sha1).exist?
|
||||
end
|
||||
if sha1.present?
|
||||
ids << build_list.id
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL)
|
||||
|
||||
build_lists
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -9,6 +9,12 @@ module AbfWorkerService
|
|||
|
||||
def create!
|
||||
cleanup_folder
|
||||
|
||||
if filter_build_lists_without_packages(build_list).blank?
|
||||
build_list.fail_publish_container
|
||||
return
|
||||
end
|
||||
|
||||
Resque.push(
|
||||
'publish_worker', # Low priority
|
||||
'class' => 'AbfWorker::PublishWorker',
|
||||
|
|
|
@ -237,24 +237,5 @@ module AbfWorkerService
|
|||
end
|
||||
end
|
||||
|
||||
def filter_build_lists_without_packages(build_lists)
|
||||
ids = []
|
||||
build_lists = build_lists.select do |build_list|
|
||||
sha1 = build_list.packages.pluck(:sha1).find do |sha1|
|
||||
!FileStoreService::File.new(sha1: sha1).exist?
|
||||
end
|
||||
if sha1.present?
|
||||
ids << build_list.id
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL)
|
||||
|
||||
build_lists
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -12,10 +12,18 @@ describe AbfWorkerService::Container do
|
|||
context '#create!' do
|
||||
|
||||
it 'creates task' do
|
||||
expect(build_list).to_not receive(:fail_publish_container)
|
||||
expect(Resque).to receive(:push)
|
||||
subject.create!
|
||||
end
|
||||
|
||||
it 'fails when no packages on FS' do
|
||||
expect(subject).to receive(:filter_build_lists_without_packages).and_return([])
|
||||
expect(build_list).to receive(:fail_publish_container)
|
||||
expect(Resque).to_not receive(:push)
|
||||
subject.create!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue