OCA / oca-port

Tool for porting Odoo modules changes from one version to another
GNU Lesser General Public License v3.0
30 stars 21 forks source link

use authenticated requests on github api #29

Open gurneyalex opened 1 year ago

gurneyalex commented 1 year ago

Is your feature request related to a problem?

When running oca port on "busy" projects a couple of time I get this error:

$ ~/oenv3/bin/oca-port --repo-name queue --fork work 14.0 15.0 queue_job
queue_job already exists on 15.0, checking PRs to port...
Traceback (most recent call last):
  File "/home/afayolle/oenv3/bin/oca-port", line 8, in <module>
    sys.exit(main())
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/__init__.py", line 140, in main
    PortAddonPullRequest(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 96, in run
    branches_diff = BranchesDiff(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 439, in __init__
    self.commits_diff = self.get_commits_diff()
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 547, in get_commits_diff
    pr = self._get_original_pr(commit)
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/port_addon_pr.py", line 641, in _get_original_pr
    raw_data = github.get_original_pr(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/utils/github.py", line 31, in get_original_pr
    gh_commit_pulls = request(
  File "/home/afayolle/oenv3/lib/python3.8/site-packages/oca_port/utils/github.py", line 25, in request
    raise RuntimeError(response.text)
RuntimeError: {"message":"API rate limit exceeded for 88.170.64.58. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}

Describe the solution you'd like

I don't see an option to use authenticated requests, but it would be nice. And maybe some throttling could be used to avoid having the error?

sebalix commented 1 year ago

Did you set your GH token?

$ export GITHUB_TOKEN=<token>
sebalix commented 3 months ago

The environment variable above should be mentioned in the documentation/CLI --help, so keeping this issue open.

sbidoul commented 1 month ago

What would be nice is to try and obtain the token using the gh client, a bit like this: https://github.com/OCA/maintainer-tools/blob/fbdc8945feabe1f6f3091c1b2d517b6c4160bc2b/tools/github_login.py#L25-L28.