chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs

Home Page:https://kodiakhq.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat(priority): Ability to push back PRs to the back of the queue

erezrokah opened this issue · comments

TLDR: Similar to priority_merge_label but low_priority_merge_label, where a PR is scheduled last.

This is useful for bots PRs, where we want them to always come after humans' PRs.

Found a few priority related issues, but not quite like this

Also not sure if it will work to use priority_merge_label: automerge and automerge_label: low priority as I remember one needs both to be in the queue

@erezrokah Thanks for the suggestion. I think the implementation would be similar to priority_merge_label. For pull requests labeled with priority_merge_label, we insert them into the Redis Sorted Set with a score of 0 instead of using the current unix timestamp as the score.

For low_priority_merge_label, we could insert the pull requests into the queue with some very high timestamp, like 4800000000, to prioritize these pull requests last.

priority_merge = config.merge.priority_merge_label in pull_request.labels
position_in_queue = await api.queue_for_merge(first=priority_merge)

kodiak/bot/kodiak/queue.py

Lines 588 to 592 in ee3cd8e

if first:
# place at front of queue. To allow us to always place this PR at
# the front, we should not pass only_if_not_exists.
await transaction.zadd(queue_name, {event.json(): 1.0})
else:

Thanks for the quick response @chdsbd, I can try and submit a PR for it if that makes sense

@erezrokah A PR would be great! I can help with tests and polish if you need