Track deployed merge requests in the database
What does this MR do?
This adds tracking of merged requests when creating deployments. These changes are hidden behind a feature flag at the moment, and no UI or APIs have been added yet.
By tracking merge requests, developers will eventually be able to easily see when their merge requests made it into a certain environment. This data also allows for more accurate measuring of the time between a merge request getting merged and deployed to a certain environment.
Fixes #32584 (closed)
How is data tracked
For the first deployment to an environment, we take the branch name that is deployed and record all merge requests merged (directly) into that branch. This is needed because there is no commit that we can compare to. The first commit in the repository would not work, as the list of commits easily gets too big (e.g. in the case of GitLab itself this would involve over 150 000 commits).
When there is a previous deployment, we gather all the commits since that deployment (on the branch that is deployed), up until (and including) the commit that triggered the deployment. We then retrieve all merge requests that created these commits.
The changes in this MR are behind a project feature flag called
deployment_merge_requests. We will keep this feature flag around until we
are comfortable with how we collect the data, and have determined it to be
- Write end to end test for the deployments API and tracking of merge requests