@@ -132,15 +132,6 @@ jobs:
132132 yarn install --cwd example
133133 yarn install
134134
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-
144135 - name : Get build target
145136 working-directory : ${{ env.work_dir }}
146137 run : |
@@ -158,6 +149,31 @@ jobs:
158149 fi
159150 fi
160151
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+
161177 - name : Lint library
162178 working-directory : ${{ env.work_dir }}
163179 run : |
@@ -185,25 +201,27 @@ jobs:
185201 yarn example expo export:web
186202
187203 - name : Install JDK
188- if : env.android_build == 1
204+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
189205 uses : actions/setup-java@v3
190206 with :
191207 distribution : ' zulu'
192208 java-version : ' 11'
193209
194210 - name : Finalize Android SDK
195- if : env.android_build == 1
211+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
196212 run : |
197213 /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
198214
199215 - name : Cache Gradle
200- if : env.android_build == 1
216+ if : env.android_build == 1 && env.turbo_cache_hit_android != 1
201217 uses : actions/cache@v3
202218 with :
203219 path : |
204220 ~/.gradle/wrapper
205221 ~/.gradle/caches
206222 key : ${{ runner.os }}-gradle-${{ hashFiles(format('{0}/example/android/gradle/wrapper/gradle-wrapper.properties', env.work_dir)) }}
223+ restore-keys : |
224+ ${{ runner.os }}-gradle-
207225
208226 - name : Build example (Android)
209227 if : env.android_build == 1
@@ -212,20 +230,20 @@ jobs:
212230 yarn turbo run build:android --cache-dir=".turbo/cache"
213231
214232 - name : Cache cocoapods
215- if : env.ios_build == 1
233+ if : env.ios_build == 1 && env.turbo_cache_hit_ios != 1
216234 id : library-cocoapods-cache
217235 uses : actions/cache@v3
218236 with :
219237 path : |
220238 ${{ env.work_dir }}/**/ios/Pods
221239 ${{ 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)) }}
223241 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)) }}-
225243 ${{ runner.os }}-library-cocoapods-
226244
227245 - 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'
229247 working-directory : ${{ env.work_dir }}
230248 run : |
231249 yarn example pods
0 commit comments