Travis-CI: how to cache composer executable between assemblies?

On each assembly of travis composer self-update launched. And it is updated with every build. Is it possible to cache the executable files of the composer, as we do this with the vendor the dir via

 cache: directories: - vendor - $HOME/.composer/cache 

I was thinking of caching all /home/travis/.phpenv/versions/5.5/bin/composer , but I feel that this is wrong, because the contents of this folder may change without notifying the caching system about the change (for example, when travis updates the php version )

Any suggestions (except for the special composer, of course)?

+5
source share
1 answer

I would recommend not to update the composer himself, but let the tracy handle it. (automatically updated every 30/60 days)

I can also recommend using a new container infrastructure to speed up execution and enable 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 cache: ensures that the composer is cached 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 

As well as heads-up, if you are testing HHVM and you need to set the date-time, see https://github.com/travis-ci/travis-ci/issues/2523 . My way to solve this is to add the .ini file in my test directory with the date-time and install it in the correct folder for all testers. This is added to install: -step:

  - mkdir -p /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d - phpenv config-add test/phpconfig.ini 

In any case, a little more information than you requested, but I hope this helps someone to look for a composer / travis / material :)

+5
source

Source: https://habr.com/ru/post/1215535/


All Articles