Skip to content
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

Travis-CI + Github API limit #1314

Closed
fprochazka opened this issue Nov 11, 2012 · 22 comments
Closed

Travis-CI + Github API limit #1314

fprochazka opened this issue Nov 11, 2012 · 22 comments

Comments

@fprochazka
Copy link
Contributor

Is there any suggested way to solve the Github API limit problem? Or will my builds just randomly fail?

https://travis-ci.org/Kdyby/Framework/jobs/3142911

Not sure, if this is problem of Composer or Travis-CI.

@Seldaek
Copy link
Member

Seldaek commented Nov 11, 2012

If you rely on VCS repos for your travis test suite, you'd better run install with --no-interaction, that way it'll fallback to a git clone if the api limit is exhausted. For travis pro I guess you could include an oauth token so that it gets a higher limit, but for public travis repos it's kinda tricky to do that.

@Seldaek Seldaek closed this as completed Nov 11, 2012
@fprochazka
Copy link
Contributor Author

I already did that. Didn't know it would fallback on clone. Thank you!

@amacneil
Copy link

Thanks! This was really helpful. Wish it was documented somewhere.

@amacneil
Copy link

Wait, this doesn't work with latest composer. Back to square 1. Any suggestions?

@Seldaek
Copy link
Member

Seldaek commented Feb 12, 2013

@adrianmacneil what do you mean doesn't work? And is "latest composer" after running self-update or using the latest tag? Because the last tag is quite old by now.

@amacneil
Copy link

I mean --non-interactive isn't a valid option. See this build failure: https://travis-ci.org/adrianmacneil/omnipay/jobs/4744814

I've worked around the issue now by using --prefer-source for Travis, though this seems like a sub-optimal solution.

Forgive my ignorance.. is there is a reason composer doesn't just use the public github zip URLs, rather than the API URLs which cause rate limit issues on Travis?

@stof
Copy link
Contributor

stof commented Feb 12, 2013

it is --no-interaction (or -n), not --non-interactive

@Seldaek
Copy link
Member

Seldaek commented Feb 12, 2013

Right, I adjusted my comment above to avoid confusing more people :)

@amacneil
Copy link

Awesome, thanks guys! I just tested with -n instead of --prefer-source but it seems I'm back under the Github API rate limit so will report back if I run into any issues.

@amacneil
Copy link

It seems -n doesn't fall back to a clone like you suggested: https://travis-ci.org/adrianmacneil/omnipay/jobs/4758560

Don't worry. I think I'll just go back to --prefer-source. Hopefully this will help someone else in future.

@Seldaek
Copy link
Member

Seldaek commented Feb 13, 2013

@adrianmacneil eh sorry what you experienced is another issue. -n helps when the parsing of a custom package repository fails due to the github rate limiting, but for downloads indeed the only ways to fix it right now are using --prefer-source, or providing an oauth API token but that's not really easy to do on travis for an open source project.

cursedcoder referenced this issue in phpspec/phpspec2-proof-of-concept Mar 17, 2013
@covex-nn
Copy link

covex-nn commented May 5, 2013

There is a solution of this problem: Encryption keys

I followed the instructions and created encrypted variable GITHUB_TOKEN

  • travis encrypt -r covex-nn/travis-test GITHUB_TOKEN=qwerty_asdf

Then i created .travis.yml and composer.json and pushed them to repository

And here is stable build on travis-ci.org with configured github-oauth.github.com in composer.json after running all scripts:

@stof
Copy link
Contributor

stof commented May 6, 2013

It won't work fully. See this quote from their doc:

Please note that secure env variables are not available for pull requests. This is done due to the security risk of exposing such information in submitted code. Everyone can submit a pull request and if an unencrypted variable is available there, it could be easily displayed.

clue added a commit to clue/graph-composer that referenced this issue May 17, 2013
JoostK pushed a commit to JoostK/framework that referenced this issue Dec 12, 2013
Composer uses the GitHub API to download packages, but the API is
rate-limited so repeated builds from the same IP hit the limit. This
adds --prefer-source to download from source, which is slower but more
reliable. It also adds --no-interaction to avoid hanging in case a
similar issue should arise in the future.

Reference:
composer/composer#1314
hkdobrev added a commit to OpenBuildings/purchases that referenced this issue Jan 24, 2014
When the GitHub API limit is reached the non-interaction mode would fallback to git cloning.

See composer/composer#1314
tommygnr pushed a commit to tommygnr/phpDocumentor2 that referenced this issue May 27, 2014
@aertmann
Copy link

Had this issue as well when using create-project. Neither adding --no-interaction nor --prefer-source solved the problem, but using git clone and composer install didn't have the issue. No idea why there would be any difference, but seems there is. Maybe it's handled differently internally and those arguments are only used for the root repository? Just a tip if anyone else comes across the same issue.

@bojanz
Copy link

bojanz commented Oct 26, 2015

http://blog.wyrihaximus.net/2015/09/github-auth-token-on-travis/ documents most of the solution.

What we did:

  1. Created the token. No scopes (read only access to public info only).
  2. Added it to Travis as the GITHUB_OAUTH_TOKEN env variable.
  3. Added git config --global github.accesstoken $GITHUB_OAUTH_TOKEN to .travis.yml (before-install)
    The article advocates doing composer config github-oauth.github.com instead, but that still failed on --prefer-dist for us. Composer bug?
  4. Removed --prefer source, kept -n.

@mykz
Copy link

mykz commented Dec 17, 2015

@bojanz really nice solution, Thanks for taking time to post it. 👍

@danepowell
Copy link
Contributor

Hmm... so Github was supposed to have fixed this by removing anonymous rate limits:
#4884 (comment)

But I'm still seeing composer installs failing on Travis with errors like this:
"Downloading: Connecting... Failed to download composer/installers from dist: Could not authenticate against github.com"

We never added an OAuth token to composer.json or .travis.yml, so it shouldn't be authenticating. I think this must be due to rate limiting.

@bojanz
Copy link

bojanz commented Mar 21, 2016

Yeah, I don't think there's a way to avoid rate limiting in Travis, cause it's simply a case of many builds coming from the same IPs. No matter how high the limit is on GitHub, Travis will reach it.

We need to keep using the OAuth tokens.

@danepowell
Copy link
Contributor

Actually it seems to be only intermittently failing. I wonder if some of the Travis IPs are still blacklisted from the old rate limit and it just takes a while to clear them or something...

@hkdobrev
Copy link
Contributor

Travis CI uses a lot of different IPs and it changes them on every build. That's why it cannot provide a list or a range to whitelist in firewalls. I guess GitHub has rate-limited some IP, but the next built uses another one.

@alexislefebvre
Copy link

It may not solve all the problems, but I have successfully tested a workaround which consist in caching the vendor/ directory, an archive is created with tar and stored in Travis CI's cache. I presented this method on Stack Overflow. A composer update --prefer-source takes 30 seconds when this cache is used, and 2 minutes without this cache. I haven't checked if it's quicker with --prefer-dist and if the API limit is not reached.

@spekary
Copy link

spekary commented Jan 24, 2018

I recently ran into this problem, grunted and groaned over it for a couple of days, and wanted to post a fix for our specific problem as it might help others. The cause of this for us was that we had "repository" entries in our composer.json file pointing to our github source for some new repositories under development. Even though we had registered these with packagist, we were still seeing the problem. It wasn't until we removed these repository entries from the composer.json file so that packagist could be the pointer to them, did we finally see our travis builds start to work consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests