Skip to content

Commit 098fa56

Browse files
committed
align dependency caching with docs
1 parent 09464fe commit 098fa56

1 file changed

Lines changed: 22 additions & 12 deletions

File tree

.circleci/config.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ jobs:
1111
executor: my-executor
1212
steps:
1313
- checkout
14+
# Fallback keys allow partial cache hits when the lock file changes.
15+
# Bump v1- to invalidate all caches.
1416
- restore_cache:
17+
name: Restore gem cache
1518
keys:
16-
- gem-cache-{{ checksum "Gemfile.lock" }}
19+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
20+
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
21+
- v1-gem-cache-{{ arch }}-
1722
- run:
1823
name: Install ruby dependencies
1924
command: |
@@ -24,8 +29,13 @@ jobs:
2429
- run:
2530
name: Install scss_lint
2631
command: gem install scss_lint
32+
# Drop stale gems left by a partial cache restore.
33+
- run:
34+
name: Clean stale gems
35+
command: bundle clean --force
2736
- save_cache:
28-
key: gem-cache-{{ checksum "Gemfile.lock" }}
37+
name: Save gem cache
38+
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
2939
paths:
3040
- vendor/bundle
3141
- persist_to_workspace:
@@ -36,16 +46,22 @@ jobs:
3646
executor: my-executor
3747
steps:
3848
- checkout
49+
# Fallback keys allow partial cache hits when the lock file changes.
3950
- restore_cache:
51+
name: Restore npm cache
4052
keys:
41-
- npm-cache-{{ checksum "package-lock.json" }}
53+
- v1-node-{{ .Branch }}-{{ checksum "package-lock.json" }}
54+
- v1-node-{{ .Branch }}-
55+
- v1-node-
4256
- run:
4357
name: Install node dependencies
4458
command: npm ci
59+
# Cache npm's download store, not node_modules; npm ci rebuilds node_modules from it.
4560
- save_cache:
46-
key: npm-cache-{{ checksum "package-lock.json" }}
61+
name: Save npm cache
62+
key: v1-node-{{ .Branch }}-{{ checksum "package-lock.json" }}
4763
paths:
48-
- node_modules
64+
- ~/.npm
4965
- persist_to_workspace:
5066
root: ~/project
5167
paths:
@@ -54,15 +70,9 @@ jobs:
5470
executor: my-executor
5571
steps:
5672
- checkout
73+
# Deps come from the workspace; no cache restore needed here.
5774
- attach_workspace:
5875
at: ~/project
59-
- restore_cache:
60-
keys:
61-
- npm-cache-{{ checksum "package-lock.json" }}
62-
- restore_cache:
63-
keys:
64-
- gem-cache-{{ checksum "Gemfile.lock" }}
65-
- gem-cache
6676
- run:
6777
name: Build site assets
6878
command: npm run build:all-assets

0 commit comments

Comments
 (0)