-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first part of review, more coming soon...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
eessi_bot_event_handler.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, will create an issue for that.
eessi_bot_event_handler.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking of build
and deploy
permission should also come from here (eventually)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes makes sense
# ... 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #184 to follow up on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:build
an action can be filtered wrt a repository, an architecture and a bot instance namehelp
andbuild
and an action filterbot:
), displays if a command has been received, processes the command(s) and adds some result/output in the same commenthelp
,build
andshowconfig
app.cfg
setting for limiting which GH accounts can send commands to the botTODOsdoneupdate_pr_comment
is working only with issue comment events (not with pull request events) because it accesses theissue
section of an event, see line (intools/pr_comments.py
)