-
Notifications
You must be signed in to change notification settings - Fork 156
169 lines (166 loc) · 7.67 KB
/
unit-and-instrumented-tests-action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: unit-and-instrumented-tests
on:
workflow_dispatch:
push:
env:
API_MIN: 21
API_CURRENT: 34
JAVA_DISTRIBUTION: 'corretto'
JAVA_VERSION: '17'
jobs:
unit-test-api-level-min:
name: unit-test-api-level-$API_MIN
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# repo's gradle is configured to run on java 17
- name: Setup java 17 for gradle
uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Run unit tests
run: |
./gradlew :Branch-SDK:testDebugUnitTest
# contains the reports and apk
- name: Save test artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: unit-test-api-level-$API_MIN
path: ./Branch-SDK/build/
instrumented-test-api-level-min:
name: instrumented-test-api-level-$API_MIN
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# create an emulator with google apis, runs on java 8
- name: Create Android emulator
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_MIN";google_apis;x86_64"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_MIN";google_apis;x86_64"
# boots and waits for the emulator to be ready
- name: Launch Emulator
timeout-minutes: 30
run: |
echo "Starting emulator and waiting for boot to complete."
nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82'
echo "Emulator has finished booting"
# repo's gradle is configured to run on java 17
- name: Setup java 17 for gradle
uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
# gradlew will automatically connect to booted emulator
- name: Run instrumented tests
run: |
./gradlew :Branch-SDK:connectedDebugAndroidTest -Dorg.gradle.jvmargs="-Xmx8192M -Dkotlin.daemon.jvm.options\\=\"-Xmx8192M\"" --info
# contains the reports and apk
- name: Save test artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: instrumented-test-api-level-$API_MIN
path: ./Branch-SDK/build/
jacoco-test-coverage-api-level-min:
name: jacoco-test-coverage-api-level-$API_MIN
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs: [unit-test-api-level-min, instrumented-test-api-level-min]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# create an emulator with google apis, runs on java 8
- name: Create Android emulator
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_MIN";google_apis;x86_64"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_MIN";google_apis;x86_64"
# boots and waits for the emulator to be ready
- name: Launch Emulator
timeout-minutes: 30
run: |
echo "Starting emulator and waiting for boot to complete."
nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82'
echo "Emulator has finished booting"
# repo's gradle is configured to run on java 17
- name: Setup java 17 for gradle
uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Run Coverage
run: |
./gradlew :Branch-SDK:jacocoTestReport --info
- name: Upload Coverage Test Report
if: success()
uses: codecov/codecov-action@v3
with:
file: ./Branch-SDK/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml
fail_ci_if_error: true
unit-test-api-level-current:
name: unit-test-api-level-$API_CURRENT
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# repo's gradle is configured to run on java 17
- name: Setup java 17 for gradle
uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Run unit tests
run: |
./gradlew :Branch-SDK:testDebugUnitTest
# contains the reports and apk
- name: Save test artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: unit-test-api-level-$API_CURRENT
path: ./Branch-SDK/build/
instrumented-test-api-level-current:
name: instrumented-test-api-level-$API_CURRENT
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# create an emulator with google apis, runs on java 8
- name: Create Android emulator
run: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_CURRENT";google_apis_playstore;x86_64"
echo "no" | $ANDROID_HOME/tools/bin/avdmanager list device
echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_CURRENT";google_apis_playstore;x86_64"
# boots and waits for the emulator to be ready
- name: Launch Emulator
timeout-minutes: 30
run: |
echo "Starting emulator and waiting for boot to complete."
nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82'
echo "Emulator has finished booting"
# repo's gradle is configured to run on java 17
- name: Setup java 17 for gradle
uses: actions/setup-java@v3
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
# gradlew will automatically connect to booted emulator
- name: Run instrumented tests
run: |
./gradlew :Branch-SDK:connectedDebugAndroidTest -Dorg.gradle.jvmargs="-Xmx8192M -Dkotlin.daemon.jvm.options\\=\"-Xmx8192M\"" --info
# contains the reports and apk
- name: Save test artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: instrumented-test-api-level-$API_CURRENT
path: ./Branch-SDK/build/