@@ -132,15 +132,6 @@ jobs:
132
132
yarn install --cwd example
133
133
yarn install
134
134
135
- - name : Cache turborepo
136
- uses : actions/cache@v3
137
- with :
138
- path : |
139
- ${{ env.work_dir }}/.turbo
140
- key : ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }}
141
- restore-keys : |
142
- ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-
143
-
144
135
- name : Get build target
145
136
working-directory : ${{ env.work_dir }}
146
137
run : |
@@ -158,6 +149,31 @@ jobs:
158
149
fi
159
150
fi
160
151
152
+ - name : Cache turborepo
153
+ if : env.android_build == 1 || env.ios_build == 1
154
+ uses : actions/cache@v3
155
+ with :
156
+ path : |
157
+ ${{ env.work_dir }}/.turbo
158
+ key : ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }}
159
+ restore-keys : |
160
+ ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-
161
+
162
+ - name : Check turborepo cache
163
+ if : env.android_build == 1 || env.ios_build == 1
164
+ working-directory : ${{ env.work_dir }}
165
+ run : |
166
+ TURBO_CACHE_STATUS_ANDROID=$(node -p "($(yarn --silent turbo run build:android --cache-dir=".turbo/cache" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
167
+ TURBO_CACHE_STATUS_IOS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir=".turbo/cache" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
168
+
169
+ if [[ $TURBO_CACHE_STATUS_ANDROID == "HIT" ]]; then
170
+ echo "turbo_cache_hit_android=1" >> $GITHUB_ENV
171
+ fi
172
+
173
+ if [[ $TURBO_CACHE_STATUS_IOS == "HIT" ]]; then
174
+ echo "turbo_cache_hit_ios=1" >> $GITHUB_ENV
175
+ fi
176
+
161
177
- name : Lint library
162
178
working-directory : ${{ env.work_dir }}
163
179
run : |
@@ -185,25 +201,27 @@ jobs:
185
201
yarn example expo export:web
186
202
187
203
- name : Install JDK
188
- if : env.android_build == 1
204
+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
189
205
uses : actions/setup-java@v3
190
206
with :
191
207
distribution : ' zulu'
192
208
java-version : ' 11'
193
209
194
210
- name : Finalize Android SDK
195
- if : env.android_build == 1
211
+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
196
212
run : |
197
213
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
198
214
199
215
- name : Cache Gradle
200
- if : env.android_build == 1
216
+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
201
217
uses : actions/cache@v3
202
218
with :
203
219
path : |
204
220
~/.gradle/wrapper
205
221
~/.gradle/caches
206
222
key : ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }}
223
+ restore-keys : |
224
+ ${{ runner.os }}-gradle-
207
225
208
226
- name : Build example (Android)
209
227
if : env.android_build == 1
@@ -212,20 +230,20 @@ jobs:
212
230
yarn turbo run build:android --cache-dir=".turbo/cache"
213
231
214
232
- name : Cache cocoapods
215
- if : env.ios_build == 1
233
+ if : env.ios_build == 1 && env.turbo_cache_hit_ios != 1
216
234
id : library-cocoapods-cache
217
235
uses : actions/cache@v3
218
236
with :
219
237
path : |
220
238
${{ env.work_dir }}/**/ios/Pods
221
239
${{ env.work_dir }}/**/ios/Podfile.lock
222
- key : ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/** /Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }}
240
+ key : ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios /Podfile', env.work_dir)) }}-${{ hashFiles(format('{0}/**/yarn.lock', env.work_dir)) }}
223
241
restore-keys : |
224
- ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/** /Podfile', env.work_dir)) }}-
242
+ ${{ runner.os }}-library-cocoapods-${{ hashFiles(format('{0}/example/ios /Podfile', env.work_dir)) }}-
225
243
${{ runner.os }}-library-cocoapods-
226
244
227
245
- name : Install cocoapods
228
- if : steps.library-cocoapods-cache.outputs.cache-hit != 'true' && env.ios_build == 1
246
+ if : env.ios_build == 1 && env.turbo_cache_hit_ios != 1 && steps.library-cocoapods-cache.outputs.cache-hit != 'true'
229
247
working-directory : ${{ env.work_dir }}
230
248
run : |
231
249
yarn example pods
0 commit comments