From 984143c4da77435bee34cbdee2718868821734c3 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 08:47:15 -0400 Subject: [PATCH 1/7] dataconnect.yml: fix missing cache keys when saving to cache --- .github/workflows/dataconnect.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index 9fa9511d717..2c47c06e10d 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -27,6 +27,8 @@ env: FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '13.29.1' }} FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase + FDC_GRADLE_CACHE_KEY: gradle-cache-jqnvfzw6w7-${{ github.run_id }} + FDC_AVD_CACHE_KEY: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -80,7 +82,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: gradle-cache-jqnvfzw6w7-${{ github.run_id }} + key: ${{ env.FDC_GRADLE_CACHE_KEY }} restore-keys: | gradle-cache-jqnvfzw6w7- @@ -124,7 +126,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ steps.restore-gradle-cache.outputs.cache-primary-key }} + key: ${{ env.FDC_GRADLE_CACHE_KEY }} - name: Enable KVM group permissions for Android Emulator run: | @@ -141,7 +143,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }} + key: ${{ env.FDC_AVD_CACHE_KEY }} restore-keys: | avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- @@ -163,7 +165,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: ${{ steps.restore-avd-cache.outputs.cache-primary-key }} + key: ${{ env.FDC_AVD_CACHE_KEY }} - name: Data Connect Emulator run: | From a4c786fda27e277f2745a9d20376773a37660ac5 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 08:55:59 -0400 Subject: [PATCH 2/7] REVERT ME: run the steps that are only to be run in the scheduled runs to verify that they run correctly. --- .github/workflows/dataconnect.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index 2c47c06e10d..fd9ebc97a85 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -77,7 +77,6 @@ jobs: - name: Restore Gradle cache id: restore-gradle-cache uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 - if: github.event_name != 'schedule' with: path: | ~/.gradle/caches @@ -121,7 +120,6 @@ jobs: - name: Save Gradle cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 - if: github.event_name == 'schedule' with: path: | ~/.gradle/caches @@ -137,7 +135,6 @@ jobs: - name: Restore AVD cache uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 - if: github.event_name != 'schedule' id: restore-avd-cache with: path: | @@ -148,7 +145,7 @@ jobs: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- - name: Create AVD - if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-hit != 'true' + if: steps.restore-avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0 with: api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }} @@ -160,7 +157,6 @@ jobs: - name: Save AVD cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 - if: github.event_name == 'schedule' with: path: | ~/.android/avd/* From d9acccac5ee894c68a354a6df7f80510aa66234e Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 09:23:31 -0400 Subject: [PATCH 3/7] hardcode keys since ${{ env.XXX }} is not available in the "env" section --- .github/workflows/dataconnect.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index fd9ebc97a85..5e73c5ec865 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -27,8 +27,6 @@ env: FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '13.29.1' }} FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase - FDC_GRADLE_CACHE_KEY: gradle-cache-jqnvfzw6w7-${{ github.run_id }} - FDC_AVD_CACHE_KEY: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }} concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -81,7 +79,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ env.FDC_GRADLE_CACHE_KEY }} + key: gradle-cache-jqnvfzw6w7-${{ github.run_id }} restore-keys: | gradle-cache-jqnvfzw6w7- @@ -124,7 +122,7 @@ jobs: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ env.FDC_GRADLE_CACHE_KEY }} + key: gradle-cache-jqnvfzw6w7-${{ github.run_id }} - name: Enable KVM group permissions for Android Emulator run: | @@ -140,7 +138,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: ${{ env.FDC_AVD_CACHE_KEY }} + key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }} restore-keys: | avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- @@ -161,7 +159,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: ${{ env.FDC_AVD_CACHE_KEY }} + key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }} - name: Data Connect Emulator run: | From e40b0a960c924eeb28c5b490f715e8cd689d3854 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 09:45:37 -0400 Subject: [PATCH 4/7] dataconnect.yml: revert a4c786fda27e277f2745a9d20376773a37660ac5 --- .github/workflows/dataconnect.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index 5e73c5ec865..fc0a029ccd3 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -75,6 +75,7 @@ jobs: - name: Restore Gradle cache id: restore-gradle-cache uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 + if: github.event_name != 'schedule' with: path: | ~/.gradle/caches @@ -118,6 +119,7 @@ jobs: - name: Save Gradle cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 + if: github.event_name == 'schedule' with: path: | ~/.gradle/caches @@ -133,6 +135,7 @@ jobs: - name: Restore AVD cache uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 + if: github.event_name != 'schedule' id: restore-avd-cache with: path: | @@ -143,7 +146,7 @@ jobs: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- - name: Create AVD - if: steps.restore-avd-cache.outputs.cache-hit != 'true' + if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0 with: api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }} @@ -155,6 +158,7 @@ jobs: - name: Save AVD cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 + if: github.event_name == 'schedule' with: path: | ~/.android/avd/* From 71a4aea9c0df7db9b5f8abb88a5959bcc5e90046 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 10:05:26 -0400 Subject: [PATCH 5/7] dataconnect.yml: fix logic that determines when to run the "Create AVD" step by using `cache-matched-key` instead of `cache-hit` See https://github.com/actions/cache/tree/main/restore --- .github/workflows/dataconnect.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index fc0a029ccd3..333645905a2 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -146,7 +146,7 @@ jobs: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- - name: Create AVD - if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-hit != 'true' + if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-matched-key != '' uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0 with: api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }} @@ -154,7 +154,7 @@ jobs: force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: echo "Generated AVD snapshot for caching." + script: echo "Generated AVD snapshot for caching: event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}" - name: Save AVD cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 From 1a611550679eda5e5b8d0ad403e768b7b120d790 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 10:33:57 -0400 Subject: [PATCH 6/7] dataconnect.yml: fix syntax error by quoting a string with single quotes --- .github/workflows/dataconnect.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index 333645905a2..f924ac26cf8 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -154,7 +154,7 @@ jobs: force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: echo "Generated AVD snapshot for caching: event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}" + script: 'echo "Generated AVD snapshot for caching: event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}"' - name: Save AVD cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 From fa17dde5dd829995a9a209199f9e4d66764aeab1 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 2 Apr 2025 12:24:26 -0400 Subject: [PATCH 7/7] dataconnect.yml: fix != to == in "Create AVD" if statement --- .github/workflows/dataconnect.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dataconnect.yml b/.github/workflows/dataconnect.yml index f924ac26cf8..0c9eb2205e3 100644 --- a/.github/workflows/dataconnect.yml +++ b/.github/workflows/dataconnect.yml @@ -146,7 +146,7 @@ jobs: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}- - name: Create AVD - if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-matched-key != '' + if: github.event_name == 'schedule' || steps.restore-avd-cache.outputs.cache-matched-key == '' uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0 with: api-level: ${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }} @@ -154,7 +154,7 @@ jobs: force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: 'echo "Generated AVD snapshot for caching: event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}"' + script: 'echo "Generated AVD snapshot for caching; event_name=${{ github.event_name }}, cache-matched-key=${{ steps.restore-avd-cache.outputs.cache-matched-key }}"' - name: Save AVD cache uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2