chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs
https://kodiakhq.com
GNU Affero General Public License v3.0
1.05k stars 63 forks source link

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

Open erezrokah opened 2 years ago

erezrokah commented 2 years ago

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

chdsbd commented 2 years ago

@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.

https://github.com/chdsbd/kodiak/blob/ee3cd8e6f4ec0434dd48dc9548ae321b0c525022/bot/kodiak/evaluation.py#L1171-L1172

https://github.com/chdsbd/kodiak/blob/ee3cd8e6f4ec0434dd48dc9548ae321b0c525022/bot/kodiak/queue.py#L588-L592

erezrokah commented 2 years ago

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

chdsbd commented 2 years ago

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