Skip to content

Commit ec291fd

Browse files
committed
CI: updated caching strategy
1 parent aca7f30 commit ec291fd

1 file changed

Lines changed: 55 additions & 40 deletions

File tree

.circleci/config.yml

Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,62 @@ aliases:
1010
- &restore_yarn_cache
1111
restore_cache:
1212
name: Restore yarn cache
13-
key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
13+
keys:
14+
- v1-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}
15+
- v1-yarn_cache-{{ arch }}-
16+
- v1-yarn_cache-
17+
18+
- &yarn_install
19+
run:
20+
name: Install dependencies
21+
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
22+
23+
- &save_yarn_cache
24+
save_cache:
25+
name: Save yarn cache
26+
key: v1-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}
27+
paths:
28+
- ~/.cache/yarn
29+
30+
- &restore_yarn_cache_fixtures_dom
31+
restore_cache:
32+
name: Restore yarn cache for fixtures/dom
33+
keys:
34+
- v1-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}-fixtures/dom
35+
- v1-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}
36+
- v1-yarn_cache-{{ arch }}-
37+
- v1-yarn_cache-
38+
39+
- &yarn_install_fixtures_dom
40+
run:
41+
name: Install dependencies in fixtures/dom
42+
working_directory: fixtures/dom
43+
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
44+
45+
- &save_yarn_cache_fixtures_dom
46+
save_cache:
47+
name: Save yarn cache for fixtures/dom
48+
key: v1-yarn_cache-{{ arch }}-{{ checksum "yarn.lock" }}-fixtures/dom
49+
paths:
50+
- ~/.cache/yarn
1451

1552
- &prepare_node_modules_cache_key
1653
run:
1754
name: Preparing node_modules cache key
1855
command: yarn workspaces info | head -n -1 > workspace_info.txt
1956

57+
- &save_node_modules
58+
save_cache:
59+
name: Save node_modules cache
60+
key: v1-node_modules-{{ arch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }}
61+
paths:
62+
- node_modules
63+
2064
- &restore_node_modules
2165
restore_cache:
2266
name: Restore node_modules cache
2367
keys:
24-
- v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }}-node-modules
68+
- v1-node_modules-{{ arch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }}
2569

2670
- &TEST_PARALLELISM 20
2771

@@ -48,28 +92,12 @@ jobs:
4892
- run:
4993
name: Nodejs Version
5094
command: node --version
95+
- *prepare_node_modules_cache_key
5196
- *restore_yarn_cache
52-
- run:
53-
name: Install Packages
54-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
55-
- run: yarn workspaces info | head -n -1 > workspace_info.txt
56-
- save_cache:
57-
# Store the yarn cache globally for all lock files with this same
58-
# checksum. This will speed up the setup job for all PRs where the
59-
# lockfile is the same.
60-
name: Save yarn cache for future installs
61-
key: v2-node-{{ arch }}-{{ checksum "yarn.lock" }}-yarn
62-
paths:
63-
- ~/.cache/yarn
64-
- save_cache:
65-
# Store node_modules for all jobs in this workflow so that they don't
66-
# need to each run a yarn install for each job. This will speed up
67-
# all jobs run on this branch with the same lockfile.
68-
name: Save node_modules cache
69-
# This cache key is per branch, a yarn install in setup is required.
70-
key: v2-node-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}-{{ checksum "workspace_info.txt" }}-node-modules
71-
paths:
72-
- node_modules
97+
- *restore_node_modules
98+
- *yarn_install
99+
- *save_yarn_cache
100+
- *save_node_modules
73101

74102
yarn_lint:
75103
docker: *docker
@@ -216,9 +244,6 @@ jobs:
216244
at: .
217245
- *prepare_node_modules_cache_key
218246
- *restore_node_modules
219-
- run:
220-
name: Install Packages
221-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
222247
- run:
223248
environment:
224249
RELEASE_CHANNEL: experimental
@@ -235,9 +260,6 @@ jobs:
235260
at: .
236261
- *prepare_node_modules_cache_key
237262
- *restore_node_modules
238-
- run:
239-
name: Install Packages
240-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
241263
- run:
242264
name: Playwright install deps
243265
command: |
@@ -261,9 +283,6 @@ jobs:
261283
at: .
262284
- *prepare_node_modules_cache_key
263285
- *restore_node_modules
264-
- run:
265-
name: Install nested packages from Yarn cache
266-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
267286
- run: ./scripts/circleci/download_devtools_regression_build.js << parameters.version >> --replaceBuild
268287
- run: node ./scripts/jest/jest-cli.js --build --project devtools --release-channel=experimental --reactVersion << parameters.version >> --ci
269288

@@ -280,9 +299,6 @@ jobs:
280299
at: .
281300
- *prepare_node_modules_cache_key
282301
- *restore_node_modules
283-
- run:
284-
name: Install nested packages from Yarn cache
285-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
286302
- run:
287303
name: Playwright install deps
288304
command: |
@@ -362,9 +378,6 @@ jobs:
362378
at: .
363379
- *prepare_node_modules_cache_key
364380
- *restore_node_modules
365-
- run:
366-
name: Install nested packages from Yarn cache
367-
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn
368381
- run: yarn test --build <<parameters.args>> --ci
369382

370383
RELEASE_CHANNEL_stable_yarn_test_dom_fixtures:
@@ -376,13 +389,15 @@ jobs:
376389
at: .
377390
- *prepare_node_modules_cache_key
378391
- *restore_node_modules
392+
- *restore_yarn_cache_fixtures_dom
393+
- *yarn_install_fixtures_dom
394+
- *save_yarn_cache_fixtures_dom
379395
- run:
380396
name: Run DOM fixture tests
381397
environment:
382398
RELEASE_CHANNEL: stable
399+
working_directory: fixtures/dom
383400
command: |
384-
cd fixtures/dom
385-
yarn --frozen-lockfile
386401
yarn prestart
387402
yarn test --maxWorkers=2
388403

0 commit comments

Comments
 (0)