-
-
Notifications
You must be signed in to change notification settings - Fork 927
238 lines (209 loc) · 8.55 KB
/
pr.yml
File metadata and controls
238 lines (209 loc) · 8.55 KB
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
233
234
235
236
237
238
name: Pull Request
on:
pull_request:
branches: [master]
# This workflow should cancel previous builds since it means that a new commit has been made to the PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ktlint:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build-env
with:
mock-google-services: "true"
# Since `build-logic` is added with `includeBuild` we have to call ktlint explicitly on `:convention`.
- name: Validate ktlint
run: ./gradlew ktlintCheck :build-logic:convention:ktlintCheck
- name: Upload lint reports (SARIF)
if: ${{ !cancelled() && hashFiles('**/*.sarif') != '' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "./"
category: "KTlint"
lint:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build-env
with:
mock-google-services: "true"
- name: Validate Lint
run: ./gradlew lint
- name: Upload lint reports (HTML)
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: lint-reports
path: "**/build/reports/lint-results-*.html"
- name: Upload lint reports (SARIF)
if: ${{ !cancelled() && hashFiles('**/*.sarif') != '' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "./"
category: "Android Lint"
pr_build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for modified DB schemas on branch
run: |
if git diff --name-only --diff-filter=DMR origin/master... | grep "^common/schemas"; then
echo -e "\n❌ Existing database schema modified, please increase the database version instead"
exit 1
else
echo -e "\n✔️ No changed database schemas on branch"
fi
- uses: ./.github/actions/setup-build-env
with:
mock-google-services: "true"
- name: Build Debug APK
run: |
./gradlew :common:assemble :app:assembleDebug :wear:assembleDebug :automotive:assembleDebug
- name: Check for missing/modified DB schemas after build
run: |
if [[ $(git status common/schemas --porcelain) ]]; then
echo $(git status common/schemas --porcelain)
echo -e "\n❌ Found uncommitted changes in database schema directory, please make sure to include all changes in your commit(s)"
exit 1;
else
echo -e "\n✔️ No changes in database schema directory after build"
fi
- name: Archive Debug Build
uses: actions/upload-artifact@v4
with:
path: ./**/*.apk
instrumentation_test:
name: "Instrumentation Tests"
runs-on: ubuntu-latest
strategy:
# We want the result of each device to be reported, so we can't fail-fast
fail-fast: false
matrix:
configuration:
- api-level: 21
arch: x86_64
profile: "Nexus 5"
target: "google_apis"
gradle_target: ":app:connectedFullDebugAndroidTest :app:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest"
- api-level: 30
arch: x86
profile: "tv_4k"
target: "android-tv"
gradle_target: ":app:connectedFullDebugAndroidTest :app:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest"
- api-level: 35
arch: x86_64
profile: "pixel_7"
target: "google_apis"
gradle_target: ":app:connectedFullDebugAndroidTest :app:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest"
# Disabled due to Github Actions limitations https://github.com/ReactiveCircus/android-emulator-runner/pull/428
#- api-level: 33
# arch: x86_64
# profile: "automotive_1024p_landscape"
# target: "android-automotive"
# gradle_target: ":automotive:connectedFullDebugAndroidTest :automotive:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest"
#- api-level: "34-ext9" # -ext9 is not usable because of https://github.com/ReactiveCircus/android-emulator-runner/issues/429
# arch: x86_64
# profile: "automotive_ultrawide"
# target: "android-automotive"
# gradle_target: ":automotive:connectedFullDebugAndroidTest :automotive:connectedMinimalDebugAndroidTest :common:connectedDebugAndroidTest"
- api-level: 26
arch: x86
profile: "wearos_square"
target: "android-wear"
gradle_target: ":wear:connectedDebugAndroidTest :common:connectedDebugAndroidTest"
- api-level: 34
arch: x86_64
profile: "wearos_small_round"
target: "android-wear"
gradle_target: ":wear:connectedDebugAndroidTest :common:connectedDebugAndroidTest"
steps:
- name: Delete unnecessary tools 🔧
uses: jlumbroso/free-disk-space@v1.3.1
with:
android: false # Don't remove Android tools
tool-cache: true # Remove image tool cache - rm -rf "$AGENT_TOOLSDIRECTORY"
docker-images: false # Takes 16s, enable if needed in the future
large-packages: false # includes google-cloud-sdk and it's slow
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build-env
with:
mock-google-services: "true"
- name: Enable KVM group perms
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
ls /dev/kvm
- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.configuration.target }}-${{ matrix.configuration.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:
api-level: ${{ matrix.configuration.api-level }}
arch: ${{ matrix.configuration.arch }}
force-avd-creation: false
disable-animations: true
disk-size: 1G # We need to ensure that there is enough space for the emulator to run. If not we get 'Failed to commit install' errors.
heap-size: 1G
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
profile: ${{ matrix.configuration.profile }}
target: ${{ matrix.configuration.target }}
script: |
echo "Generated AVD snapshot for caching."
- name: Build projects and run instrumentation tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.configuration.api-level }}
arch: ${{ matrix.configuration.arch }}
force-avd-creation: false
disable-animations: true
disk-size: 1G
heap-size: 1G
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
profile: ${{ matrix.configuration.profile }}
target: ${{ matrix.configuration.target }}
script: ./gradlew ${{ matrix.configuration.gradle_target }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: Instrumentation test results (API${{ matrix.configuration.api-level }}) ${{ matrix.configuration.target }}
path: |
**/build/reports/*
**/build/outputs/*/connected/*
publish_test_results:
name: "Publish Tests Results"
needs: instrumentation_test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Publish Test Results EnricoMi
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
comment_mode: "failures"
files: |
**/androidTest-results/**/TEST-*.xml