Skip to content

Caching: use of CACHE_NAME - differencation based on env name? #887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grooverdan opened this issue Dec 19, 2016 · 2 comments
Closed

Caching: use of CACHE_NAME - differencation based on env name? #887

grooverdan opened this issue Dec 19, 2016 · 2 comments

Comments

@grooverdan
Copy link
Contributor

grooverdan commented Dec 19, 2016

I'm compiling with multiple gcc version like:

compiler:
  - gcc
  - clang
env:
  - GCC_VERSION=5
  - GCC_VERSION=6
script:
  - if [[ "${TRAVIS_OS_NAME}" == 'linux' && "${CXX}" == 'clang++' ]]; then
      export MYSQL_BUILD_CC=/usr/bin/clang-3.8  MYSQL_BUILD_CXX=/usr/bin/clang++-3.8;
    fi
  - if [[ "${TRAVIS_OS_NAME}" == 'linux' && "${CXX}" == 'g++' ]]; then
      export MYSQL_BUILD_CC=/usr/bin/gcc-${GCC_VERSION} MYSQL_BUILD_CXX=/usr/bin/g++-${GCC_VERSION};
    fi
  - ....

I'm trying to work out how to set CACHE_NAME so each GCC version gets a unique name. This is to solve the problem that the builds are concurrent and will override each others ccache rather than aggregating them or separating them.

As the cache is retrieved before the before_install phase (https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) it can't be scripted.

The following did appear to work.

env:
  - GCC_VERSION=5 CACHE_NAME=${TRAVIS_OS_NAME}-${CC}-${GCC_VERSION}
  - GCC_VERSION=6
Setting environment variables from .travis.yml
$ export GCC_VERSION=5
$ export CACHE_NAME=${TRAVIS_OS_NAME}-${CC}-${GCC_VERSION}
$ export CXX=clang++
$ export CC=clang
$ export PATH=/usr/lib/ccache:$PATH
cache.1
Setting up build cache
$ export CASHER_DIR=$HOME/.casher
$ Installing caching utilities
attempting to download cache archive
fetching 10.2-travis-clang/cache-linux-trusty-a16944a9cbbaae897e8d1989ff7a3a8a7e71250b5c80f0949f1755d4f7bdf8ab--compiler-clang.tgz
found cache

Is this how CACHE_NAME meant to be used?

@BanzaiMan
Copy link
Contributor

BanzaiMan commented Dec 20, 2016

https://docs.travis-ci.com/user/caching/#Caches-and-build-matrices

One of the factors that go into the cache name is

Names and values of visible environment variables set in .travis.yml or Settings panel

In other words, the difference in GCC_VERSION is enough to make the two caches go to different places.

CACHE_NAME is meant to provide a different cache name when all other factors are equal (even when CACHE_NAME does not affect the build in any way). In your use case, then, CACHE_NAME (or any other environment variable) is not necessary.

@grooverdan
Copy link
Contributor Author

thanks for the clarification @BanzaiMan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants