Speed up yarn cache in circle (#19566)
Ricky committed
Aug 11, 2020 at 14:05 UTC
c8d9b8878a3a50fe94db5407727a3d5cba13f971
1 file changed
+52
-71
.circleci/config.yml
+52
-71
@@ -7,17 +7,11 @@ aliases:
7
- &environment
8
TZ: /usr/share/zoneinfo/America/Los_Angeles
9
10
- - &restore_yarn_cache
10
+ - &restore_node_modules
11
restore_cache:
12
name: Restore node_modules cache
13
keys:
14
- - v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
15
- - v2-node-{{ arch }}-{{ .Branch }}-
16
- - v2-node-{{ arch }}-
17
- - &run_yarn
18
- run:
19
- name: Install Packages
20
- command: yarn --frozen-lockfile
14
+ - v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-modules
15
16
- &TEST_PARALLELISM 20
17
@@ -30,8 +24,7 @@ aliases:
24
steps:
25
- checkout
26
- attach_workspace: *attach_workspace
33
- - *restore_yarn_cache
34
- - *run_yarn
27
+ - *restore_node_modules
28
- run: node ./scripts/rollup/consolidateBundleSizes.js
29
- run: ./scripts/circleci/pack_and_store_artifact.sh
30
- store_artifacts:
@@ -59,13 +52,29 @@ jobs:
52
- run:
53
name: Nodejs Version
54
command: node --version
62
- - *restore_yarn_cache
63
- - *run_yarn
55
+ - restore_cache:
56
+ name: Restore yarn cache
57
+ key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
58
+ - run:
59
+ name: Install Packages
60
+ command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
61
- save_cache:
65
- name: Save node_modules cache
66
- key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
62
+ # Store the yarn cache globally for all lock files with this same
63
+ # checksum. This will speed up the setup job for all PRs where the
64
+ # lockfile is the same.
65
+ name: Save yarn cache for future installs
66
+ key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
67
paths:
68
- ~/.cache/yarn
69
+ - save_cache:
70
+ # Store node_modules for all jobs in this workflow so that they don't
71
+ # need to each run a yarn install for each job. This will speed up
72
+ # all jobs run on this branch with the same lockfile.
73
+ name: Save node_modules cache
74
+ # This cache key is per branch, a yarn install in setup is required.
75
+ key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-node-modules
76
+ paths:
77
+ - node_modules
78
79
yarn_lint:
80
docker: *docker
@@ -73,8 +82,7 @@ jobs:
82
83
steps:
84
- checkout
76
- - *restore_yarn_cache
77
- - *run_yarn
85
+ - *restore_node_modules
86
- run: node ./scripts/prettier/index
87
- run: node ./scripts/tasks/eslint
88
- run: ./scripts/circleci/check_license.sh
@@ -87,8 +95,7 @@ jobs:
95
96
steps:
97
- checkout
90
- - *restore_yarn_cache
91
- - *run_yarn
98
+ - *restore_node_modules
99
- run: node ./scripts/tasks/flow-ci
100
101
RELEASE_CHANNEL_stable_yarn_test:
@@ -98,8 +105,7 @@ jobs:
105
106
steps:
107
- checkout
101
- - *restore_yarn_cache
102
- - *run_yarn
108
+ - *restore_node_modules
109
- run: yarn test --release-channel=stable --ci
110
111
yarn_test:
@@ -108,8 +114,7 @@ jobs:
114
parallelism: *TEST_PARALLELISM
115
steps:
116
- checkout
111
- - *restore_yarn_cache
112
- - *run_yarn
117
+ - *restore_node_modules
118
- run: yarn test --ci
119
120
RELEASE_CHANNEL_stable_yarn_test_www:
@@ -118,8 +123,7 @@ jobs:
123
parallelism: *TEST_PARALLELISM
124
steps:
125
- checkout
121
- - *restore_yarn_cache
122
- - *run_yarn
126
+ - *restore_node_modules
127
- run: yarn test --release-channel=www-classic --ci
128
129
RELEASE_CHANNEL_stable_yarn_test_www_variant:
@@ -128,8 +132,7 @@ jobs:
132
parallelism: *TEST_PARALLELISM
133
steps:
134
- checkout
131
- - *restore_yarn_cache
132
- - *run_yarn
135
+ - *restore_node_modules
136
- run: yarn test --release-channel=www-classic --variant --ci
137
138
RELEASE_CHANNEL_stable_yarn_test_prod_www:
@@ -138,8 +141,7 @@ jobs:
141
parallelism: *TEST_PARALLELISM
142
steps:
143
- checkout
141
- - *restore_yarn_cache
142
- - *run_yarn
144
+ - *restore_node_modules
145
- run: yarn test --release-channel=www-classic --prod --ci
146
147
RELEASE_CHANNEL_stable_yarn_test_prod_www_variant:
@@ -148,8 +150,7 @@ jobs:
150
parallelism: *TEST_PARALLELISM
151
steps:
152
- checkout
151
- - *restore_yarn_cache
152
- - *run_yarn
153
+ - *restore_node_modules
154
- run: yarn test --release-channel=www-classic --prod --variant --ci
155
156
yarn_test_www:
@@ -158,8 +159,7 @@ jobs:
159
parallelism: *TEST_PARALLELISM
160
steps:
161
- checkout
161
- - *restore_yarn_cache
162
- - *run_yarn
162
+ - *restore_node_modules
163
- run: yarn test --release-channel=www-modern --ci
164
165
yarn_test_www_variant:
@@ -168,8 +168,7 @@ jobs:
168
parallelism: *TEST_PARALLELISM
169
steps:
170
- checkout
171
- - *restore_yarn_cache
172
- - *run_yarn
171
+ - *restore_node_modules
172
- run: yarn test --release-channel=www-modern --variant --ci
173
174
yarn_test_prod_www:
@@ -178,8 +177,7 @@ jobs:
177
parallelism: *TEST_PARALLELISM
178
steps:
179
- checkout
181
- - *restore_yarn_cache
182
- - *run_yarn
180
+ - *restore_node_modules
181
- run: yarn test --release-channel=www-modern --prod --ci
182
183
yarn_test_prod_www_variant:
@@ -188,8 +186,7 @@ jobs:
186
parallelism: *TEST_PARALLELISM
187
steps:
188
- checkout
191
- - *restore_yarn_cache
192
- - *run_yarn
189
+ - *restore_node_modules
190
- run: yarn test --release-channel=www-modern --prod --variant --ci
191
192
RELEASE_CHANNEL_stable_yarn_test_persistent:
@@ -199,8 +196,7 @@ jobs:
196
197
steps:
198
- checkout
202
- - *restore_yarn_cache
203
- - *run_yarn
199
+ - *restore_node_modules
200
- run: yarn test --release-channel=stable --persistent --ci
201
202
RELEASE_CHANNEL_stable_yarn_test_prod:
@@ -210,8 +206,7 @@ jobs:
206
207
steps:
208
- checkout
213
- - *restore_yarn_cache
214
- - *run_yarn
209
+ - *restore_node_modules
210
- run: yarn test --release-channel=stable --prod --ci
211
212
yarn_test_prod:
@@ -220,8 +215,7 @@ jobs:
215
parallelism: *TEST_PARALLELISM
216
steps:
217
- checkout
223
- - *restore_yarn_cache
224
- - *run_yarn
218
+ - *restore_node_modules
219
- run: yarn test --release-channel=experimental --prod --ci
220
221
RELEASE_CHANNEL_stable_yarn_build:
@@ -230,8 +224,7 @@ jobs:
224
parallelism: *TEST_PARALLELISM
225
steps:
226
- checkout
233
- - *restore_yarn_cache
234
- - *run_yarn
227
+ - *restore_node_modules
228
- run:
229
environment:
230
RELEASE_CHANNEL: stable
@@ -257,8 +250,7 @@ jobs:
250
parallelism: 20
251
steps:
252
- checkout
260
- - *restore_yarn_cache
261
- - *run_yarn
253
+ - *restore_node_modules
254
- run:
255
environment:
256
RELEASE_CHANNEL: experimental
@@ -285,8 +277,7 @@ jobs:
277
steps:
278
- checkout
279
- attach_workspace: *attach_workspace
288
- - *restore_yarn_cache
289
- - *run_yarn
280
+ - *restore_node_modules
281
- run:
282
environment:
283
RELEASE_CHANNEL: experimental
@@ -305,8 +296,7 @@ jobs:
296
steps:
297
- checkout
298
- attach_workspace: *attach_workspace
308
- - *restore_yarn_cache
309
- - *run_yarn
299
+ - *restore_node_modules
300
# This runs in the process_artifacts job, too, but it's faster to run
301
# this step in both jobs instead of running the jobs sequentially
302
- run: node ./scripts/rollup/consolidateBundleSizes.js
@@ -321,8 +311,7 @@ jobs:
311
steps:
312
- checkout
313
- attach_workspace: *attach_workspace
324
- - *restore_yarn_cache
325
- - *run_yarn
314
+ - *restore_node_modules
315
# This runs in the process_artifacts job, too, but it's faster to run
316
# this step in both jobs instead of running the jobs sequentially
317
- run: node ./scripts/rollup/consolidateBundleSizes.js
@@ -337,8 +326,7 @@ jobs:
326
steps:
327
- checkout
328
- attach_workspace: *attach_workspace
340
- - *restore_yarn_cache
341
- - *run_yarn
329
+ - *restore_node_modules
330
- run: yarn lint-build
331
- run: scripts/circleci/check_minified_errors.sh
332
@@ -348,8 +336,7 @@ jobs:
336
steps:
337
- checkout
338
- attach_workspace: *attach_workspace
351
- - *restore_yarn_cache
352
- - *run_yarn
339
+ - *restore_node_modules
340
- run:
341
environment:
342
RELEASE_CHANNEL: stable
@@ -363,8 +350,7 @@ jobs:
350
steps:
351
- checkout
352
- attach_workspace: *attach_workspace
366
- - *restore_yarn_cache
367
- - *run_yarn
353
+ - *restore_node_modules
354
- run: yarn test --release-channel=stable --build --ci
355
356
yarn_test_build:
@@ -374,8 +360,7 @@ jobs:
360
steps:
361
- checkout
362
- attach_workspace: *attach_workspace
377
- - *restore_yarn_cache
378
- - *run_yarn
363
+ - *restore_node_modules
364
- run: yarn test --release-channel=experimental --build --ci
365
366
yarn_test_build_devtools:
@@ -384,8 +369,7 @@ jobs:
369
steps:
370
- checkout
371
- attach_workspace: *attach_workspace
387
- - *restore_yarn_cache
388
- - *run_yarn
372
+ - *restore_node_modules
373
- run: yarn test --project=devtools --build --ci
374
375
RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
@@ -394,7 +378,7 @@ jobs:
378
steps:
379
- checkout
380
- attach_workspace: *attach_workspace
397
- - *restore_yarn_cache
381
+ - *restore_node_modules
382
- run:
383
name: Run DOM fixture tests
384
environment:
@@ -410,8 +394,7 @@ jobs:
394
environment: *environment
395
steps:
396
- checkout
413
- - *restore_yarn_cache
414
- - *run_yarn
397
+ - *restore_node_modules
398
- run:
399
name: Run fuzz tests
400
command: |
@@ -425,8 +408,7 @@ jobs:
408
steps:
409
- checkout
410
- attach_workspace: *attach_workspace
428
- - *restore_yarn_cache
429
- - *run_yarn
411
+ - *restore_node_modules
412
- run: yarn test --release-channel=stable --build --prod --ci
413
414
yarn_test_build_prod:
@@ -436,8 +418,7 @@ jobs:
418
steps:
419
- checkout
420
- attach_workspace: *attach_workspace
439
- - *restore_yarn_cache
440
- - *run_yarn
421
+ - *restore_node_modules
422
- run: yarn test --release-channel=experimental --build --prod --ci
423
424
workflows: