Class: Gitlab::Ci::Reports::CoverageReportGenerator

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/reports/coverage_report_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(pipeline) ⇒ CoverageReportGenerator

Returns a new instance of CoverageReportGenerator.



9
10
11
# File 'lib/gitlab/ci/reports/coverage_report_generator.rb', line 9

def initialize(pipeline)
  @pipeline = pipeline
end

Instance Method Details

#reportObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/ci/reports/coverage_report_generator.rb', line 13

def report
  coverage_report = Gitlab::Ci::Reports::CoverageReport.new

  # Return an empty report if the pipeline is a child pipeline.
  # Since the coverage report is used in a merge request report,
  # we are only interested in the coverage report from the root pipeline.
  return coverage_report if @pipeline.child?

  coverage_report.tap do |coverage_report|
    report_builds.find_each do |build|
      build.each_report(::Ci::JobArtifact.file_types_for_report(:coverage)) do |file_type, blob|
        Gitlab::Ci::Parsers.fabricate!(file_type).parse!(
          blob,
          coverage_report,
          project_path: @pipeline.project.full_path,
          worktree_paths: @pipeline.all_worktree_paths
        )
      end
    end
  end
end