GitLab CI - Cache not working : <p>I'm currently using GitLab in combination with CI runners to run unit tests of my project, to speed up the process of bootstrapping the tests I'm using the built-in cache functionality, however this doesn't seem to work.</p>

<p>Each time someone commits to master, my runner does a <code>git fetch</code> and proceeds to <strong>remove all cached files</strong>, which means I have to stare at my screen for around 10 minutes to wait for a test to complete while the runner re-downloads <strong>all</strong> dependencies (NPM and PIP being the biggest time killers).</p>

<p>Output of the CI runner:</p>

<pre><code>Fetching changes...

Removing bower_modules/jquery/  --+-- Shouldn't happen!
Removing bower_modules/tether/    |
Removing node_modules/            |
Removing vendor/                --'
HEAD is now at 7c513dd Update .gitlab-ci.yml
</code></pre>

<p>Currently my <em>.gitlab-ci.yml</em></p>

<pre><code>image: python:latest

services:
  - redis:latest
  - node:latest

cache:
  key: "$CI_BUILD_REF_NAME"
  untracked: true
  paths:
  - ~/.cache/pip/
  - vendor/
  - node_modules/
  - bower_components/


before_script:
  - python -V

  # Still gets executed even though node is listed as a service??
  - '(which nodejs &amp;&amp; which npm) || (apt-get update -q &amp;&amp; apt-get -o dir::cache::archives="vendor/apt/" install nodejs npm -yqq)'
  - npm install -g bower gulp

  # Following statements ignore cache!
  - pip install -r requirements.txt
  - npm install --only=dev
  - bower install --allow-root
  - gulp build

test:
  variables:
    DEBUG: "1"
  script:
  - python -m unittest myproject
</code></pre>

<p>I've tried reading the following articles for help however none of them seem to fix my problem:</p>

<ul>
<li><a href="http://docs.gitlab.com/ce/ci/yaml/README.html#cache" rel="noreferrer">http://docs.gitlab.com/ce/ci/yaml/README.html#cache</a></li>
<li><a href="https://fleschenberg.net/gitlab-pip-cache/" rel="noreferrer">https://fleschenberg.net/gitlab-pip-cache/</a></li>
<li><a href="https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336" rel="noreferrer">https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/336</a></li>
</ul>
