sympy / sympy-bot-old

SymPy pull request helper
http://reviews.sympy.org/
Other
24 stars 16 forks source link

Using github hooks instead of pollings for updating review site #112

Closed MichaelMayorov closed 12 years ago

MichaelMayorov commented 12 years ago

Could we use github API hooks https://help.github.com/articles/post-receive-hooks instead of /update and /quickupdate(they just poll github) on review site? Benefits:

  1. Realtime updating information about pull requests
  2. In future, we could use it in "sympy-bot work" without asking github for realtime updating on client side.

For realtime updating we could use "Comet" http://en.wikipedia.org/wiki/Comet_(programming) model on sympy-bot web. BTW, Google App Engine supports "Comet" http://googleappengine.blogspot.com/2010/05/app-engine-at-google-io-2010.html

asmeurer commented 12 years ago

@certik will you be able to review this?

certik commented 12 years ago

@MichaelMayorov, absolutely. As a first step, the web app should get updated using github hooks, however not the post-receive hook which is triggered only when pushed into the master, but rather these hooks:

http://developer.github.com/v3/repos/hooks/

which get triggered whenever a new pull request is created. I currently don't have time to work on it --- if you want to give it a shot, and send a pull request, that would be really awesome!

@asmeurer, there is nothing to review yet, or am I missing some code?

asmeurer commented 12 years ago

Sorry. I'm so used to github issues being pull requests.

toolforger commented 12 years ago

Relying on a github-specific mechanism means switching to another platform will be harder. While I believe we're currently extremely happy with github, github's policies could change at any time - for example, when bought by a big company (think Sun's drasticy policy changes after they were bought by Oracle).

The point is moot if we can expect to have similar hooks in any other service that we might be moving to. Or if we say that using hooks will save us much more work than we'd incur on rebuilding the infrastructure for a different site. Do we?

MichaelMayorov commented 12 years ago

I not quite understand how to use this hooks http://developer.github.com/v3/repos/hooks/ I tried

curl -d '{ "name": "web", "active": true, "config": { "url": "http://something.com/webhook" } }' "https://api.github.com/repos/MichaelMayorov/test-hooks" { "message": "Not Found" }

and

curl "https://api.github.com/repos/MichaelMayorov/test-hooks/hooks" { "message": "Not Found" }

How to use this API?

certik commented 12 years ago

I think that the address "https://api.github.com/repos/sympy/sympy/hooks" is correct. However, you need to be authenticated to github first, see here:

http://developer.github.com/v3/#authentication

$ curl -u certik https://api.github.com/repos/certik/sympy/hooks
Enter host password for user 'certik':
[
  {
    "updated_at": "2012-06-24T22:45:44Z",
    "config": {
      "domain": "",
      "user": "certik",
      "token": "blablabla"
    },
    "events": [
      "push"
    ],
    "created_at": "2012-06-20T21:14:23Z",
    "name": "travis",
    "id": 306085,
    "url": "https://api.github.com/repos/certik/sympy/hooks/306085",
    "last_response": {
      "status": "ok",
      "message": "OK",
      "code": 200
    },
    "active": true
  }
]
certik commented 12 years ago

So the authentication is another problem --- the webapp needs to be using OAuth I think: http://developer.github.com/v3/oauth/, it shouldn't be very difficult to setup, but it will take some time to nail it down.

MichaelMayorov commented 12 years ago

Most of works already done, but I found that some pull requests have "mergeable": "None" Obviously, that these pulls will be never showed on main page. How we should handle this situation? I suggest make "None" equal to "False"

MichaelMayorov commented 12 years ago

Ok, now hooks seems work, but I still need test of my code.

Here is my draft http://shell.marchael.ru/ (currenlty forwarded from my notebook and may be unreacheable) with one open pull and one closed

MichaelMayorov commented 12 years ago

@asmeurer You'll give me a favour if you'll create web-hook to my work machine. So I'll be able to see incoming pulls to sympy/sympy

MichaelMayorov commented 12 years ago

I opened pull request https://github.com/sympy/sympy-bot/pull/113

I Hope someone will review this code :)

certik commented 12 years ago

Thanks! I am on it.

asmeurer commented 12 years ago

None probably means it could not determine the mergability (or possibly that it hasn't been computed yet). I see this sometimes in the web interface. I imagine repolling would usually fix the problem.

MichaelMayorov commented 12 years ago

https://github.com/sympy/sympy-bot/pull/113 was merged and this issue could be closed.