On MR merge, save a list of compliance violations that occurred at the point of merging
requested to merge 347324-on-mr-merge-save-a-list-of-compliance-violations-that-occurred-at-the-point-of-merging into master
What does this MR do and why?
This MR adds a new service worker to the EE PostMergeService
so when an MR is merged, we will asynchronously review the merged MR for any compliance violations and save these to the merge_requests_compliance_violations
table. These saved violations will be used by #347325 (closed).
We add a new feature flag so we can easily incrementally roll this out or roll this back to protect the merge process.
During testing it became apparent that the initial assumptions on data locations were incorrect so I have had to update the violation classes with:
- Updated
ApprovedByCommitter
andApprovedByMergeRequestAuthor
to useapproved_by_users
rather thanapprover_users
- Updated
ApprovedByInsufficientUsers
to use the merge request metrics data if it exists
How to set up and validate locally
- Enable the feature flag
compliance_violations_graphql_type
:echo "Feature.enable(:compliance_violations_graphql_type)" | bundle exec rails c
- Go to a projects general settings and make sure
Prevent approval by author.
is unticked under theMerge request approvals
section - Edit a file in the project and create a new merge request
- Use the merge requests author to approve the merge request and then merge it
- Wait for merging to be completed
- Check the
merge_request_compliance_violations
table to see it has been filled with three violations (reasons0
,1
and2
) for your merge request- Use a database GUI
- In your terminal enter
gdk psql
and then run the following query:SELECT * FROM merge_requests_compliance_violations;
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.
Related to #347324 (closed)
Edited by Robert Hunt