CircleCI Stone Caching

Is it possible to cache gems so that bundle install does not install a bunch of gems for each assembly? It takes 5 minutes on each assembly, which is too much.

I added this to the circle.yml configuration:

 dependencies: cache_directories: - "/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/" 

This is the general directory provided by bundle show gem_name where all system stones are located.

After that, the addition system writes the following log:

 restoring cache v4/company/repo_name/dependency/circle-ci/42/mGWhlYQIxyOy0GZtt4QmCw__.tar.gz restoring home/ubuntu/repo_name/vendor/bundle, home/ubuntu/.m2, home/ubuntu/.ivy2, home/ubuntu/.go_workspace, home/ubuntu/.gradle, home/ubuntu/.rvm/gems/ruby-2.1.2/gems 

So, as far as I understand, it restores the system gems and gems installed in vendor/bundle , however I still see this (and it takes a lot of time):

 Installing rake 10.4.2 Installing i18n 0.7.0 Installing json 1.8.2 Installing minitest 5.5.1 ... 

instead

 using rake 10.4.2 using i18n 0.7.0 using json 1.8.2 using minitest 5.5.1 ... 

So it seems like it should work, but it is not. What could be wrong?

+5
source share
1 answer

The solution is simple: CircleCI runs some default commands and caches the default stones in vendor/bundle , so there is no need to add anything to cache_directories .

Among these default commands: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 , which checks for gems in the cache directory and installs them if they do not exist.

In my case, I had a project consisting of several applications (main application, common user interface, API client and API layout), divided into 4 different repositories. Most of them need bundle install commands.

The only thing I had to do was replace all my bundle install commands (which always install gems) with bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 . In this case, all the stones are installed only for the first time when I run the tests, and all subsequent assemblies use the gems previously stored in the cache.

+17
source

All Articles