Skip to content

Enforce code coverage % before merge

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

As a team lead, I want my project to have/enforce a minimum amount of test coverage, so that I can focus on larger issues for the project like code quality, are we delivering value to customers, etc.

Intended users

User experience goal

  • The Maintainer should be able to use the GitLab UI to set a minimum test coverage % for a project.
    • TBD - Is this the average percentage or by regex set in the settings?
  • A developer will see a message on the Merge Request page ( in the existing treatment shown below OR something new?) if the project will be below the set test coverage with the MR merged.

Screen_Shot_2020-12-29_at_8.03.38_AM

Proposal

  • Add interface to the CI/CD settings to set an optional minimum test coverage % (average and/or by regex setup)
  • Ensure that maintainers can override this requirement
  • Add to the existing interface or new interface on the MR page an alert about why a merge is blocked when test coverage would be below the threshold after the merge.
  • Update documentation for CI/CD settings and MR page
  • Track the number of projects with a set threshold

Further details

Since we're able to show test coverage in the MR widget (https://docs.gitlab.com/ee/user/project/pipelines/settings.html), we should consider enabling test coverage enforcement before accepting a merge request.

Permissions and Security

Only Maintainers and Owners will be able to set the threshold for a project.

Documentation

  • Update documentation for CI/CD settings
  • Update documentation for MR

Availability & Testing

  • It will be very important to ensure that an MR can still be merged by a project maintainer/owner similar to Security approvals

What does success look like, and how can we measure that?

Within 90 days of launch/tracking availability 100 projects have implemented a minimum test coverage threshold.

What is the type of buyer?

The user who cares about this is the Team Lead but is likely a ~"GitLab Core" tiered feature.

Is this a cross-stage feature?

Yes, this involves the devopscreate stage who works on the MR page.

Links / references

Coverage documentation

Edited by 🤖 GitLab Bot 🤖