Repository navigation
support for sending commands to bot instances via PR comments - #172
Conversation
|
@trz42 Can you look into fixing the merge conflicts? |
…eature/bot-rebuild
Done. |
boegel
left a comment
There was a problem hiding this comment.
first part of review, more coming soon...
boegel
left a comment
There was a problem hiding this comment.
Minor issue: tests are missing for stuff in tools/commands.py for example, but that's not a huge disaster (not worth blocking PR over imho)
| return handler(event_info, bot_command) | ||
| else: | ||
| self.log(f"No handler for command '{cmd}'") | ||
| raise EESSIBotCommandError(f"unknown command '{cmd}'; use `bot: help` for usage information") |
There was a problem hiding this comment.
Maybe this should also result in a comment back to the issue/PR where the bot command was issued?
Unknown bot command 'foo', only valid bot commands are: ...
This can be done in a follow-up PR imho.
There was a problem hiding this comment.
OK, will create an issue for that.
| help_msg += "\n - Commands must be sent with a **new** comment (edits of existing comments are ignored)." | ||
| help_msg += "\n - A comment may contain multiple commands, one per line." | ||
| help_msg += "\n - Every command begins at the start of a line and has the syntax `bot: COMMAND [ARGUMENTS]*`" | ||
| help_msg += "\n - Currently supported COMMANDs are: `help`, `build`, `showconfig`" |
There was a problem hiding this comment.
This should eventually be replaced by a pointer to documentation (once it's there) - can be done in follow-up PR
| COMMAND_PERMISSION = "command_permission" | ||
|
|
||
|
|
||
| def check_command_permission(account): |
There was a problem hiding this comment.
Checking of build and deploy permission should also come from here (eventually)?
| # ... in order to prevent surprises we should be careful what the bot | ||
| # adds to comments, for example, before updating a comment it could | ||
| # run the update through the function checking for a bot command. | ||
| if check_command_permission(sender) is False: |
There was a problem hiding this comment.
Since this is triggered for every issue comment being made, it's done too early, since for accounts that don't have permission to send commands to the bot this will immediately trigger a account XXX has NO permission to send commands to the bot (see boegel/software-layer#24 (comment)).
That should only be done if the comment effectively includes bot commands.
Let's try and make this the first thing we fix after merging this PR...
boegel
left a comment
There was a problem hiding this comment.
I've tested this extensively with boegel/software-layer#24, and it's good to merge imho.
There's definitely room for improvement, but it's a nice step forward.
Thanks a lot for all the effort on this @trz42!
This PR probably needs some updates/polishing but it has been tested already with a few PRs to the software-layer repository. It includes the following additions:
bot:buildan action can be filtered wrt a repository, an architecture and a bot instance namehelpandbuildand an action filterbot:), displays if a command has been received, processes the command(s) and adds some result/output in the same commenthelp,buildandshowconfigapp.cfgsetting for limiting which GH accounts can send commands to the botTODOsdoneupdate_pr_commentis working only with issue comment events (not with pull request events) because it accesses theissuesection of an event, see line (intools/pr_comments.py)