Skip to content

Commit c0fabe9

Browse files
authored
feat: add parameter to enable/disable AVD caching (#81)
Add parameter to disable AVD caching.
1 parent 6b2de9e commit c0fabe9

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

actions/android/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ inputs:
2222
required: false
2323
type: string
2424
default: ''
25+
cacheAvd:
26+
description: Whether to cache the AVD
27+
required: false
28+
type: boolean
29+
default: 'true'
2530
runs:
2631
using: 'composite'
2732
steps:
@@ -68,6 +73,7 @@ runs:
6873
sudo udevadm trigger --name-match=kvm
6974
ls /dev/kvm
7075
- name: Compute AVD cache key
76+
if: ${{ fromJSON(inputs.cacheAvd) }}
7177
id: avd-key
7278
shell: bash
7379
run: |
@@ -78,6 +84,7 @@ runs:
7884
CACHE_KEY="avd-$ARCH-$AVD_CONFIG_HASH"
7985
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
8086
- name: Restore AVD cache
87+
if: ${{ fromJSON(inputs.cacheAvd) }}
8188
uses: actions/cache/restore@v4
8289
id: avd-cache
8390
with:
@@ -86,7 +93,7 @@ runs:
8693
~/.android/adb*
8794
key: ${{ steps.avd-key.outputs.key }}
8895
- name: Create AVD and generate snapshot for caching
89-
if: steps.avd-cache.outputs.cache-hit != 'true'
96+
if: ${{ fromJSON(inputs.cacheAvd) && steps.avd-cache.outputs.cache-hit != 'true' }}
9097
uses: reactivecircus/android-emulator-runner@v2
9198
with:
9299
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
@@ -100,7 +107,7 @@ runs:
100107
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
101108
script: echo "Generated AVD snapshot for caching."
102109
- name: Save AVD cache
103-
if: steps.avd-cache.outputs.cache-hit != 'true'
110+
if: ${{ fromJSON(inputs.cacheAvd) && steps.avd-cache.outputs.cache-hit != 'true' }}
104111
uses: actions/cache/save@v4
105112
with:
106113
path: |

packages/github-action/src/android/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ inputs:
2222
required: false
2323
type: string
2424
default: ''
25+
cacheAvd:
26+
description: Whether to cache the AVD
27+
required: false
28+
type: boolean
29+
default: 'true'
2530
runs:
2631
using: 'composite'
2732
steps:
@@ -68,6 +73,7 @@ runs:
6873
sudo udevadm trigger --name-match=kvm
6974
ls /dev/kvm
7075
- name: Compute AVD cache key
76+
if: ${{ fromJSON(inputs.cacheAvd) }}
7177
id: avd-key
7278
shell: bash
7379
run: |
@@ -78,6 +84,7 @@ runs:
7884
CACHE_KEY="avd-$ARCH-$AVD_CONFIG_HASH"
7985
echo "key=$CACHE_KEY" >> $GITHUB_OUTPUT
8086
- name: Restore AVD cache
87+
if: ${{ fromJSON(inputs.cacheAvd) }}
8188
uses: actions/cache/restore@v4
8289
id: avd-cache
8390
with:
@@ -86,7 +93,7 @@ runs:
8693
~/.android/adb*
8794
key: ${{ steps.avd-key.outputs.key }}
8895
- name: Create AVD and generate snapshot for caching
89-
if: steps.avd-cache.outputs.cache-hit != 'true'
96+
if: ${{ fromJSON(inputs.cacheAvd) && steps.avd-cache.outputs.cache-hit != 'true' }}
9097
uses: reactivecircus/android-emulator-runner@v2
9198
with:
9299
api-level: ${{ fromJson(steps.load-config.outputs.config).config.device.avd.apiLevel }}
@@ -100,7 +107,7 @@ runs:
100107
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
101108
script: echo "Generated AVD snapshot for caching."
102109
- name: Save AVD cache
103-
if: steps.avd-cache.outputs.cache-hit != 'true'
110+
if: ${{ fromJSON(inputs.cacheAvd) && steps.avd-cache.outputs.cache-hit != 'true' }}
104111
uses: actions/cache/save@v4
105112
with:
106113
path: |

0 commit comments

Comments
 (0)