On every travis build, composer self-update
is run. And it gets updated on every build. Is it possible to cache composer executables like we do it with vendor
dir via
cache:
directories:
- vendor
- $HOME/.composer/cache
I thought about caching the whole /home/travis/.phpenv/versions/5.5/bin/composer
but I feel this is not right because the contents of this folder may change without notifying caching system about a change (when travis updates php version for example).
Any suggestions (except for custom composer, of course)?
I'd recommend not updating composer itself, but let travis handle it. (its automatically updated every 30/60 days)
Also i can recommend using the new containerized infrastructure to speed up the runs and allow caching...
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache
php:
- 5.5
- 5.6
- 7
- hhvm
install:
- composer install
script: vendor/bin/phpunit
The sudo: false
statement indicates the use of containers. The cache:
statement makes sure composer caches correctly.
If you really want to cache the composer binary:
language: php
php:
- 5.5
- 5.6
- 7
- hhvm
cache:
directories:
- $HOME/.composer/cache
install:
- travis_retry composer self-update && composer --version
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- travis_retry composer install --prefer-dist --no-interaction
script: vendor/bin/phpunit
Also just as a heads up, if testing for HHVM and you need to set the datetime, have a look at https://github.com/travis-ci/travis-ci/issues/2523. My way of solving this is adding a .ini
-file in my test
-directory with the datetime and setting this in the correct folder for all test-runners. This is prepended in the install:
-step:
- mkdir -p /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d
- phpenv config-add test/phpconfig.ini
Anyway, a bit more information than you requested, but i hope this helps someone looking for composer/travis/stuff :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With