Refactor BuildFinishedWorker for EE

This simply moves the logic from the "perform" method into a separate
"process_build" method, allowing EE to more easily extend this
behaviour.
This commit is contained in:
Yorick Peterse 2019-01-17 16:08:36 +01:00
parent d56b76a52d
commit d67d0dfb2b
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
1 changed files with 19 additions and 7 deletions

View File

@ -9,14 +9,26 @@ class BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
# We execute that in sync as this access the files in order to access local file, and reduce IO
BuildTraceSectionsWorker.new.perform(build.id)
BuildCoverageWorker.new.perform(build.id)
# We execute that async as this are two independent operations that can be executed after TraceSections and Coverage
BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.perform_async(build.id)
process_build(build)
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
# Processes a single CI build that has finished.
#
# This logic resides in a separate method so that EE can extend it more
# easily.
#
# @param [Ci::Build] build The build to process.
def process_build(build)
# We execute these in sync to reduce IO.
BuildTraceSectionsWorker.new.perform(build.id)
BuildCoverageWorker.new.perform(build.id)
# We execute these async as these are independent operations.
BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.perform_async(build.id)
end
end