Heroku CI Pipeline - Caching gems between builds

Viewed 399

I've just set up a Ruby on Rails app on Heroku, but, I'm experiencing a CI setup performance problem, which is quite annoying.

During the setup of our unit tests, Heroku is always re-installing our gems, producing logs like:

Fetching activestorage 6.0.2.2
Installing activestorage 6.0.2.2

This is not the case when setting up our app, as it shows lines like this instead:

Using activestorage 6.0.2.2

In both cases, bundler looks to be called with the correct arguments:

(for CI setup)

Running: bundle install --without development --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment

(for app setup)

Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment

In both cases, we're having the line:

Bundled gems are installed into `./vendor/bundle`

So, I'm wondering: do you know why Heroku does not cache gems between CI test setups, while it's the case during consequent builds of our app? If yes, is there a way to force the reuse of gems previously installed in our CI pipeline? This is taking a lot of time and can benefit from that.

Thanks a lot

2 Answers

After asking Heroku's team, it was a bug in the ruby's buildpack. This is now fixed, and works well. Buildpack creators can cache data between CI build, it was just turned off during one of their upgrade.

Heroku does not cache gems between CI test setups

Heroku filesystem is an ephemeral filesystem. When you run the tests, a dyno is spun up with a brand new operating system. Then heroku install all the dependencies and starts your tests.

I think it is a common scenario with all the CI platforms. Everytime we run tests, they will spin up a new environment from start by installing all the dependencies.

One justification for this may be that tests change a lot of data on different levels. So the CI providers start from scratch so that previous test residue data can't interfere with current run.

Related