|
3 | 3 | workflow_dispatch: |
4 | 4 | push: |
5 | 5 | env: |
6 | | - API_MIN: 23 |
7 | 6 | API_CURRENT: 34 |
8 | 7 | JAVA_DISTRIBUTION: 'corretto' |
9 | 8 | JAVA_VERSION: '17' |
10 | 9 | jobs: |
11 | | - unit-test-api-level-min: |
12 | | - name: unit-test-api-level-$API_MIN |
13 | | - runs-on: macos-latest |
14 | | - steps: |
15 | | - - name: Checkout |
16 | | - uses: actions/checkout@v3 |
17 | | - # repo's gradle is configured to run on java 17 |
18 | | - - name: Setup java 17 for gradle |
19 | | - uses: actions/setup-java@v3 |
20 | | - with: |
21 | | - distribution: ${{ env.JAVA_DISTRIBUTION }} |
22 | | - java-version: ${{ env.JAVA_VERSION }} |
23 | | - - name: Run unit tests |
24 | | - run: | |
25 | | - ./gradlew :Branch-SDK:testDebugUnitTest |
26 | | - # contains the reports and apk |
27 | | - - name: Save test artifacts |
28 | | - if: success() || failure() |
29 | | - uses: actions/upload-artifact@v4 |
30 | | - with: |
31 | | - name: unit-test-api-level-$API_MIN |
32 | | - path: ./Branch-SDK/build/ |
33 | | - |
34 | | - instrumented-test-api-level-min: |
35 | | - name: instrumented-test-api-level-$API_MIN |
36 | | - runs-on: macos-latest |
37 | | - steps: |
38 | | - - name: Checkout |
39 | | - uses: actions/checkout@v3 |
40 | | - # create an emulator with google apis, runs on java 8 |
41 | | - - name: Create Android emulator |
42 | | - run: | |
43 | | - echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses |
44 | | - echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_MIN";google_apis;x86_64" |
45 | | - echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_MIN";google_apis;x86_64" |
46 | | - # boots and waits for the emulator to be ready |
47 | | - - name: Launch Emulator |
48 | | - timeout-minutes: 30 |
49 | | - run: | |
50 | | - echo "Starting emulator and waiting for boot to complete." |
51 | | - nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 & |
52 | | - $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82' |
53 | | - echo "Emulator has finished booting" |
54 | | - # repo's gradle is configured to run on java 17 |
55 | | - - name: Setup java 17 for gradle |
56 | | - uses: actions/setup-java@v3 |
57 | | - with: |
58 | | - distribution: ${{ env.JAVA_DISTRIBUTION }} |
59 | | - java-version: ${{ env.JAVA_VERSION }} |
60 | | - # gradlew will automatically connect to booted emulator |
61 | | - - name: Run instrumented tests |
62 | | - run: | |
63 | | - ./gradlew :Branch-SDK:connectedDebugAndroidTest -Dorg.gradle.jvmargs="-Xmx8192M -Dkotlin.daemon.jvm.options\\=\"-Xmx8192M\"" --info |
64 | | - # contains the reports and apk |
65 | | - - name: Save test artifacts |
66 | | - if: success() || failure() |
67 | | - uses: actions/upload-artifact@v4 |
68 | | - with: |
69 | | - name: instrumented-test-api-level-$API_MIN |
70 | | - path: ./Branch-SDK/build/ |
71 | | - |
72 | | - jacoco-test-coverage-api-level-min: |
73 | | - name: jacoco-test-coverage-api-level-$API_MIN |
74 | | - if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} |
75 | | - needs: [unit-test-api-level-min, instrumented-test-api-level-min] |
76 | | - runs-on: macos-latest |
77 | | - steps: |
78 | | - - name: Checkout |
79 | | - uses: actions/checkout@v3 |
80 | | - # create an emulator with google apis, runs on java 8 |
81 | | - - name: Create Android emulator |
82 | | - run: | |
83 | | - echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --licenses |
84 | | - echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install "system-images;android-"$API_MIN";google_apis;x86_64" |
85 | | - echo "no" | $ANDROID_HOME/tools/bin/avdmanager --verbose create avd --force --name test --package "system-images;android-"$API_MIN";google_apis;x86_64" |
86 | | - # boots and waits for the emulator to be ready |
87 | | - - name: Launch Emulator |
88 | | - timeout-minutes: 30 |
89 | | - run: | |
90 | | - echo "Starting emulator and waiting for boot to complete." |
91 | | - nohup $ANDROID_HOME/tools/emulator -avd test -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 & |
92 | | - $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do echo "waiting..."; sleep 1; done; input keyevent 82' |
93 | | - echo "Emulator has finished booting" |
94 | | - # repo's gradle is configured to run on java 17 |
95 | | - - name: Setup java 17 for gradle |
96 | | - uses: actions/setup-java@v3 |
97 | | - with: |
98 | | - distribution: ${{ env.JAVA_DISTRIBUTION }} |
99 | | - java-version: ${{ env.JAVA_VERSION }} |
100 | | - - name: Run Coverage |
101 | | - run: | |
102 | | - ./gradlew :Branch-SDK:jacocoTestReport --info |
103 | | - - name: Upload Coverage Test Report |
104 | | - if: success() |
105 | | - uses: codecov/codecov-action@v5 |
106 | | - with: |
107 | | - file: ./Branch-SDK/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml |
108 | | - fail_ci_if_error: true |
109 | | - |
110 | 10 | unit-test-api-level-current: |
111 | 11 | name: unit-test-api-level-$API_CURRENT |
112 | 12 | runs-on: macos-latest |
|
0 commit comments