samphilipd
How to cache erlang builds on CI?
Hey everyone!
I’m working on optimising our build pipeline. I have a flow that looks like:
– compile
– dialyzer, test etc
These are executed in separate containers. The compiled files are moved from the first container to the second by saving the _build/dev directory to a workspace, which is attached to the subsequent containers.
This works well in that application files are never recompiled, however every time it always recompiles all the Erlang modules. What have I missed in order to cache these.
Thanks!
Sam
Most Liked
idi527

Just ran into a somewhat similar issue (erlang deps didn’t seem to be cached) and in my case the problem was in not caching deps folder after running mix compile. This is important since rebar3 actually stores ebins in deps, and in _build mix only creates symlinks.
So, my approach before (which had the same problem as in OP):
# deps stage
- cache pull deps
- mix deps.get
- cache push deps
# compile stage
- cache pull deps, _build
- mix compile
- cache push _build
and my approach now:
# deps stage
- cache pull deps
- mix deps.get
- cache push deps
# compile stage
- cache pull deps, _build
- mix compile
- cache push deps, _build # <-- !!!
idi527
Once for each stage, yes. Otherwise mix complains about missing dependencies.
tristan
We were made aware of this recently and got it fixed. Didn’t realize all compilation wasn’t done to deps by mix 
The rebar3 version installed by mix should now be 3.13.1 which supports an additional argument of where to send output.
I’m not sure what version of mix uses the new output option… Will go look in a bit.







