travis icon indicating copy to clipboard operation
travis copied to clipboard

Develop caching mechanisms for composer, cakephp clone?

Open beporter opened this issue 10 years ago • 0 comments

Travis recently enabled caching on builds that don't require the use of sudo (which is probably most Cake projects.)

We've tested this out with the composer cache directory and the vendor/ directory that contains the installed dependencies and cut our Travis build matrix time from 42 minutes to 17 minutes. This simple win was easily accomplished by editing the .travis.yml file:

cache:
  directories:
    - vendor  # Not sure this helps with the current friendsofcake/travis setup.
    - $HOME/.composer/cache # This definitely helps.

I'd like to propose that this project include this caching by default.

But beyond that, there are two remaining time-consuming steps that are repeated by this project now:

  • composer self-update
  • git clone git://github.com/cakephp/cakephp.git --branch $CAKE_REF --depth 1 ../cakephp

If these two steps could be cached as well, it would further improve build speeds, but they both require more in-depth manipulation of the assets to work.

Composer executable

We would want to use the cached version of the composer executable when it was available, for example. There are many ways to do this, but updating $PATH is one that might be relatively non-invasive. Very crudely, I'm thinking:

  1. Add $HOME/bin-cached to .travis.yml as a Travis cached directory.
  2. Set PATH=$HOME/bin-cached/:$PATH.
  3. The before_script.sh process could check for a bin-cached/composer executable, and if not present, download the latest composer binary there.
  4. Additional builds would use the cached version when it was available.

Cake core cloning

As for the cake core cloning, that would be more complicated. Travis uploads the cache dir whenever its contents changes, so maybe we could do something like:

  1. Add ../cakephp-cached to the Travis cache config.
  2. In before_script.sh, clone to ../cakephp-cached/$CAKE_VERSION (if not already present) instead of just ../cakephp
  3. Perform the rest of the copy, install and test commands on that cached directory instead.
  4. Subsequent builds targeting the same Cake version (2.6 for example, but with PHP v5.5 instead of 5.4) would be able to re-use the already-cloned core folder.

I'm just spit-balling all of this, but I feel like we all have a responsibility to show respect for the free service both GitHub and Travis provide to all open source projects by not being frivolous or wasteful with their resources. We should reduce the load on both infrastructures as much as possible. The benefit is that everyone's builds go faster. :+1:

beporter avatar Apr 13 '15 16:04 beporter