-
Notifications
You must be signed in to change notification settings - Fork 61
Test the command parsing logic #32
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
Conversation
3b36184
to
2f9b34c
Compare
Unfortunately I didn't get a chance to look at this and I will be really busy for the next few weeks, so it would be great if someone else can review this! Here are some random notes about the command parsing and the testing:
|
Hey, no problem. Good luck with your exams! Yeah, pytest is nice. I didn’t realize there was precedent. I’ll switch over. I’ll see what I can do about the parse. Seems kinda fuzzy what we do and don’t want, so we’ll see. |
The behavior I expect and would like is to parse until an invalid word is found, and then stop parsing that line. Dunno if the others have different opinions. |
That behavior seems reasonable. If it's easier then I think going down the triagebot route with "must have terminator" is also fine (e.g., a period) -- it doesn't really hurt us all that much from a user experience point of view |
One issue I could see with the terminator is that nobody is used to it with bors, and I'd like for this PR not to change the current workflow. |
I agree about no terminators. That would confuse everybody at this point. Do we want to test current functionality now, and introduce the order change in a future PR? Or make those parser changes now? |
I agree that it's not ideal to have that behavior change, I just intended to say that I don't think it's the end of the world presuming we indicate the change by throwing errors and suggesting to users that they should insert the terminator as appropriate. But if we can do without, great -- bors/homu's syntax is certainly simpler than triagebot's. |
Start adding some tests to Homu by testing the issue comment command-parsing logic. Take `parse_commands` and break it apart into two phases * Parsing phase * Execution phase The parsing phase returns a list of commands with action names (ideally, this would be a Rust enum, but to simulate that, we use action names on a single class) that are returned regardless of the current state. So for example, `@bors retry` will return a `retry` command regardless of the current state of `realtime`. The execution phase then inspects the list of commands and decides what to do with them. So for example, the `retry` command will be skipped if `realtime == False`. This has the positive result of having a parsing phase that has no side-effects, which makes it much easier to test. This can lead to higher confidence that the code works as expected without the high cost of testing in production and possibly disrupting the build flow. This has the negative result of adding a lot of lines of code to achieve command parsing, which we already do successfully without the tests.
baedbc1
to
e885dd7
Compare
|
When parsing a @bors command, stop parsing when we reach any unknown word. This enables commands like @bors retry (yielding priority to the rollup) to include a description of why we retried (which gets put in the retry log) without also setting `rollup`. The only tricky bit to this is a command like @bors r=person 0123456789abcdef where the commit sha is part of the `r=` command, and we need to parse it that way.
f5fb2f1
to
0194c3a
Compare
Homu leaves self-approvals in comments, like <!-- @bors r=someone abcdef --> and we need to make sure those still parse correctly.
Commands that started with the botname *and then a colon* were being dropped, because the parser didn't recognize the command and didn't continue. Fix this by explicitely allowing a colon after the botname.
bbc6169
to
69f5fd1
Compare
Won't have time to properly review this for a while, sorry! By the way, there is another edge case that would be awesome to solve: ignore all commands when the line starts with |
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 looks great! Thank you so much!
Merged this early even if my last comment wasn't handled to unblock your other work. Opened an issue to track commands in quotes: #52 |
Start adding some tests to Homu by testing the issue comment
command-parsing logic.
Take
parse_commands
and break it apart into two phasesThe parsing phase returns a list of commands with action names (ideally,
this would be a Rust enum, but to simulate that, we use action names on
a single class) that are returned regardless of the current state. So
for example,
@bors retry
will return aretry
command regardless ofthe current state of
realtime
.The execution phase then inspects the list of commands and decides what
to do with them. So for example, the
retry
command will be skipped ifrealtime == False
.This has the positive result of having a parsing phase that has no
side-effects, which makes it much easier to test. This can lead to
higher confidence that the code works as expected without the high cost
of testing in production and possibly disrupting the build flow.
This has the negative result of adding a lot of lines of code to achieve
command parsing, which we already do successfully without the tests.