The first step is checkout code and cached with key src-v1-{{ .Environment.CIRCLE_SHA1 }}. This is all fine, every build step after will be able to use this cache.
But, we also bundle our dependencies with yarn and stores the node_modules directory with key yarn-v1-{{ checksum "yarn.lock" }}.
This is where the freaky stuff starts. After the build step we branch into two different job, lint and test. Both these jobs will try to mount the cache for src-v1-somechecksum and yarn-v1-someotherchecksum. But the cachekey for yarn is not the same as the one we stored previously.
If we store the yarn with checksum abd132 in the jobs after it tries to read it from def456.
And even when I SSH into the server and do a sha1sum yarn.lock and compare between our different buildsteps, they don’t match.
I’m trying to understand the significance of the diff in the context of your original question. There’s a difference between two files, so they will produce a different checksum, right?
Are you asking why the files bundle_dependencies.yarn.lock and lint.yarn.lock are different?
Ok, I wan’t clear in my initial post so here’s a breakdown.
Our flow has 3 steps
Checkout code
Bundle dependencies
3.a. yarn test
3.b. yarn linst
This is how it all works and what cache keys we store/restore
The first step will simply git checkout and store that as cache-key src-v1-{{ .Environment.CIRCLE_SHA1 }}
The second step will restore the cache key src-v1-{{ .Environment.CIRCLE_SHA1 }} , run yarn install and then store the node_modules path as yarn-v1-{{ checksum "yarn.lock" }}
Then we will run step 3.a and step 3.b in parallell. And this is where it gets weird, so here’s a “log” of the flow.
Stored Cache to src-v1-517e613b63367b6aecb0235e5627e3f22d2100ba
Found a cache from build 294 at src-v1-517e613b63367b6aecb0235e5627e3f22d2100ba
yarn install
Stored Cache to yarn-v1-EaB9BI2GC9JS3N+eq+63xs+GPgjWn4XdunuQizTEMuE=
3.a
Found a cache from build 294 at src-v1-517e613b63367b6aecb0235e5627e3f22d2100ba
No cache is found for key: yarn-v1-bgEWCf8ao+UPVVqDaz4I0OvwtXiqbGOLVAhvzgkWlB0=
error An unexpected error occurred: "Command failed.
3.b
Found a cache from build 294 at src-v1-517e613b63367b6aecb0235e5627e3f22d2100ba
No cache is found for key: yarn-v1-bgEWCf8ao+UPVVqDaz4I0OvwtXiqbGOLVAhvzgkWlB0=
error An unexpected error occurred: "Command failed.
As you can see, it stores yarn-v1 as one checksum but tries to restore it from another one.