Commit ae349032 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'mo-refactor-pipeline-artifact-coverage' into 'master'

Refactor coverage report service

See merge request gitlab-org/gitlab!50424
parents bb2d4497 da5b1a23
......@@ -249,7 +249,7 @@ module Ci
after_transition any => ::Ci::Pipeline.completed_statuses do |pipeline|
pipeline.run_after_commit do
::Ci::Pipelines::CreateArtifactWorker.perform_async(pipeline.id)
::Ci::PipelineArtifacts::CoverageReportWorker.perform_async(pipeline.id)
end
end
......
# frozen_string_literal: true
module Ci
module Pipelines
class CreateArtifactService
module PipelineArtifacts
class CoverageReportService
def execute(pipeline)
return unless pipeline.can_generate_coverage_reports?
return if pipeline.has_coverage_reports?
......
......@@ -1077,7 +1077,7 @@
:weight: 1
:idempotent: true
:tags: []
- :name: pipeline_background:ci_pipeline_success_unlock_artifacts
- :name: pipeline_background:ci_pipeline_artifacts_coverage_report
:feature_category: :continuous_integration
:has_external_dependencies:
:urgency: :low
......@@ -1085,7 +1085,7 @@
:weight: 1
:idempotent: true
:tags: []
- :name: pipeline_background:ci_pipelines_create_artifact
- :name: pipeline_background:ci_pipeline_success_unlock_artifacts
:feature_category: :continuous_integration
:has_external_dependencies:
:urgency: :low
......
# frozen_string_literal: true
module Ci
module Pipelines
class CreateArtifactWorker
module PipelineArtifacts
class CoverageReportWorker
include ApplicationWorker
include PipelineBackgroundQueue
......@@ -10,7 +10,7 @@ module Ci
def perform(pipeline_id)
Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
Ci::Pipelines::CreateArtifactService.new.execute(pipeline)
Ci::PipelineArtifacts::CoverageReportService.new.execute(pipeline)
end
end
end
......
---
title: Rename coverage report sidekiq queue
merge_request: 50424
author:
type: changed
# frozen_string_literal: true
class MigrateCoverageReportWorker < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
sidekiq_queue_migrate 'ci_pipelines_create_artifact', to: 'ci_pipeline_artifacts_coverage_report'
end
def down
sidekiq_queue_migrate 'ci_pipeline_artifacts_coverage_report', to: 'ci_pipelines_create_artifact'
end
end
a83762c788d4ec007a26da386dc36bce16b60f5642ed3e6405482acfebefc1be
\ No newline at end of file
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe ::Ci::Pipelines::CreateArtifactService do
RSpec.describe ::Ci::PipelineArtifacts::CoverageReportService do
describe '#execute' do
subject { described_class.new.execute(pipeline) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe ::Ci::Pipelines::CreateArtifactWorker do
RSpec.describe ::Ci::PipelineArtifacts::CoverageReportWorker do
describe '#perform' do
subject { described_class.new.perform(pipeline_id) }
......@@ -11,7 +11,7 @@ RSpec.describe ::Ci::Pipelines::CreateArtifactWorker do
let(:pipeline_id) { pipeline.id }
it 'calls pipeline report result service' do
expect_next_instance_of(::Ci::Pipelines::CreateArtifactService) do |create_artifact_service|
expect_next_instance_of(::Ci::PipelineArtifacts::CoverageReportService) do |create_artifact_service|
expect(create_artifact_service).to receive(:execute)
end
......@@ -23,7 +23,7 @@ RSpec.describe ::Ci::Pipelines::CreateArtifactWorker do
let(:pipeline_id) { non_existing_record_id }
it 'does not call pipeline create artifact service' do
expect(Ci::Pipelines::CreateArtifactService).not_to receive(:execute)
expect(Ci::PipelineArtifacts::CoverageReportService).not_to receive(:execute)
subject
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