Commit c4bde1c3 authored by Yorick Peterse's avatar Yorick Peterse

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.
parent afb5b9d2
......@@ -9,18 +9,28 @@ class BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
UpdateBuildMinutesService.new(build.project, nil).execute(build)
process_build(build)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# We execute that in sync as this access the files in order to access local file, and reduce IO
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 that async as this are two independent operations that can be executed after TraceSections and Coverage
# We execute these async as these are independent operations.
BuildHooksWorker.perform_async(build.id)
ArchiveTraceWorker.perform_async(build.id)
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
BuildFinishedWorker.prepend(EE::BuildFinishedWorker)
......@@ -2,14 +2,12 @@
module EE
module BuildFinishedWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
def process_build(build)
UpdateBuildMinutesService.new(build.project, nil).execute(build)
super
::Ci::Build.find_by(id: build_id).try do |build|
ChatNotificationWorker.perform_async(build_id) if build.pipeline.chat?
end
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment