Background
We have a PHP project that was working fine with Travis CI until a certain point and since then has totally stopped working. The project is simply failing to build with Composer.
Details
The last successful build was: this one
The most recent failed build was:
this one, in the branch Naming Collisions
which is this commit
The error that keeps coming up is:
Failed to execute git clone --mirror 'git@github.com:edmondscommerce/Faker.git' '/home/travis/.composer/cache/vcs/git-github.com-edmondscommerce-Faker.git/'
latest branch is NamingCollisions
, this is the latest commit
Notice in the composer.json we are using a fork for the Faker library:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/edmondscommerce/Faker.git"
}
],
This all works fine for our local tests, it only fails in Travis.
Things we have tried:
flushing Travis caches
clearing composer caches before doing the install - .travis.bash
adding:
"github-protocols": ["https"]
to the composer.json
No luck so far.
Unfortunately we're now just testing locally and ignoring Travis because it is consistently failing now even though the code is working fine.
Hopefully one of you readers can help figure this one out!
What we went with
In the end we decided to add "no-api": true
to the repositories
config as suggested by Everon.
This forces composer to no longer make use the github API (docs):
If you set the no-api key to true on a github repository it will clone the repository as it would with any other git repository instead of using the GitHub API.
I had a look in to this and it isn't an issue with Travis itself.
After looking in to Travis and running the Travis environment locally in a Docker instance I was able to reproduce the issue.
Travis is complaining that it can not authenticate through at Github.
You need to use a Travis environment variable that can then be used to set the access token so that Composer can do what is required to install the VCS repository fork of Faker.
You can define the variable in the settings for your repository in Travis, it is then available as a standard Bash variable to be used in your travis before_script
array or in your shell scripts.
Token from the build log:
Setting environment variables from repository settings
$ export GITHUB_TOKEN=[secure]
You define the required access token here: https://github.com/settings/tokens/new?scopes=repo
And can then set it in the before script like so:
before_script:
- composer config github-oauth.github.com ${GITHUB_TOKEN};
- bash -x .travis.bash
Another option is to add "no-api" to your Faker fork - See below.
...
"repositories": [
{
"type": "vcs",
"url": "https://github.com/edmondscommerce/Faker.git",
"no-api": true
}
]
...
Build (failed but has past the point you were having issues with) https://travis-ci.org/everon/doctrine-static-meta/jobs/352620456