This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
132 lines (117 loc) · 4.78 KB
/
android.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
name: Android
on:
push:
branches: [ main, "version-*" ]
pull_request:
branches: [ "main" ]
types: [ labeled, synchronize, opened, reopened ]
workflow_dispatch:
# Enrich gradle.properties for CI/CD
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon
ARCH: x86_64
DEVICE: Nexus 5X
concurrency:
group: ${{ github.ref == 'refs/heads/main' && format('android-build-main-{0}', github.sha) || format('android-build-pr-{0}', github.ref) }}
cancel-in-progress: true
jobs:
tests:
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Android'))
name: Run all tests
runs-on: macos-12
strategy:
matrix:
api-level: [31]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- name: Rust & Cargo cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install Rust & Uniffi
run: make setup
- name: Install Rust targets
run: |
rustup target add i686-linux-android
rustup target add x86_64-linux-android
rustup target add armv7-linux-androideabi
rustup target add aarch64-linux-android
- name: Setup Gradle & Build test cases
uses: gradle/gradle-build-action@v2
env:
ANDROID_NDK_TOOLCHAIN_DIR: ${{ env.ANDROID_NDK_HOME }}/toolchains
with:
build-root-directory: platforms/android
arguments: |
:library:assembleDebugUnitTest :library:assembleDebugAndroidTest ${{ env.CI_GRADLE_ARG_PROPERTIES }}
cache-read-only: false
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: platforms/android
api-level: ${{ matrix.api-level }}
profile: ${{ env.DEVICE }}
arch: ${{ env.ARCH }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
enable-hw-keyboard: true
script: echo "Generated AVD snapshot for caching."
- name: Run all tests with coverage
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: platforms/android
api-level: ${{ matrix.api-level }}
arch: ${{ env.ARCH }}
profile: ${{ env.DEVICE }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
enable-hw-keyboard: true
script: |
./gradlew unitTestsWithCoverage ${{ env.CI_GRADLE_ARG_PROPERTIES }}
./gradlew generateUnitTestCoverageReport ${{ env.CI_GRADLE_ARG_PROPERTIES }}
./gradlew instrumentationTestsWithCoverage ${{ env.CI_GRADLE_ARG_PROPERTIES }}
./gradlew generateInstrumentationTestCoverageReport ${{ env.CI_GRADLE_ARG_PROPERTIES }}
- name : Upload test results
if : ${{ always() }}
uses : actions/upload-artifact@v3
with :
name : android-test-results-${{ matrix.api-level }}
path : |
./**/build/reports/tests/**
./**/build/reports/androidTests/connected/**
- name: Upload unit test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: build/reports/jacoco/generateUnitTestCoverageReport/generateUnitTestCoverageReport.xml
fail_ci_if_error: false
flags: unittests-android, unittests
# https://github.com/codecov/codecov-action/issues/557#issuecomment-1216749652
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload instrumentation test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: build/reports/jacoco/generateInstrumentationTestCoverageReport/generateInstrumentationTestCoverageReport.xml
fail_ci_if_error: false
flags: uitests-android, uitests
# https://github.com/codecov/codecov-action/issues/557#issuecomment-1216749652
token: ${{ secrets.CODECOV_TOKEN }}