I noticed an interesting bug when using aliases with our new CircleCI 2.0 config:
I set an alias
node_cache_key: &node_cache_key
npm-{{ checksum "package.json" }}
This is part of the job:
- restore_cache:
key: *node_cache_key
- run: npm install
- save_cache:
key: *node_cache_key
paths:
- node_modules
And when it would try to recover the cache from previous builds
No cache is found for key: npm-hcMXzcM5ob9jB8+PrSdqJNcMF3MwZ1YrS0RAfe4Zghg=
And then later saving the new cache
Skipping cache generation, cache already exists for key: npm-dH_AZxhZiD+Hh8VLfIJGHMIa4Uh+sbJCwZSUWbG1RaI=
Found one created at 2018-09-05 05:26:30 +0000 UTC0000 UTC
I went ahead and removed the alias and set the commands to just directly reference npm-{{ checksum "package.json" }}
and voila, the cache was recognized, and speedy builds.
I’m not sure if it has something to do with where the checkout
step happens (after the alias is created).