Gitlab ci cache julia packages

I have my own private gitlab server but probably this is general gitlab stuff.

How can I cache my julia packages which are dependencies of the package I want to test?

If I run Pkg.test("PkgName") everything gets saved in /root/.julia/v0.6 but it seems like gitlab doesn’t allow to cache stuff in that level.

I always get this warning:
WARNING: /root/.julia/v0.6: no matching files

I have this part inside my .gitlab-ci.yml

 cache:
    paths:
      - /root/.julia/v0.6

Thanks for any ideas. For example can I install the packages in a local folder (local in /builds/ which seems to be the directory where something can be cached)

You can change the JULIA_DEPOT_PATH which is where the package manager will look for packages. If you set it to a folder inside your project directory, you can then add that folder to the GitLab cache.

For example inside your .gitlab-ci.yml file add:

variables:
  # override DEPOT_PATH to install packages in the project
  # folder, because gitlab can only cache files whthin it
  JULIA_DEPOT_PATH: "$CI_PROJECT_DIR/.julia"
cache:
  paths:
    - $JULIA_DEPOT_PATH