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

Restrict merges to during working hours #323

Open dpraul opened 4 years ago

dpraul commented 4 years ago

Hi! Great bot - hoping to integrate it further as we play around with it more.

Dependabot has an excellent setting where auto-merging can be restricted to only occur during working hours, like so: image

Would love to see a feature like this here!

chdsbd commented 4 years ago

That's a cool idea. I don't think it would be too difficult to add, but I'm unsure of how to express this in .kodiak.toml.

These are a few ideas I came up with:

verbose

[merge.automerge_schedule.days.sunday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.monday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.tuesday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.wednesday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.thursday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.friday]
start = 07:32:00
end = 12:32:00
[merge.automerge_schedule.days.saturday]
start = 07:32:00
end = 12:32:00

inline

[merge.automerge_schedule.days]
monday = {start = 07:32:00, end = 12:32:00}
tuesday = {start = 07:32:00, end = 12:32:00}
wednesday = {start = 07:32:00, end = 12:32:00}
thursday = {start = 07:32:00, end = 12:32:00}
friday = {start = 07:32:00, end = 12:32:00}
saturday = {start = 07:32:00, end = 12:32:00}
sunday = {start = 07:32:00, end = 12:32:00}

minimalist

[merge.automerge_schedule.days]
monday = [07:32:00, 12:32:00]
tuesday = [07:32:00, 12:32:00]
wednesday = [07:32:00, 12:32:00]
thursday = [07:32:00, 12:32:00]
friday = [07:32:00, 12:32:00]
saturday = [07:32:00, 12:32:00]
sunday = [07:32:00, 12:32:00]

I'm curious if you have any other suggestions.

EDIT: looking at this a couple times more I think I'm personally learning towards the inline exmaple

sbdchd commented 4 years ago

Also needs a timezone setting of some sort

dpraul commented 4 years ago

I imagine it should also account for:

  1. days where there should be no merging
  2. people who want the schedule to be the same for all days

Inline is easiest to read but I think it makes it hard to account for (2) - but that's not totally essential to optimize for

chdsbd commented 4 years ago

Maybe something like this where we have some global settings and allow individual days to be overridden.

[merge.automerge_schedule]
timezone = 'America/New_York'
# specify global start/end times
start = 07:32:00
end = 12:32:00

# override global times by day
[merge.automerge_schedule.days]
monday = {start = 07:32:00, end = 12:32:00}
tuesday = {start = 07:32:00, end = 12:32:00}
wednesday = {start = 07:32:00, end = 12:32:00}
thursday = {start = 07:32:00, end = 12:32:00}
friday = {start = 07:32:00, end = 12:32:00}
# don't merge on specific days by setting an empty table
saturday = {}
# alternatively I think using a boolean is more clear
sunday = false
dpraul commented 4 years ago

that makes sense to me!

chdsbd commented 4 years ago

Would your expectation be that if a PR was opened outside of the merge window, it would be merge upon the next opening?

I guess that would require a bit more work than simply ignoring a PR outside of the window because Kodiak would need to track PRs opened outside the window and trigger evaluation once the new time period comes around. Anyway, I think I know how to do it.

EDIT: Also, is this something you're still interested in seeing in Kodiak?

dpraul commented 4 years ago

Yes, I think I would expect it to keep track and start merging again once the next merge window opens.

And yes, still interested in seeing this - it would make kodiak more compelling for us

chdsbd commented 4 years ago

I found this GitHub bot which you can configure to block merging based on a schedule. It doesn't completely solve this issue because it will block merging completely, not just auto merging.

https://github.com/marketplace/merge-freeze

chirag04 commented 3 years ago

@chdsbd came here searching for a feature to setup scheduled merges. like add automerge label but merge it a specific time instead of doing it immediately. maybe a separate label along with automerge to specify the time of merge?

staabm commented 3 years ago

I guess it could be pretty easy to setup a github action which errors when started within the time-window. Additionally mark this check as mandatory, so dependabot will not merge until this check is green