Introducing Merge Queue Priorities

Introducing Merge Queue Priorities

Julien Danjou

When you get hooked into automation, you always want more. For the last years, our users merged more and more pull requests using Mergify, leveraging our unique merge queue system.

At some point, your queue so big that you need to organize it. This is especially true when your continuous integration system takes a few minutes (hours?) to run and validate your code.

Adding Priority to the Queue

Today we're launching priorities for your merge queue. You can now set a different merge priority for your pull request based on its urgency.

This leverages our rule system; therefore, there is no limit to how you can organize your queue!

Extract from the merge action documentation

Enabling this feature is as simple as adding the priority parameter to your configuration.

Use-Case: Fast Tracking your Hotfixes

Let's go with an example. If you enabled the merge queue by setting the strict: true parameter, you can then write elaborated rules such as:

pull_request_rules:
  - name: automatic merge of 🚑 hotfix (high priority)
    conditions:
      - status-success=Travis CI - Pull Request
      - "#approved-reviews-by>=2"
      - base=master
      - label=🚑 hotfix
    actions:
      merge:
        method: merge
        strict: smart
        priority: high
  - name: automatic merge of bot 🤖 (low priority)
    conditions:
      - author~=^dependabot(|-preview)\[bot\]$
      - status-success=Travis CI - Pull Request
      - "#approved-reviews-by>=2"
      - base=master
    actions:
      merge:
        method: merge
        strict: smart
        priority: low
  - name: automatic merge for master when reviewed and CI passes
    conditions:
      - status-success=Travis CI - Pull Request
      - "#approved-reviews-by>=2"
      - base=master
    actions:
      merge:
        method: merge
        strict: smart
        priority: medium

The rules above define three different way of merging a pull request:

  1. Either two users approved it,  CI passed, and the label 🚑 hotfix is set; in this case, the pull request will be moved at the front of the queue and merged first — as soon as possible.
  2. Instead, if the pull request does not have that label but comes from dependabot (a bot that updates your dependencies), it will be moved at the end of the merge queue.
  3. Finally, a human-written pull request that is not a hotfix will have a medium priority and get merged before the bot updates, but after any hotfix.

You can use up to 10000 priority levels, which ought to be enough for anybody, right?

Check the documentation for the merge action if you want more details. Enjoy!