gitlab-org--gitlab-foss/app/workers/build_finished_worker.rb

40 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
queue_namespace :pipeline_processing
urgency :high
worker_resource_boundary :cpu
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
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)
ExpirePipelineCacheWorker.perform_async(build.pipeline_id) if build.pipeline.cacheable?
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
end
end
BuildFinishedWorker.prepend_if_ee('EE::BuildFinishedWorker')