Commit 2d24a2db authored by Sean McGivern's avatar Sean McGivern

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

Refactor pipeline artifacts logic

See merge request gitlab-org/gitlab!40983
parents 5489973f cc9bf431
......@@ -878,7 +878,11 @@ module Ci
end
def has_coverage_reports?
self.has_reports?(Ci::JobArtifact.coverage_reports)
pipeline_artifacts&.has_code_coverage?
end
def can_generate_coverage_reports?
has_reports?(Ci::JobArtifact.coverage_reports)
end
def test_report_summary
......
......@@ -1372,7 +1372,7 @@ class MergeRequest < ApplicationRecord
def has_coverage_reports?
return false unless Feature.enabled?(:coverage_report_view, project)
actual_head_pipeline&.pipeline_artifacts&.has_code_coverage?
actual_head_pipeline&.has_coverage_reports?
end
def has_terraform_reports?
......
......@@ -4,8 +4,8 @@ module Ci
class CreateArtifactService
def execute(pipeline)
return unless ::Gitlab::Ci::Features.coverage_report_view?(pipeline.project)
return unless pipeline.has_coverage_reports?
return if pipeline.pipeline_artifacts.has_code_coverage?
return unless pipeline.can_generate_coverage_reports?
return if pipeline.has_coverage_reports?
file = build_carrierwave_file(pipeline)
......
......@@ -2945,6 +2945,22 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
describe '#has_coverage_reports?' do
subject { pipeline.has_coverage_reports? }
context 'when pipeline has a code coverage artifact' do
let(:pipeline) { create(:ci_pipeline, :with_coverage_report_artifact, :running, project: project) }
it { expect(subject).to be_truthy }
end
context 'when pipeline does not have a code coverage artifact' do
let(:pipeline) { create(:ci_pipeline, :success, project: project) }
it { expect(subject).to be_falsey }
end
end
describe '#can_generate_coverage_reports?' do
subject { pipeline.can_generate_coverage_reports? }
context 'when pipeline has builds with coverage reports' do
before do
create(:ci_build, :coverage_reports, pipeline: pipeline, project: project)
......
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