I may be using cache in the wrong way, or I’m not seeing it do what I expect it to. The relevant bit of my yml looks like:
.install node dependencies: &import_install_node_dependencies
stage: install-dependencies
image: node:9.0
script:
- npm install -g bower
- npm install --production
- bower --allow-root install --production
cache:
key: "$CI_ENVIRONMENT_SLUG-$CI_JOB_NAME"
paths:
- node_modules/
- bower_components/
- assets/vendor/
artifacts:
paths:
- node_modules/
- bower_components/
- assets/vendor/
expire_in: 3 mos
install node dependencies staging:
<<: *import_install_node_dependencies
only:
- features/staging
environment:
name: staging
The relevant output then looks like:
Checking cache for staging-install node dependencies staging...
Successfully extracted cache
$ npm install -g bower
$ npm install --production
added 114 packages in 20.546s
$ bower --allow-root install --production
Creating cache staging-install node dependencies staging...
node_modules/: found 37062 matching files
WARNING: bower_components/: no matching files
assets/vendor/: found 580 matching files
Created cache
Uploading artifacts...
node_modules/: found 37062 matching files
WARNING: bower_components/: no matching files
assets/vendor/: found 580 matching files
Uploading artifacts to coordinator... ok id=2901 responseStatus=201 Created token=psdipQu5
Job succeeded
What this looks like to me is that it’s successfully finding files to cache, creating a cache from them, and downloading them on each pipeline. Great. What it’s not doing is… not running the tedious npm install / bower install etc etc that I was hoping caching all that… stuff… would prevent. It’s found cached versions, but it’s still recreating the files each time. Have I completely misunderstood what cache is supposed to be for, or am I Doing It Wrong?
Thanks