|
1 | 1 | name : Run Android Instrumentation Tests with Artifact and AVD Caching
|
2 |
| -description: This action sets up Gradle, runs a preparatory task, runs Android tests on an emulator, and uploads test results. |
| 2 | +description : This action sets up Gradle, runs a preparatory task, runs Android tests on an emulator, and uploads test results. |
3 | 3 |
|
4 |
| -inputs: |
5 |
| - prepare-task: |
6 |
| - description: 'Gradle task for preparing necessary artifacts. Supports multi-line input.' |
7 |
| - required: true |
8 |
| - test-task: |
9 |
| - description: 'Gradle task for running instrumentation tests. Supports multi-line input.' |
10 |
| - required: true |
| 4 | +inputs : |
| 5 | + prepare-task : |
| 6 | + description : 'Gradle task for preparing necessary artifacts. Supports multi-line input.' |
| 7 | + required : true |
| 8 | + test-task : |
| 9 | + description : 'Gradle task for running instrumentation tests. Supports multi-line input.' |
| 10 | + required : true |
11 | 11 | api-level :
|
12 | 12 | description : 'The Android SDK api level, like `29`'
|
13 | 13 | required : true
|
@@ -43,40 +43,51 @@ runs :
|
43 | 43 | write-cache-key : ${{ inputs.write-cache-key }}
|
44 | 44 |
|
45 | 45 | # Get the AVD if it's already cached.
|
46 |
| - - name: AVD cache |
47 |
| - uses: actions/cache@v3 |
48 |
| - id: avd-cache |
49 |
| - with: |
50 |
| - path: | |
| 46 | + - name : AVD cache |
| 47 | + uses : actions/cache/restore@v3 |
| 48 | + id : restore-avd-cache |
| 49 | + with : |
| 50 | + path : | |
51 | 51 | ~/.android/avd/*
|
52 | 52 | ~/.android/adb*
|
53 |
| - key: avd-${{ matrix.api-level }} |
| 53 | + key : avd-${{ matrix.api-level }} |
54 | 54 |
|
55 |
| - # If the AVD cache didn't exist, create an AVD and cache it. |
56 |
| - - name: create AVD and generate snapshot for caching |
57 |
| - if: steps.avd-cache.outputs.cache-hit != 'true' |
58 |
| - uses: reactivecircus/android-emulator-runner@v2 |
59 |
| - with: |
60 |
| - api-level: ${{ inputs.api-level }} |
| 55 | + # If the AVD cache didn't exist, create an AVD |
| 56 | + - name : create AVD and generate snapshot for caching |
| 57 | + if : steps.restore-avd-cache.outputs.cache-hit != 'true' |
| 58 | + uses : reactivecircus/android-emulator-runner@v2 |
| 59 | + with : |
| 60 | + api-level : ${{ inputs.api-level }} |
61 | 61 | arch : x86_64
|
62 |
| - disable-animations: false |
63 |
| - emulator-boot-timeout: 12000 |
64 |
| - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
65 |
| - force-avd-creation: false |
| 62 | + disable-animations : false |
| 63 | + emulator-boot-timeout : 12000 |
| 64 | + emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 65 | + force-avd-creation : false |
66 | 66 | profile : Galaxy Nexus
|
67 |
| - ram-size: 4096M |
68 |
| - script: echo "Generated AVD snapshot." |
| 67 | + ram-size : 4096M |
| 68 | + script : echo "Generated AVD snapshot." |
| 69 | + |
| 70 | + # If we just created an AVD because there wasn't one in the cache, then cache that AVD. |
| 71 | + - name : cache new AVD before tests |
| 72 | + if : steps.restore-avd-cache.outputs.cache-hit != 'true' |
| 73 | + id : save-avd-cache |
| 74 | + uses : actions/cache/save@v3 |
| 75 | + with : |
| 76 | + path : | |
| 77 | + ~/.android/avd/* |
| 78 | + ~/.android/adb* |
| 79 | + key : avd-${{ matrix.api-level }} |
69 | 80 |
|
70 | 81 | # Run the actual emulator tests.
|
71 | 82 | # At this point every task should be up-to-date and the AVD should be ready to go.
|
72 |
| - - name: run tests |
73 |
| - uses: reactivecircus/android-emulator-runner@v2 |
74 |
| - with: |
75 |
| - api-level: ${{ inputs.api-level }} |
| 83 | + - name : run tests |
| 84 | + uses : reactivecircus/android-emulator-runner@v2 |
| 85 | + with : |
| 86 | + api-level : ${{ inputs.api-level }} |
76 | 87 | arch : x86_64
|
77 |
| - disable-animations: true |
78 |
| - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
79 |
| - force-avd-creation: false |
| 88 | + disable-animations : true |
| 89 | + emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 90 | + force-avd-creation : false |
80 | 91 | profile : Galaxy Nexus
|
81 | 92 | script : ./gradlew ${{ inputs.test-task }}
|
82 | 93 |
|
|
0 commit comments