Draft: Track the latest commit with a valid CI config for merge requests
What does this MR do and why?
Track the latest commit with a valid CI config for merge requests
This adds a new pair of columns mr_ci_config_source_branch_sha
and push_ci_config_source_branch_sha
to the
merge_requests
table, representing the SHA of the latest commit on the
source branch for which a GitLab pipeline configuration was processed,
for merge request events and push events, respectively.
This allows us to differentiate between the following two cases when the source branch has no pipeline SHA:
- No pipeline was created, but the configuration is technically valid (i.e. this SHA matches the source branch head SHA)
- No pipeline has been created yet (i.e. this SHA does not match the source branch HEAD SHA)
In the former case, we want to optionally allow merges when "Pipelines must succeed" is selected, whereas in the latter case we should not allow merging.
Part of #334281
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
-
Enable the flag
Feature.enable(:track_mr_ci_config_source_branch_sha)
-
Create a merge request in a project, changing
.gitlab-ci.yml
to the following:job: script: echo hi rules: - if: $THIS_VARIABLE_IS_NOT_SET
-
Grab the MR in the rails console, and observe that the columns got updated and that the new methods work as expected:
project = Projects.find_by_full_path(project_path) mr = project.merge_requests.find_by_iid(mr_iid) # mr_iid is the number in the MR URL puts mr.ci_config_source_branch_sha puts mr.processed_latest_ci_config?
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.