Skip to content

Commit 8816991

Browse files
authored
Improve APK caching in CI (#2626)
1 parent d36f2f9 commit 8816991

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ jobs:
182182
183183
- name: Check turborepo cache for Android
184184
run: |
185-
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
185+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.taskId === 'paper#build:android').cache.status")
186+
TURBO_HASH=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.taskId === 'paper#build:android').hash")
186187
187188
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
188189
echo "turbo_cache_hit=1" >> $GITHUB_ENV
190+
echo "turbo_hash=$TURBO_HASH" >> $GITHUB_ENV
189191
fi
190192
191193
- name: Install JDK
@@ -233,16 +235,19 @@ jobs:
233235
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --concurrency 1
234236
235237
- name: Cache apk
238+
if: env.turbo_cache_hit != 1
236239
uses: actions/cache/save@v3
237240
env:
238241
cache-name: cache-apk
239242
with:
240243
path: apps/paper/android/app/build/outputs/apk/debug/app-debug.apk
241-
key: apk-${{ github.sha }}
244+
key: apk-${{ env.turbo_hash }}
242245

243246
test-android:
244247
needs: build-android
245248
runs-on: macos-latest-large
249+
env:
250+
TURBO_CACHE_DIR: .turbo/android
246251
strategy:
247252
matrix:
248253
working-directory: [apps/paper]
@@ -256,13 +261,21 @@ jobs:
256261
uses: ./.github/actions/setup
257262
with:
258263
github_token: ${{ secrets.GITHUB_TOKEN }}
259-
264+
265+
- name: Check turborepo cache for Android
266+
run: |
267+
TURBO_HASH=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.taskId === 'paper#build:android').hash")
268+
269+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
270+
echo "turbo_hash=$TURBO_HASH" >> $GITHUB_ENV
271+
fi
272+
260273
- name: Restore APK
261274
id: cache-apk
262275
uses: actions/cache/restore@v3
263276
with:
264277
path: ${{ matrix.working-directory }}/android/app/build/outputs/apk/debug/app-debug.apk
265-
key: apk-${{ github.sha }}
278+
key: apk-${{ env.turbo_hash }}
266279

267280
- name: SKDs - download required images
268281
run: $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-30;default;x86_64"

0 commit comments

Comments
 (0)