-
Notifications
You must be signed in to change notification settings - Fork 1
232 lines (197 loc) · 6.3 KB
/
ci.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: ci
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
jobs:
# Builds and checks .apk and .aar
assemble:
name: Assemble and check
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Generate cache key
run: ./checksum.sh checksum.txt
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Assemble and checks
run: ./gradlew spotlessCheck assemble apiCheck lintDebug --build-cache --no-daemon --stacktrace --scan
# Runs unit tests
unit-tests:
name: Unit tests
needs: assemble
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Generate cache key
run: ./checksum.sh checksum.txt
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Unit Tests with coverage
run: ./gradlew koverXmlReport --build-cache --no-daemon --stacktrace
- name: Zip test reports
run: zip -r reports.zip ./build/reports/kover/report.xml
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-tests-reports
path: reports.zip
- name: Upload tests coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-tests-coverage
path: library/build/reports/kover
# Runs instrumentation tests
instrumentation-tests:
name: Instrumentation tests
needs: assemble
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
api-level:
# - 21 (comment for now: constant fails on emulator, locally - OK)
- 25
- 28
- 31
- 33
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Generate cache key
run: ./checksum.sh checksum.txt
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Instrumentation Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
script: ./gradlew connectedCheck mergeAndroidReports --build-cache --no-daemon --stacktrace
- name: Upload tests reports
if: always()
uses: actions/upload-artifact@v4
with:
name: 'android-tests-${{ matrix.api-level }}-reports'
path: build/androidTest-results
- name: Upload tests coverage
if: ${{ matrix.api-level == 25 }}
uses: actions/upload-artifact@v4
with:
name: 'android-tests-${{ matrix.api-level }}-coverage'
path: library/build/reports/coverage
# Runs screenshot tests
screenshot-tests:
name: Screenshot tests
needs: assemble
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Generate cache key
run: ./checksum.sh checksum.txt
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('checksum.txt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache AVD snapshot
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-30-aosp-atd
- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
target: aosp_atd
api-level: 30
arch: x86
channel: canary
profile: pixel
avd-name: Pixel_3a_API_30_AOSP
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching"
- name: Screenshot Tests
uses: reactivecircus/android-emulator-runner@v2
with:
target: aosp_atd
api-level: 30
arch: x86
channel: canary
profile: pixel
avd-name: Pixel_3a_API_30_AOSP
script: ./gradlew :library:executeScreenshotTests --build-cache --no-daemon --stacktrace
- name: Upload tests reports
if: always()
uses: actions/upload-artifact@v4
with:
name: 'screenshot-tests-reports'
path: library/build/reports/shot
# Upload coverage
upload-coverage:
name: Upload coverage
needs: [unit-tests, instrumentation-tests]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Download unit tests coverage
uses: actions/download-artifact@v4
with:
name: unit-tests-coverage
- name: Download android tests coverage
uses: actions/download-artifact@v4
with:
name: android-tests-25-coverage
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
directory: .