Submitting a Merge Request#
git push prints a URL to the terminal that you can use to start a merge request.
Alternatively, use GitLab’s web interface.
The default target branch is
main; if your branch started fromrelease, select that as the target branch.If the merge request resolves an outstanding issue, include a closing pattern such as
Closes #123in the MR’s description to automatically have the issue closed when the MR is merged [1] .
If you are not contributing from a fork:
Select appropriate labels including a workflow label.
Assign yourself to the MR.
Select reviewers for the MR; clicking on
> Approval Ruleswill list appropriate reviewers.If the branch started from
releaseselect themilestoneofVxx.yy-release-fixesFor changes only to documentation, add the
docs-onlylabel, which will trigger a modified pipeline to build a preview of the documentation automatically. Any warnings from Sphinx will cause the pipeline to fail. Once completed, click “View App” on the right side in the middle of the MR page.For changes limited to petsc4py, add the
petsc4py-onlylabel to run the petsc4py build/test configurations, installation and pip checks, and documentation preview, together with the source and CI checks. Thedocs-onlylabel takes precedence if both labels are present. Removepetsc4py-onlyto restore the full pipeline.Once the MR has been submitted, refresh the browser and select Pipelines to examine and run testing; see GitLab CI Pipelines.
For MRs from forks:
Make sure the fork is public – as GitLab merge request process does not work well with a private fork.
Select the correct target repository
petsc/petscalong with the target branch.Select the “Allow commits from members who can merge to the target branch” option.
Pipelines for MRs from forks run only after a developer starts them, because they use PETSc’s test machines.
GitLab does not allow you to set labels, so
@-mention one of the developers in a comment so they can assign someone to the MR to add labels, run pipelines, and generally assist with the MR. The assignee and submitter should be listed in the upper right corner as assignees to the MR.
Workflow labels#
The MR process, including testing and reviewing, is managed by workflow labels that indicate the state of the MR. Every MR should have exactly one of these labels.
The standard workflow has three steps.
workflow::Pipeline-TestingThe user is testing their branch. Generally, unless asked, no one else has a reason to look at such an MR.workflow::ReviewThe user would like their branch reviewed.workflow::Ready-For-MergeThe MR has passed all tests, passed the review, has no outstanding threads, and has a clean commit history.
The submitter/assignee of the MR is responsible for changing the workflow label appropriately during the MR process.
Some MRs may begin with either of the following workflow states.
workflow::Request-For-CommentThe branch is not being requested to be merged, but the user would like feedback on the branch. You do not need to test the code in this state.workflow::In-DevelopmentThe developer is working on the branch. Other developers not involved in the branch generally have no reason to look at these MRs.
These should also be marked as “Draft” on the MR page.
The developer usually eventually converts these two states to workflow::Review.
You can run the pipelines on an MR in any workflow state.
MR reviewing#
Once the MR has passed the pipeline, it is ready for review.
The submitter/assignee must change the workflow label to workflow::Review.
It is the submitter/assignee’s responsibility to track the progress of the MR and ensure it gets merged.
If the pipeline detects problems, it is the submitter/assignee’s responsibility to fix the errors.
Reviewers comment on the MR, either
by clicking on the left end of a specific line in the
Changeswindow. A useful feature is the “insert suggestion” button in the comment box, to suggest an exact replacement on a line or several adjacent lines.or in the overview if it is a general comment. When introducing a new topic (thread) in reviewing an MR, one should submit with “Start Review” and not “Comment”.
GitLab MRs use “threads” to track discussions. When responding to a thread, make sure to use the “Reply” box for that thread; do not introduce a new thread or a comment.
In addition to human reviewers, developers can start LLM reviews of the MR from the pipeline; see LLM review jobs. Treat their findings like those of any other reviewer, but expect some false positives.
Updating the MR in response to CI failures and reviews describes how to respond to the reviews and to pipeline failures.
If the submitter/assignee feels the MR is not getting reviewed in a timely manner, they may assign additional reviewers to the MR and request in the MR discussion these same people to review by @-mentioning them.
When reviewers believe an MR is ready to be merged, they approve it. You can determine who must approve your MR by clicking on the “View eligible reviewers” towards the top of the “Overview” page.
When a sufficient number of reviewers has approved the merge, the pipeline passes, new commits have been properly rearranged if needed, and all threads have been resolved, the submitter/assignee must set the label to workflow::Ready-For-Merge.
Updating the MR in response to CI failures and reviews#
Most MRs go through several rounds of changes before they are merged. In each round, the submitter/assignee:
Reads the failed pipeline jobs (GitLab CI Pipelines) and the unresolved threads.
Fixes the problems on the local branch, and checks the fixes locally with the tests and source checks described in Developing a Merge Request.
Pushes the branch. If the branch history was rewritten, for example to keep the history clean, use
git push -f. To run only the jobs that failed, runlib/petsc/bin/maint/runjobs.pybefore the push, and remove its temporary commit after the pipeline finishes.Replies in each thread with what was changed, or why no change is necessary, and marks the thread as resolved when the problem is fixed. If a reviewer suggested an exact replacement, the “Apply suggestion” button commits it directly to the branch; get that commit with
git pull --ff-onlybefore you change the branch locally.Runs the pipeline again, unless
runjobs.pyalready started the failed jobs.
After a push, the “Changes” tab of the MR can compare any two versions of the branch, which lets reviewers see only what changed since their last review.
An LLM harness such as Claude Code can read the failed job logs, the threads, and the LLM review reports, and then make many of these fixes for you; see Using LLM Harnesses such as Claude Code with GitLab CI and Merge Requests.
Footnotes