2

Is it possible to separate the install deps and caching from the build of the source code?

I have:

sudo: required
language: cpp

matrix:
  include:

  - env: GCC_VERSION="4.9" 
    os: linux
    dist: trusty
    compiler: gcc
    cache: 
      directories:
        - /usr/local/include
        - /usr/local/lib
        - /usr/local/share
    addons:
      apt:
        packages:
        - gcc-4.9
        - g++-4.9
        sources:
        - ubuntu-toolchain-r-test


# Install dependencies
install:
  - export BUILD_DEPS="OFF" 
  - export BUILD_GRSF="ON"


  - export CHECKOUT_PATH=`pwd`;

  - chmod +x $CHECKOUT_PATH/travis/install_${TRAVIS_OS_NAME}.sh
  - . $CHECKOUT_PATH/travis/install_${TRAVIS_OS_NAME}.sh

script:
  - chmod +x $CHECKOUT_PATH/travis/build.sh
  - . $CHECKOUT_PATH/travis/build.sh

notifications:
  email: false 

Because my build takes too long (more than 50 minutes with building dependencies and the source code) I proceed in the following way: I set

BUILD_DEPS="ON" # build only deps
BUILD_GRSF="OFF"

which only builds the dependencies and caches them, afterwards I set

BUILD_DEPS="OFF" 
BUILD_GRSF="ON" # build only source

in the .travis.yaml file which then builds only the source code.

This seems to work but is cumbersome? Is there a better solution to this? Maybe directly on travis modifying the .travis.yaml and make a new commit "travis cached, build source now". which will then trigger another travis build (which now builds the source)

Gabriel
  • 8,990
  • 6
  • 57
  • 101

2 Answers2

2

Your dependency install script could look for a marker file your script leaves after successful installation in a cached dir and only if that's not found you would re-run the build. That way you don't need any modifications to the travis spec at least.

renefritze
  • 2,167
  • 14
  • 25
  • thanks, that would be a solution. so far my cache timesout (300mb tgz file) , cannot be installed because it takes too long, hm...? – Gabriel May 31 '16 at 09:50
-1

It seems travis can only cache in $HOME:

https://github.com/travis-ci/travis-ci/issues/6115#issuecomment-222817367

rap-2-h
  • 30,204
  • 37
  • 167
  • 263