-
Notifications
You must be signed in to change notification settings - Fork 25
PoC: Add script to listen for AMQP review requests #468
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
base: master
Are you sure you want to change the base?
Conversation
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.
Looks generally good.
|
||
|
||
def listen(args): | ||
connection = pika.BlockingConnection(pika.URLParameters(args.url)) |
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.
only one question and note to look at. I guess this part is taken from https://amqp.opensuse.org/files/amqp_get_opensuse.py, which comes with pika.BlockingConnection
. I wonder if this is going to stay or there is a plan to use async connection here
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 also tried out https://rabbit.opensuse.org/files/amqp_listen_opensuse.py which is using await
, but it uses aio_pika
, and I couldn't find that as a package in opensuse. So I thought it's either blocking and pika or async and aio_pika.
But apparently there is also an example for pika: https://pika.readthedocs.io/en/stable/examples/asynchronous_consumer_example.html
I don't know at this point which approach would be better.
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 guess the BlockingConnection
is simpler. Documentation comes with some warnings tho.
for async there is https://pika.readthedocs.io/en/stable/intro.html which is a good start I guess.
@@ -0,0 +1,437 @@ | |||
{ |
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.
Before merging it would make sense to trim down these JSON files to what's actually needed. (I know it is annoying, had to do the same when extending qem-bot.)
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 is a proof of concept and and example. It is not meant to be merged.
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.
That file can be used to simulate a review request without actually having to request a review on gitea (I didn't want to spam people with endless emails)
Issue: https://progress.opensuse.org/issues/185491
Still a lot missing:
webhook_id
field of the scheduled product. Alternatively it could be done by a hook scriptRequirements:
To run the script:
This will print all received events. verbose 2 will only print
opensuse.src.
events, and verbose 1 only the ones we want to process.To simulate an event for testing without having to request a review you can use this:
It will schedule a product and add a pending check to the corresponding pull request (I used https://src.opensuse.org/tinita/myplayground/pulls/2 for testing), linking to one of the scheduled jobs