Skip to content

Add backend support for Coverage-Check rule

Erick Bajao requested to merge eb-code-coverage-approvals into master

What does this MR do?

Solves #15765 (closed)

This MR adds the backend support for the new MR approval rule named Coverage-Check.

Note that we only support coverage regex defined through the CI YAML config, and not through the project setting.

This MR is heavily inspired by !59698 (closed). The difference is that we do not want to rely on the coverage report artifact but rather compare the base and head pipelines coverage values.

Raw SQL

This is the SQL generated when fetching the builds in pipeline.update_builds_coverage:

SELECT
    "ci_builds".*
FROM
    "ci_builds"
WHERE
    "ci_builds"."type" = 'Ci::Build'
    AND "ci_builds"."commit_id" = 313784471
    AND "ci_builds"."coverage_regex" IS NOT NULL
    AND "ci_builds"."coverage" IS NULL

query plan: https://explain-depesz.postgres.ai/s/HeV

Screenshots (strongly suggested)

Sample screenshot when coverage is not lower than the base pipeline's: Screen_Shot_2021-06-02_at_11.06.33_PM

Sample screenshot when coverage is lower than the base pipeline's: Screen_Shot_2021-06-02_at_11.02.41_PM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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 Saikat Sarkar

Merge request reports