Class: GitlabQuality::TestTooling::CodeCoverage::PerTestCoverageExporter
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::CodeCoverage::PerTestCoverageExporter
- Defined in:
- lib/gitlab_quality/test_tooling/code_coverage/per_test_coverage_exporter.rb
Overview
Standalone per-test coverage export: inserts per-test, per-source-file rows into ‘code_coverage.test_coverage_per_file` and, unless skipped, runs the daily `test_health_risk` aggregation.
Unlike the full coverage-metrics export, this path needs only ClickHouse credentials and the per-test coverage glob, not the LCOV report, the Crystalball test map, or the responsibility patterns. Category enrichment (feature_category/group/stage/section per row) is optional: pass ‘test_reports` to map test files to feature categories via the test report JSON, otherwise those columns stay blank.
‘skip_aggregation` lets a batched caller insert without re-running the table-wide aggregation on every batch. The streaming export invokes this once per artifact batch with `skip_aggregation: true`, then runs the aggregation once at the end.
Instance Method Summary collapse
-
#initialize(coverage_glob:, clickhouse:, test_reports: nil, jest_quarantine_file: nil, captured_sha: ENV.fetch('CI_COMMIT_SHA', ''), skip_aggregation: false, logger: nil) ⇒ PerTestCoverageExporter
constructor
A new instance of PerTestCoverageExporter.
- #run ⇒ void
Constructor Details
#initialize(coverage_glob:, clickhouse:, test_reports: nil, jest_quarantine_file: nil, captured_sha: ENV.fetch('CI_COMMIT_SHA', ''), skip_aggregation: false, logger: nil) ⇒ PerTestCoverageExporter
Returns a new instance of PerTestCoverageExporter.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/per_test_coverage_exporter.rb', line 26 def initialize( coverage_glob:, clickhouse:, test_reports: nil, jest_quarantine_file: nil, captured_sha: ENV.fetch('CI_COMMIT_SHA', ''), skip_aggregation: false, logger: nil) @coverage_glob = coverage_glob @clickhouse = clickhouse @test_reports = test_reports @jest_quarantine_file = jest_quarantine_file @captured_sha = captured_sha.to_s @skip_aggregation = skip_aggregation @logger = logger || ::Logger.new($stdout) end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gitlab_quality/test_tooling/code_coverage/per_test_coverage_exporter.rb', line 40 def run coverage_files = Dir.glob(coverage_glob) if coverage_files.empty? logger.info( "#{ClickHouse::LOG_PREFIX} No per-test coverage artifacts matched #{coverage_glob}; nothing to export." ) return end insert(coverage_files) ingest_jest_quarantine aggregate unless skip_aggregation end |