Skip to content

Add ability to filter compliance violations by target branch

What does this MR do and why?

  1. Add a scope to filter merge request compliance violations by target branch.
  2. Update GraphQL API and added a new argument targetBranch to use the new scope and filter compliance violations by target branch.

Database query

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17746/commands/59194

Screenshots or screen recordings

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

How to set up and validate locally

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

  1. Ensure that you have an ultimate license and some compliance violations in the database OR run FILTER=compliance_report_violations rake db:seed_fu to seed some compliance violations.
  2. Visit GraphiQL explorer and run the following query:
query getComplianceViolations {
  group(fullPath: "flightjs") {
    mergeRequestViolations(filters: {mergedAfter: "2023-01-31"}) {
      nodes {
        id,
        severityLevel,
        reason,
        violatingUser {
          name
        },
        mergeRequest {
          iid
          targetBranch
        }
      }
    }
  }
}

Note the target_branch values from the result. 2. Now update the query to add the target_branch filter

query getComplianceViolations {
  group(fullPath: "flightjs") {
    mergeRequestViolations(filters: {targetBranch: "main", mergedAfter: "2023-01-31"}) {
      nodes {
        id,
        severityLevel,
        reason,
        violatingUser {
          name
        },
        mergeRequest {
          iid
          targetBranch
        }
      }
    }
  }
}

Ensure that the results only contain the violations associated with the target branch "main" (there could be no results as well) in case there are no violations associated with target branch named "main".

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 #358412 (closed)

Edited by Huzaifa Iftikhar

Merge request reports