I am having the problem that on every new pipeline my cache for the node_modules misses and is recreated.
Even though I have set the key to the yarn.lock file Gitlab CI creates a new cache key for every commit.
Here is my config:
cache: &yarn_cache
key:
files:
- yarn.lock
policy: pull
paths:
- 'node_modules/'
install dependencies:
stage: install
interruptible: false
cache:
<<: *yarn_cache
policy: pull-push
script:
- time yarn install --frozen-lockfile --no-progress --non-interactive
The output in the console is:
Restoring cache
00:01
Checking cache for ea648fb349a089e115e8f732eef012e018d72e46...
FATAL: file does not exist
Failed to extract cache
This happens on every push. When I restart the job using the UI the key stays the same. Also for all the following jobs the cache key is the same and works.
However, the key should be the same for all commits that use that yarn.lock file.
Regards
Simon