Skip to content

Use numeric value for pipeline coverage and pipeline coverage delta

What does this MR do and why?

Use numeric value in pipeline coverage to ensure coverage approval rule requirement is not removed when the coverage has decreased.

This fixes bug where pipeline coverage comparison was previously comparing string values, leading to unexpected result in comparison such as '5' < '10'.

As a result, the coverage approval rule requirement was removed even though the coverage has decreased.

Changing to a numeric value requires updating the presentation to format the value into a string with 2 decimals.

Screenshots or screen recordings

Before: Screenshot_2021-11-26_at_4.49.21_PM

After: Screenshot_2021-11-26_at_4.49.30_PM

How to set up and validate locally

  1. Create a project with CI pipeline that has a coverage (e.g 10)
test:
  stage: test
  script:
    - echo "Code coverage is 10%"
  coverage: '/^Code coverage is ([^%]+)/'
  1. Enable merge request approval rule for code coverage
  2. Create a merge request that reduces coverage to single digit that is greater than 1
test:
  stage: test
  script:
    - echo "Code coverage is 9%"
  coverage: '/^Code coverage is ([^%]+)/'
  1. The merge request should require manual approval based on the code coverage rule

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #345386 (closed)

Edited by Albert

Merge request reports

Loading