2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2017-08-21 12:16:51 +00:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 16:16:50 +00:00
|
|
|
queue_namespace :pipeline_processing
|
2020-03-02 18:07:42 +00:00
|
|
|
urgency :high
|
2019-10-30 15:14:17 +00:00
|
|
|
worker_resource_boundary :cpu
|
2020-06-24 18:09:03 +00:00
|
|
|
tags :requires_disk_io
|
2016-10-14 10:53:51 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-14 10:53:51 +00:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2019-01-17 15:08:36 +00:00
|
|
|
process_build(build)
|
2016-10-14 10:53:51 +00:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2019-01-17 15:08:36 +00:00
|
|
|
|
|
|
|
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)
|
2020-06-02 21:08:00 +00:00
|
|
|
Ci::BuildReportResultWorker.new.perform(build.id)
|
2019-01-17 15:08:36 +00:00
|
|
|
|
|
|
|
# We execute these async as these are independent operations.
|
|
|
|
BuildHooksWorker.perform_async(build.id)
|
|
|
|
ArchiveTraceWorker.perform_async(build.id)
|
2020-02-13 18:09:00 +00:00
|
|
|
ExpirePipelineCacheWorker.perform_async(build.pipeline_id) if build.pipeline.cacheable?
|
2019-02-20 21:29:48 +00:00
|
|
|
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
|
2019-01-17 15:08:36 +00:00
|
|
|
end
|
2016-10-14 10:53:51 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
BuildFinishedWorker.prepend_if_ee('EE::BuildFinishedWorker')
|