kodiak icon indicating copy to clipboard operation
kodiak copied to clipboard

Update by Comment Strategy

Open austince opened this issue 4 years ago • 4 comments

Coming from #150 and the ability to add new update strategies, what do you all think about an update strategy that just makes a comment on the PR and allows other processes to handle the actual update? Not sure if this would work/ work well, but it might help Kodiak stay flexible without having to implement all the different update strategies out there. Would make working with other bots easier as well.

How it might work:

update_strategy:
  - method: comment
    body: "@dependabot rebase"

Just throwing this out there, let me know what you think!

austince avatar Jun 16 '20 14:06 austince

Is your dependabot example just an example for discussion or an actual issue you've encountered? I think the example in the Kodiak docs should work with rebase merging. https://kodiakhq.com/docs/recipes#automated-dependency-updates-with-dependabot

# .kodiak.toml
version = 1

[approve]
# note: remove the "[bot]" suffix from GitHub Bot usernames.
# Instead of "dependabot-preview[bot]" use "dependabot-preview".
auto_approve_usernames = ["dependabot-preview"]

# if using `update.always`, add dependabot-preview to the blacklist to allow
# dependabot to update and close stale dependency upgrades.
[update]
blacklist_usernames = ["dependabot-preview"]

I think comment or label based update strategies could be implemented.

It's a little more work than the default case because the GItHub merge API is idempotent, so Kodiak is safe to try multiple times whereas commenting is not, so we'd need to query to check for comments matching that content before adding one.

Somewhat related is https://github.com/chdsbd/kodiak/pull/335.

chdsbd avatar Jun 17 '20 01:06 chdsbd

It's just for discussion, sorry for the confusion -- dependable has an update-by-rebase feature using that comment. The same could be done with this GitHub action.

That makes sense about the use of the idempotent API. I'm not familiar with how Kodiak works on a low level -- can you expand on what you think would be necessary for the comment checks?

austince avatar Jun 17 '20 14:06 austince

For implementation we'd need to update the main GraphQL query to also fetch comments. https://github.com/chdsbd/kodiak/blob/f3d2dc9c760a49b15f955cec9d3e35df4486d5a3/bot/kodiak/queries.py#L61-L208

We'd also need to add a new configuration option. https://github.com/chdsbd/kodiak/blob/f3d2dc9c760a49b15f955cec9d3e35df4486d5a3/bot/kodiak/config.py#L48-L67

Using the new comment information, when the configuration option is set we'd leave a comment (assuming we don't see one already) instead of calling the merge API.

https://github.com/chdsbd/kodiak/blob/f3d2dc9c760a49b15f955cec9d3e35df4486d5a3/bot/kodiak/evaluation.py#L848-L857

chdsbd avatar Jun 17 '20 23:06 chdsbd

Thanks for the detailed notes @chdsbd ! I probably don't have a chance to create a PR for a few weeks at least, so if anyone wants to take this in the meantime go ahead by all means, but I'll open an initial attempt if no one else does.

austince avatar Jun 20 '20 18:06 austince