You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to test GH integration, there should be a script able to send requests like the ones sent by GH when a PR is created or modified or when a PR/commit message mentions bpo-NNNNN.
The script should be able to:
read and send payloads from a file
generate payloads of the given type, with the values provided or with default values.
Hi, I want work on this.
Should it be a python script right?
And can you explain the second point? What do you mean by the given type, with the values provided or with default values.
Hi,
I already started working on it a while ago, and the script is now able to send payload from files, but I still have to clean it up a bit and submit a PR.
Once I do (hopefully later today) that you are welcome to work on the second point.
You should be familiar with the several available fields (https://developer.github.com/webhooks/), the ones we use most frequently, and what the best default for each is. For example the default type could be pull_request, and the default action could be opened, but it should be possible to specify other values if I want to. Feel free to ask if you have any other questions.
On Mar 28, 2017 11:02 PM, "Ezio Melotti" ***@***.***> wrote:
Hi,
I already started working on it a while ago, and the script is now able to
send payload from files, but I still have to clean it up a bit and submit a
PR.
Once I do (hopefully later today) that you are welcome to work on the
second point.
The API should be something similar:
ghsend.py --type pull_request
ghsend.py --type pull_request --action reopened
ghsend.py --type push --author ezio.melotti --title 'bpo-12345: fix a bug'
You should be familiar with the several available fields (
https://developer.github.com/webhooks/), the ones we use most frequently,
and what the best default for each is. For example the default type could
be pull_request, and the default action could be opened, but it should be
possible to specify other values if I want to. Feel free to ask if you have
any other questions.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADB1P8II7BoQodgVadW_9B2N9UCQzfdiks5rqUQbgaJpZM4MP4uX>
.
I created a pull request with the initial version of the script.
I designed it in such a way that it should be easy to extend and implement the second point:
define a file/constant with one or more basic payloads (if different types have different structures)
update parse_args() to accept and parse additional arguments (e.g. author, title, prnum, etc.)
update the basic payload with the specified arguments (add a separate function)
update the DEFAULT_HEADERS with the type of event (e.g. headers['X-GitHub-Event'] = 'pull_request')
call send_request(payload, headers) -- the function will take care of calculating the signature and adding headers for it and for the content-length.
A couple of notes about the current version:
If the argument is a filename with no path (e.g. python3 image/bin/ghsend.py pullrequestevent.txt, the script will look for it in ../roundup/test/data, if it's a path (relative or absolute), it will follow the path.
I created this file in image/bin/ because I thought of using it from within the docker, but later realized it's easier to use it from outside the docker. I currently keep docker running in one terminal tab with roundup running, and I execute the script from a separate tab outside docker (on docker-b.p.o/). This is also why I decided to set the default path to ../roundup/test/data rather than /opt/tracker/roundup/test/data. It's probably possible to connect two shell to the docker and run roundup in one and ghsend in the other, but I don't see any advantage in doing so.
Thanks @ezio-melotti! I got it.
Should I fork your repo and send a PR to your branch and then include it in this PR #12? or should I wait till this gets in?
In theory it would be good to create requests that are as close to the original as possible, but you could also remove some items if they are not important for Roundup and if it makes the script simpler.
Is there any specific problem you are trying to solve?
So currently we are using Push, IssueComment and PullRequest events. The payload is quite different for all these events. I was thinking of creating a sample file for each event and then according to the arguments change the key/values (like title, author, etc).
Once we can use the script to create requests, it would also be nice to have an option to send them (headers + payload) to stdout or to a file. This will be convenient for creating test file.
Activity
AnishShah commentedon Mar 28, 2017
Hi, I want work on this.
Should it be a python script right?
And can you explain the second point? What do you mean by
the given type, with the values provided or with default values.ezio-melotti commentedon Mar 28, 2017
Hi,
I already started working on it a while ago, and the script is now able to send payload from files, but I still have to clean it up a bit and submit a PR.
Once I do (hopefully later today) that you are welcome to work on the second point.
The API should be something similar:
You should be familiar with the several available fields (https://developer.github.com/webhooks/), the ones we use most frequently, and what the best default for each is. For example the default type could be
pull_request, and the default action could beopened, but it should be possible to specify other values if I want to. Feel free to ask if you have any other questions.AnishShah commentedon Mar 28, 2017
python#4: add a script to send GH payloads.
ezio-melotti commentedon Mar 29, 2017
I created a pull request with the initial version of the script.
I designed it in such a way that it should be easy to extend and implement the second point:
parse_args()to accept and parse additional arguments (e.g. author, title, prnum, etc.)DEFAULT_HEADERSwith the type of event (e.g.headers['X-GitHub-Event'] = 'pull_request')send_request(payload, headers)-- the function will take care of calculating the signature and adding headers for it and for the content-length.A couple of notes about the current version:
filenamewith no path (e.g.python3 image/bin/ghsend.py pullrequestevent.txt, the script will look for it in../roundup/test/data, if it's a path (relative or absolute), it will follow the path.image/bin/because I thought of using it from within the docker, but later realized it's easier to use it from outside the docker. I currently keep docker running in one terminal tab with roundup running, and I execute the script from a separate tab outside docker (ondocker-b.p.o/). This is also why I decided to set the default path to../roundup/test/datarather than/opt/tracker/roundup/test/data. It's probably possible to connect two shell to the docker and run roundup in one and ghsend in the other, but I don't see any advantage in doing so.AnishShah commentedon Mar 30, 2017
Thanks @ezio-melotti! I got it.
Should I fork your repo and send a PR to your branch and then include it in this PR #12? or should I wait till this gets in?
#4: add a script to send GH payloads.
ezio-melotti commentedon Mar 30, 2017
I went ahead and merged it so you can start working on it, @soltysh can look at it once he has time.
AnishShah commentedon Apr 3, 2017
Should the payload have all the key/value pair or just few of those that are important for roundup?
ezio-melotti commentedon Apr 3, 2017
In theory it would be good to create requests that are as close to the original as possible, but you could also remove some items if they are not important for Roundup and if it makes the script simpler.
Is there any specific problem you are trying to solve?
AnishShah commentedon Apr 3, 2017
So currently we are using Push, IssueComment and PullRequest events. The payload is quite different for all these events. I was thinking of creating a sample file for each event and then according to the arguments change the key/values (like title, author, etc).
ezio-melotti commentedon Apr 3, 2017
SGTM.
AnishShah commentedon Apr 3, 2017
ezio-melotti commentedon Apr 4, 2017
Once we can use the script to create requests, it would also be nice to have an option to send them (headers + payload) to stdout or to a file. This will be convenient for creating test file.