CircleCI 2.0 offers more control to users over how caching works. Great! But unfortunately, I’m having a tough time getting it to be useful.
Let’s say I’m running CI for a simple NodeJS server, using npm to manage dependencies. I decide to cache node_modules. I have a single master branch. I don’t even use other branches; I just push all my changes to master.
The behavior I would want is to use node_modules from the latest successful master build. I trust npm to generally figure out what to install, even given an arbitrarily stale node_modules directory.
Unfortunately, I can’t see a way to do this with the current caching operations. I can’t cache on just a fixed value or the branch key; the cache would never update. On the other hand, caching on the checksum of package.json would get me an up-to-date cache on most commits where I didn’t change my dependencies, but I’d get no benefit whatsoever, not even a partial cache, if my dependencies did change.
It’s possible I’m missing something essential. And of course, I know Circle 2 is still in beta and like many things about it But I think the caching operations need some additional attention, so they can handle cases like this.