When using a merge queue, it can be difficult to ensure that urgent pull requests are merged quickly. This is especially true for teams that have a large number of pull requests or that are working on critical projects.
It can be very frustrating to wait for all the pull requests that are already in the queue to be merged.
Indeed, merging a 'Feature' Pull Request while a bug fix is pending does not make sense, as it could create even more bugs and code regressions, leading you to reverts; therefore, fixes must be merged first, then features.
Fortunately, Mergify Merge Queue's multiple queues & priority rules features provide a powerful help to maintain control over the merging process. They allow you to create different queues with unique configurations, enabling urgent tasks to be prioritized and merged quickly.
Let's see how they work.
In order to explore how Multiple Queues and Priority Rules work, let's take a practical case:
- you have a merge queue setup on your repository,
- you have, let's say, 50 pull requests in your queue. Each one will have to wait for a CI that takes 1 minute to run to successfully finish before merging,
- now you have a bug fix pull request that needs to be merged as quickly as possible and you don't want to wait 50 minutes at least before it's merged.
Multiple Queues 👯
Mergify Merge Queue offers the possibility to have multiple queues through its `queue_rules` parameter. Mergify's multiple queues system is a powerful tool for managing a large number of pull requests.
In essence, it allows you to create different queues, each with its unique configuration, set of rules, and priorities. You can have as many types of queues as you want.
The processing of queues is done in the order they are defined and that's our point here. The first queue listed in your configuration is considered the highest priority queue. This means that all pull requests in this queue will be processed before moving on to the next queue. Mergify starts processing from the highest priority queue and then moves down to lower priority queues.
One of the essential features of Mergify's multiple queues is the dynamic handling of queue priorities. By default, when a pull request enters a queue that has a higher precedence over the one currently being processed, the processing of the current queue gets interrupted, and the higher precedence queue takes over. This ensures that your most critical pull requests are processed as soon as possible, regardless of what else is happening.
Now back to our case. You could setup up queue rules like this for instance.
- name: urgent
# This can be queued before CI finishes its first run
# if the PR has the urgent label
- label = urgent
# We still want the CI to pass to merge the PR
- check-success = my_one_minute_CI
- name: standard
# CI is needed for queueing and merging the PR
- check-success = my_one_minute_CI
With this configuration, you had the urgent label to your bug fix pull request and it will enter the urgent queue, while the 50 other pull requests are in the standard queue. Mergify will then stop evaluating the standard queue and take care of what is in the urgent queue as soon as your bug fix pull request passes the CI it will be merged.
Congrats! Your bug fix is merged in 1 minute instead of at least 50 minutes without leaving your usual workflow!
If you want to know more about multiple queues, I invite you to take a look at our documentation.
Priority Rules 🚦
Priority rules in Mergify are a set of guidelines that determine the order of pull requests within a merge queue.
They apply a priority to a pull request based on the conditions you've defined. When a pull request is added to a queue, each priority rule is evaluated against its conditions. This assessment determines where the pull request will be placed in the queue.
If multiple rules match the pull request, the one with the highest priority value is chosen. On the other hand, if no priority rule matches it will set a medium priority value.
Back to our case again. You could setup up priority rules like this, for instance.
- name: default
- name: high priority
With this configuration, you had the urgent label to your bug fix pull request and it will enter the queue in the first position, above all the 50 other pull requests with a medium priority level. Mergify will stop evaluating the current pull request and will take care of your bug fix pull request. Congrats again! Your bug fix is merged in 1 minute (or 2) instead of at least 50 minutes without leaving your usual workflow!
If you want to know more about priority rules, I invite you to take a look at our documentation.
Watch the use case video
Keep control with Mergify
In conclusion, Mergify Merge Queue's Queue Rules and Priority Rules provide powerful tools to maintain control over the merging process.
Queue Rules allow for the creation of multiple queues with unique configurations, enabling urgent tasks to be prioritized and merged quickly.
Priority Rules further streamline the process by automatically ordering pull requests within the queue based on predefined conditions.
With Mergify Merge Queue, teams can efficiently manage pull requests, ensuring smoother workflows and faster merging times for critical updates.
Less than 10 minutes setup.