Elixir is fast, very fast. So fast that a good chunk of Continuous Integration jobs on Travis CI for our Phoenix projects were spent in fetching dependencies (this is very small, but still a few seconds) and then compiling all of the dependencies.

If you’re willing to deal with getting a failed build once in a while then you can significantly speed up the CI jobs by caching certain assets. Specifically the _build/ and deps/ directories.

This strategy can be used on any CI service but the example here is for Travis CI. Simply add the following to your .travis.yml file:

cache: directories: - _build - deps

We saw a big reduction in total Pull Request CI test run time

Here is a comparison of the individual jobs

Before:

After:

If you are getting a failing build when you believe you shouldn’t, the issue could be the cache. You can simply clear the cache and start it from scratch at any time.