PoC: Add script to listen for AMQP review requests#468
PoC: Add script to listen for AMQP review requests#468perlpunk wants to merge 7 commits intoos-autoinst:masterfrom
Conversation
|
|
||
|
|
||
| def listen(args): | ||
| connection = pika.BlockingConnection(pika.URLParameters(args.url)) |
There was a problem hiding this comment.
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.
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.
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.
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.
This is a proof of concept and and example. It is not meant to be merged.
There was a problem hiding this comment.
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_idfield 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