Skip to content

Add at least two approvals check for GitLab standards adherence

What does this MR do and why?

  1. Add at least two approvals check to Gitlab standard. This check is executed whenever approval rules are updated in merge request approval setting. It creates a row inside the projects_compliance_standards_adherence table storing the current compliance status for the project.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Test the project level settings

  1. Ensure that you have a GitLab Ultimate license.
  2. Enable feature flag Feature.enable(:compliance_adherence_report)
  3. Run Projects::ComplianceStandards::Adherence.for_check_name(:at_least_two_approvals).count inside rails console and ensure that the count is zero.
  4. Navigate to a project's Settings > Merge requests and then add 'Approval rules'. Set 'Approvals required' to 2 for 'All eligible user'.
  5. Run Projects::ComplianceStandards::Adherence.last inside rails console and ensure that a row with correct attributes for status, check_name, standard is created.
  6. Navigate to a project's Settings > Merge requests and then decrease the count of 'Approvals required' to 1.
  7. Run Projects::ComplianceStandards::Adherence.last inside rails console and ensure that the status column has been updated to fail from success.
  8. You can also test by creating custom approval rules. If the total of all the approvals required is greater than or equal to two the check passes otherwise it fails.

MR acceptance checklist

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

Closes #413231 (closed)

Merge request reports