-
-
Notifications
You must be signed in to change notification settings - Fork 480
243 lines (220 loc) · 8.93 KB
/
trunk-build.yaml
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
239
240
241
242
243
---
name: Push to default, build, test, lint, and publish to internal track
"on":
push:
branches:
- master
paths:
- ".github/workflows/build-and-test.yaml"
- "project/app/src/**"
- "project/app/*.pro"
- "project/buildSrc/src/**"
- "project/*.gradle.kts"
- "project/app/*.gradle.kts"
- "project/gradle.properties"
- "project/gradle/wrapper/gradle-wrapper.properties"
- "project/gradle/libs.versions.toml"
env:
GRADLE_OPTS: "-Dorg.gradle.daemon=true -Dorg.gradle.configuration-cache=true -Dorg.gradle.parallel=true -Dorg.gradle.caching=true -Dorg.gradle.jvmargs='-Xmx3096M -Dkotlin.daemon.jvm.options=-Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC'"
jobs:
ktfmt:
name: ktfmt
runs-on: ubuntu-latest
steps:
- uses: ./.github/actions/ktfmt
build-test-lint:
name: Build, test & lint
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
steps:
- uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4
with:
distribution: "temurin"
java-version: "17"
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Gradle setup
uses: gradle/actions/setup-gradle@v4
with:
dependency-graph: generate-and-submit
cache-read-only: false
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
- name: Build
run: |
./project/gradlew -p project assembleDebug lint app:createGmsDebugUnitTestCoverageReport --scan
- name: JUnit Report Action
uses: mikepenz/action-junit-report@v4
with:
report_paths: "**/TEST-*.xml"
detailed_summary: true
include_passed: false # Lots of test, much output.
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./project/app/build/reports/coverage/test/gms/debug/report.xml
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload lint report
uses: actions/upload-artifact@v4
with:
name: lint-report
path: project/app/build/reports/lint-results-gmsDebug.html
espresso-test:
name: "Espresso test"
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
needs: build-test-lint
strategy:
fail-fast: false
matrix:
android-api: [31]
flavour: [Gms, Oss]
shard: [1, 2, 3, 4, 5, 6]
steps:
- 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
- name: Remove unused things
run: |
sudo rm -rf /opt/ghc # Haskell
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /usr/share/dotnet
sudo docker image prune --all --force
sudo df -h
# Github charges us for LFS bandwidth, so let's use the cache
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
lfs: false
- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
- name: Restore LFS cache
uses: actions/cache@v4
id: lfs-cache
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
- name: Git LFS Pull
run: git lfs pull
- uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: "17"
- name: Gradle setup
uses: gradle/actions/setup-gradle@v4
with:
dependency-graph: generate
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
- name: AVD cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: owntracks-test-${{ matrix.android-api }}-${{ matrix.flavour }}
- name: Create AVD and generate snapshot for caching
timeout-minutes: 10
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.android-api }}
force-avd-creation: false
emulator-options: -no-window -gpu auto -noaudio -no-boot-anim -camera-back none -camera-front none -memory 6000
profile: pixel_3a
target: ${{ matrix.flavour == 'Gms' && 'google_apis' || 'default' }}
ram-size: 6000M
avd-name: owntracks-test-${{ matrix.android-api }}-${{ matrix.flavour }}
disable-animations: true
arch: x86_64
cores: 2
sdcard-path-or-size: 1000M
script: |
echo "Created AVD snapshot"
- name: Espresso Test
uses: reactivecircus/android-emulator-runner@v2
timeout-minutes: 30
env:
FLAVOUR: ${{ matrix.flavour }}
SHARD_COUNT: 6
SHARD_INDEX: ${{ matrix.shard }}
with:
api-level: ${{ matrix.android-api }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu auto -noaudio -no-boot-anim -camera-back none -camera-front none -memory 6000
profile: pixel_3a
target: ${{ matrix.flavour == 'Gms' && 'google_apis' || 'default' }}
ram-size: 6000M
disable-animations: true
avd-name: owntracks-test-${{ matrix.android-api }}-${{ matrix.flavour }}
arch: x86_64
cores: 2
sdcard-path-or-size: 1000M
script: |
adb shell settings put global bluetooth_on 0
adb shell settings put secure long_press_timeout 1000
adb shell rm -rf /sdcard/googletest || echo "Couldn't delete googletest folder"
adb uninstall org.owntracks.android.debug || echo "org.owntracks.android not installed"
adb uninstall org.owntracks.android.debug.test || echo "org.owntracks.android.test not installed"
./project/gradlew -p project :app:create${FLAVOUR}DebugAndroidTestCoverageReport -Pandroid.testInstrumentationRunnerArguments.numShards=${SHARD_COUNT} -Pandroid.testInstrumentationRunnerArguments.shardIndex=${SHARD_INDEX} --max-workers=1 --scan
- name: Upload connected test result artifact
uses: actions/upload-artifact@v4
with:
name: espresso-test-reports-${{ matrix.android-api }}-${{ matrix.flavour }}-${{ matrix.shard }}
path: ./project/app/build/reports/androidTests/connected/
- name: Espresso JUnit Report
uses: mikepenz/action-junit-report@v4
with:
report_paths: "**/TEST-*.xml"
detailed_summary: true
include_passed: false
- name: Upload connected test coverage artifact
uses: ./.github/actions/upload-artifact
with:
name: espresso-test-coverage-${{ matrix.android-api }}-${{ matrix.flavour }}-${{ matrix.shard }}
path: ./project/app/build/reports/coverage/androidTest/
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
files: ./project/app/build/reports/coverage/androidTest/${{ matrix.flavour == 'Gms' && 'gms' || 'oss' }}/debug/connected/report.xml
flags: uitests
token: ${{ secrets.CODECOV_TOKEN }}
publish-to-play-store:
name: "Publish to Play Store"
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
needs: espresso-test
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Create keystore
run: |
echo -n "${KEYSTORE_BASE64}" | base64 -d > project/owntracks.release.keystore.jks
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
with:
build-root-directory: project
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
- name: Process version codes from play store
run: |
./project/gradlew -p project clean processGmsVersionCodes
cat ./project/app/build/intermediates/gpp/gmsRelease/available-version-codes.txt
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
- name: Publish Release
run: |
./project/gradlew -p project publishGmsReleaseBundle --stacktrace --scan
env:
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}