Skip to content

Expand scope of coverage badge pipeline query

drew stachon requested to merge more-coverage-badges into master

What does this MR do?

This MR allows for coverage badge values to be pulled from successful coverage jobs, regardless of the pipeline status, when the job name is passed in the request. This will allow for the coverage value to be rendered more often in high-volume projects that often have running pipelines, and in projects where failing pipelines have meaningful coverage.

Original issue: #27090 (closed)

Does this MR meet the acceptance criteria?

Query Analysis

The new query, directly to the builds table, looks like this:

SELECT
    "ci_builds".*
FROM
    "ci_builds"
WHERE
    "ci_builds"."type" = "Ci::Build"
    AND "ci_builds"."project_id" = 1
    AND ("ci_builds"."retried" = FALSE
        OR "ci_builds"."retried" IS NULL)
    AND ("ci_builds"."status" IN ('success'))
    AND "ci_builds"."ref" = "master"
    AND "ci_builds"."name" = "coverage"
ORDER BY
    ci_builds.id DESC
LIMIT 1

and the execution plan:

 Limit  (cost=3.73..3.73 rows=1 width=1544) (actual time=10.798..10.798 rows=0 loops=1)
   Buffers: shared hit=3 read=5
   I/O Timings: read=10.678
   ->  Sort  (cost=3.73..3.73 rows=1 width=1544) (actual time=10.796..10.797 rows=0 loops=1)
         Sort Key: ci_builds.id DESC
         Sort Method: quicksort  Memory: 25kB
         Buffers: shared hit=3 read=5
         I/O Timings: read=10.678
         ->  Index Scan using index_ci_builds_on_project_id_and_name_and_ref on public.ci_builds  (cost=0.70..3.72 rows=1 width=1544) (actual time=10.744..10.744 rows=0 loops=1)
               Index Cond: ((ci_builds.project_id = 1) AND ((ci_builds.name)::text = 'coverage'::text) AND ((ci_builds.ref)::text = 'master'::text))
               Buffers: shared read=5

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • ~~Label as security and @ mention @gitlab-com/gl-security/appsec~~
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods"🍉"
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by drew stachon

Merge request reports