Last active
February 27, 2019 19:00
-
-
Save stevehanson/ff70ca54fc2aadfe67f3e3e730161350 to your computer and use it in GitHub Desktop.
Circle CI config for Create React App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: 2 | |
| jobs: | |
| build: | |
| docker: | |
| - image: circleci/node:10.11.0 | |
| steps: | |
| - checkout | |
| - restore_cache: | |
| key: dependency-cache-{{ checksum "yarn.lock" }} | |
| - run: | |
| name: Setup Dependencies | |
| command: yarn install | |
| - save_cache: | |
| key: dependency-cache-{{ checksum "yarn.lock" }} | |
| paths: | |
| - ./node_modules | |
| - run: | |
| name: Run Test | |
| command: yarn test |
Author
yarn.lock seems a bit safer to me, just since it represents exactly which dependencies to download.
At least in my case, there are times when the package.json doesn't change, but the yarn.lock does, since we have a dependency on another internal GitHub repo that isn't versioned. When we upgrade that dependency via yarn upgrade ..., the package.json stays unchanged, but the lockfile changes, pointing to the latest git commit of that dependency.
You could always watch both I think with dependency-cache-{{ checksum "yarn.lock" }}-{{ checksum "package.json" }} to be extra safe. Hope that helps!
super helpful, thank you! 🌸
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! In the CircleCI docs, the
restore_cache, andsave_cachereference thepackage.jsonfile instead of theyarn.lockfile. I imagine we want to rebuild the cache when theyarn.lockfile changes but I'm not confident. Do you happen to know when we want to watch thepackage.jsonfile vs theyarn.lockfile?