Skip to content

Commit 2f451d8

Browse files
committed
Cache CI Node Modules
1 parent 007a3bb commit 2f451d8

File tree

1 file changed

+36
-59
lines changed

1 file changed

+36
-59
lines changed

.circleci/config.yml

Lines changed: 36 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ orbs:
55
advanced-checkout: vsco/[email protected]
66

77
commands:
8+
install_node_modules:
9+
parameters:
10+
working_directory:
11+
type: string
12+
default: .
13+
steps:
14+
- restore_cache:
15+
name: Restore Yarn Cache
16+
keys:
17+
- v0.2-node-modules-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
18+
- run:
19+
name: Install Node Modules
20+
working_directory: << parameters.working_directory >>
21+
command: yarn install --frozen-lockfile --cache-folder /tmp/.cache/yarn
22+
- save_cache:
23+
name: Save Yarn Cache
24+
key: v0.2-node-modules-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
25+
paths:
26+
- /tmp/.cache/yarn
27+
828
install_pods:
929
parameters:
1030
working_directory:
@@ -37,9 +57,7 @@ jobs:
3757
- image: cimg/node:16.17.1
3858
steps:
3959
- advanced-checkout/shallow-checkout
40-
- run:
41-
name: Install Node Packages
42-
command: yarn
60+
- install_node_modules
4361
- run:
4462
name: Check Format
4563
command: yarn format
@@ -52,45 +70,22 @@ jobs:
5270
- image: cimg/node:16.17.1
5371
steps:
5472
- advanced-checkout/shallow-checkout
55-
56-
- run:
57-
name: Install Node Packages
58-
command: yarn
59-
60-
- run:
61-
name: jest tests
62-
command: |
63-
mkdir -p test-results/jest
64-
yarn run test
65-
environment:
66-
JEST_JUNIT_OUTPUT: test-results/jest/junit.xml
67-
68-
- persist_to_workspace:
69-
root: ~/project
70-
paths:
71-
- node_modules
72-
73-
- store_test_results:
74-
path: test-results
75-
76-
- store_artifacts:
77-
path: test-results
73+
- install_node_modules
74+
- run: yarn test
7875

7976
test_android:
8077
executor:
8178
name: android/android-machine
8279
tag: '2022.03.1'
80+
working_directory: ~/project/example
8381
steps:
8482
- advanced-checkout/shallow-checkout
8583
- run:
8684
name: Install Yarn
8785
command: npm install -g yarn
88-
- run:
89-
name: Install Node Packages
90-
working_directory: example
91-
command: yarn
86+
- install_node_modules
9287
- android/run-tests:
93-
working-directory: ./example/android
88+
working-directory: android
9489
test-command: ./gradlew test -PinstabugUploadEnable=false
9590

9691
validate_shell_files:
@@ -113,8 +108,9 @@ jobs:
113108
xcode: 13.4.1
114109
steps:
115110
- advanced-checkout/shallow-checkout
116-
- run: yarn
117-
- run: cd example && yarn
111+
- install_node_modules
112+
- install_node_modules:
113+
working_directory: example
118114
- install_pods:
119115
working_directory: example/ios
120116
- run: git --no-pager diff
@@ -128,9 +124,7 @@ jobs:
128124
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
129125
steps:
130126
- advanced-checkout/shallow-checkout
131-
- run:
132-
name: Install node_modules
133-
command: yarn
127+
- install_node_modules
134128
- install_pods:
135129
working_directory: ios
136130
- run:
@@ -165,25 +159,15 @@ jobs:
165159
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
166160
steps:
167161
- advanced-checkout/shallow-checkout
168-
- run:
169-
name: Install React Native CLI
170-
command: npm install -g react-native-cli
171162
- run:
172163
name: Install Detox CLI
173164
command: npm install -g detox-cli
174165
- run:
175166
name: Install Detox Utils
176167
command: brew tap wix/brew && brew install applesimutils
177-
- run:
178-
name: Install Node Packages
179-
command: yarn
180-
- run:
181-
name: Build Project
182-
command: yarn build:lib
183-
- run:
184-
name: Install Example's Node Packages
168+
- install_node_modules
169+
- install_node_modules:
185170
working_directory: example
186-
command: yarn
187171
- install_pods:
188172
working_directory: example/ios
189173
- run:
@@ -204,20 +188,13 @@ jobs:
204188
- advanced-checkout/shallow-checkout
205189
- run:
206190
name: Install Yarn
207-
command: npm install --global yarn
191+
command: npm install -g yarn
208192
- run:
209193
name: Install Detox CLI
210-
command: npm install --global detox-cli
211-
- run:
212-
name: Install Node Packages
213-
command: yarn
214-
- run:
215-
name: Build Project
216-
command: yarn build:lib
217-
- run:
218-
name: Install Example's Node Packages
194+
command: npm install -g detox-cli
195+
- install_node_modules
196+
- install_node_modules:
219197
working_directory: example
220-
command: yarn
221198
- android/create-avd:
222199
avd-name: Nexus_6P_API_27
223200
install: true

0 commit comments

Comments
 (0)