11name : Testing E2E Android
22
33on :
4+ workflow_dispatch :
5+ inputs :
6+ clearCaches :
7+ description : " Clear workflow caches where possible"
8+ required : false
9+ type : string
10+
411 pull_request :
512 branches :
613 - ' **'
@@ -111,10 +118,21 @@ jobs:
111118 path : |
112119 ~/.android/avd/*
113120 ~/.android/adb*
114- key : avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1-${{ hashFiles('~/.android/avd/**/snapshots/**') }}
121+ key : avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1-${{ github.event.inputs.clearCaches }}
115122 restore-keys : |
116123 avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1
117124
125+ - name : Clear Caches Optionally
126+ if : " ${{ github.event.inputs.clearCaches != '' }}"
127+ shell : bash
128+ run : |
129+ du -sk ~/.gradle
130+ du -sk ~/.android
131+ rm -fr ~/.gradle
132+ rm -fr ~/.android
133+ du -sk ~/.gradle || echo ~/.gradle is gone
134+ du -sk ~/.android || echo ~/.android is gone
135+
118136 - name : Build Android App
119137 uses : nick-invision/retry@v2
120138 with :
@@ -146,7 +164,7 @@ jobs:
146164 - name : AVD Boot and Snapshot Creation
147165 # Only generate a snapshot with a cache miss
148166 # Comment the if out to generate snapshots on branch for performance testing
149- if : steps.avd-cache.outputs.cache-hit != 'true'
167+ if : " ${{ github.event.inputs.clearCaches != '' || ( steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main') }} "
150168 uses : reactivecircus/android-emulator-runner@v2
151169 with :
152170 api-level : ${{ matrix.api-level }}
@@ -168,7 +186,7 @@ jobs:
168186 # Only generate a snapshot for saving with a cache miss
169187 # Switch the if statements via comment if generating snapshots for performance testing
170188 # if: matrix.first-boot-delay != '0'
171- if : steps.avd-cache.outputs.cache-hit != 'true'
189+ if : " ${{ github.event.inputs.clearCaches != '' || ( steps.avd-cache.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main') }} "
172190 env :
173191 FIRST_BOOT_DELAY : ${{ matrix.first-boot-delay }}
174192 uses : reactivecircus/android-emulator-runner@v2
0 commit comments