Skip trace stream loading when coverage regex is absent
What does this MR do and why?
Ci::Build#update_coverage now returns early when coverage_regex is blank instead of calling trace.extract_coverage. This avoids unnecessary work since most builds have no coverage keyword in their CI config.
Before this change, extract_coverage was called unconditionally. Although it returns early when the regex is blank, it first builds the trace stream: loading the job_artifacts_trace association and either opening an archived trace file or constructing a ChunkedIO with an extra query. With the guard clause, none of this overhead runs for builds without a coverage regex, keeping the behavior identical while skipping work.
References
Screenshots or screen recordings
Not applicable, backend-only change.
How to set up and validate locally
-
In a Rails console, pick a build without a coverage regex and turn on SQL logging:
build = Ci::Build.where(coverage_regex: nil).last ActiveRecord::Base.logger = Logger.new($stdout) -
Run the method:
build.update_coverage # => nilBefore this change the log shows queries against
ci_job_artifactsandci_build_trace_chunks. After it, no queries run. -
Coverage stays
nil, as before, since there was no regex to extract with:build.coverage # => nil
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.