1
1
name : Testing E2E Android
2
2
3
3
on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ clearCaches :
7
+ description : " Clear workflow caches where possible"
8
+ required : false
9
+ type : string
10
+
4
11
pull_request :
5
12
branches :
6
13
- ' **'
@@ -111,10 +118,21 @@ jobs:
111
118
path : |
112
119
~/.android/avd/*
113
120
~/.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 }}
115
122
restore-keys : |
116
123
avd-${{ matrix.api-level }}-${{ matrix.arch }}-${{matrix.target}}-v1
117
124
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
+
118
136
- name : Build Android App
119
137
uses : nick-invision/retry@v2
120
138
with :
@@ -146,7 +164,7 @@ jobs:
146
164
- name : AVD Boot and Snapshot Creation
147
165
# Only generate a snapshot with a cache miss
148
166
# 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') }} "
150
168
uses : reactivecircus/android-emulator-runner@v2
151
169
with :
152
170
api-level : ${{ matrix.api-level }}
@@ -168,7 +186,7 @@ jobs:
168
186
# Only generate a snapshot for saving with a cache miss
169
187
# Switch the if statements via comment if generating snapshots for performance testing
170
188
# 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') }} "
172
190
env :
173
191
FIRST_BOOT_DELAY : ${{ matrix.first-boot-delay }}
174
192
uses : reactivecircus/android-emulator-runner@v2
0 commit comments