Add at least two approvals check for GitLab standards adherence
What does this MR do and why?
- 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
- Ensure that you have a GitLab Ultimate license.
- Enable feature flag
Feature.enable(:compliance_adherence_report)
- Run
Projects::ComplianceStandards::Adherence.for_check_name(:at_least_two_approvals).count
inside rails console and ensure that the count is zero. - Navigate to a project's Settings > Merge requests and then add 'Approval rules'. Set 'Approvals required' to 2 for 'All eligible user'.
- Run
Projects::ComplianceStandards::Adherence.last
inside rails console and ensure that a row with correct attributes for status, check_name, standard is created. - Navigate to a project's Settings > Merge requests and then decrease the count of 'Approvals required' to 1.
- Run
Projects::ComplianceStandards::Adherence.last
inside rails console and ensure that thestatus
column has been updated tofail
fromsuccess
. - 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.
-
I have evaluated the MR acceptance checklist for this MR.
Closes #413231 (closed)