Sccache in Travis CI


#1

Has anyone used sccache successfully in Travis?

I wonder how to install it quickly and portably. If I run cargo install sccache it takes way longer than any savings from the cache itself. I’ve tried to use a prebuilt binary using MUSL, but sccache depends on openssl which was too hard to compile portably.


#2

I wonder how to install it quickly and portably. If I run cargo install sccache it takes way longer than any savings from the cache itself.

Not the greatest solution but you could rely on caches

env:
  SCCACHE_VERSION=0.2.6
...
install:
- cargo install sccache --version $SCCACHE_VERSION || echo "Reusing sccache from CI cache"

No need to --force to upgrade; Travis flushes its caches when environment variables change.

  • If the build takes too long, you could use travis_wait
  • You do need to keep your fresh builds under 50 minutes or so. From some past experience, somewhere around there is Travis’ hard cutoff for all steps within a build.

EDIT: This is the approach I’m using for clippy


#3

Is the install: phase special in regards to caching? I’ve tried relying on cache: cargo when building sccache as part of script: phase, but I’m getting very low cache hit ratio from Travis’, which is why I was looking for some other trick.


#4

Is the install: phase special in regards to caching?

It isn’t as far as I’m aware.

I’m getting very low cache hit ratio from Travis’

Strange, I almost always get to use my cache. Whats the project? I’d be interested to look to see whats going on.


#5

Thanks. I’ve figured it out – the project I was working on was using Docker, and services: docker in .travis.yml disables cargo caching.