-
Notifications
You must be signed in to change notification settings - Fork 73
389 lines (332 loc) · 12.6 KB
/
ci_checks.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
name: CI
on:
push:
branches:
- release/*
pull_request:
workflow_dispatch:
inputs:
simple_server_branch:
required: false
type: string
default: master
workflow_call:
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
jobs:
qa_lint:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: QA Lint
run: ./gradlew --build-cache --no-daemon lintQaDebug
qa_unit_tests:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: QA Unit Tests
run: ./gradlew --build-cache --no-daemon testQaDebugUnitTest
generate_server_app_name:
runs-on: [ ubuntu-latest ]
outputs:
heroku_app_name: ${{ steps.generate-server-app-name.outputs.heroku_app_name }}
steps:
- name: Checkout Android source
uses: actions/checkout@v4
- name: Generate server app name
id: generate-server-app-name
run: .github/scripts/generate_heroku_app_name.sh ${{ github.ref }}
create_server_on_heroku:
needs: generate_server_app_name
runs-on: [ ubuntu-latest ]
outputs:
heroku_app_name: ${{ steps.create-server-on-heroku.outputs.heroku_app_name }}
heroku_app_url: ${{ steps.create-server-on-heroku.outputs.heroku_app_url }}
heroku_app_exists: ${{ steps.create-server-on-heroku.outputs.heroku_app_exists }}
env:
HEROKU_API_KEY: ${{ secrets.SERVICES_HEROKU_API_KEY }}
steps:
- name: Checkout Android source
uses: actions/checkout@v4
with:
path: android-app
- name: Checkout Server source
uses: actions/checkout@v4
with:
repository: simpledotorg/simple-server
fetch-depth: 0 # Full clone needed for Heroku deploys (https://devcenter.heroku.com/changelog-items/775)
path: server-app
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.simple_server_branch || 'master' }}
- name: Install Heroku CLI
if: steps.node-dependency-cache.outputs.cache-hit != 'true'
run: npm install heroku
- name: Link Heroku CLI globally
run: npm link heroku
- name: Create server on Heroku
id: create-server-on-heroku
run: |
android-app/.github/scripts/create_heroku_app.sh \
${{ needs.generate_server_app_name.outputs.heroku_app_name }} \
server-app
deploy_server_on_heroku:
needs: [create_server_on_heroku]
runs-on: [ ubuntu-latest ]
timeout-minutes: 60
outputs:
heroku_app_name: ${{ steps.start-simple-server.outputs.heroku_app_name }}
env:
HEROKU_API_KEY: ${{ secrets.SERVICES_HEROKU_API_KEY }}
steps:
- name: Checkout Android source
uses: actions/checkout@v4
with:
path: android-app
- name: Checkout server app source
uses: actions/checkout@v4
with:
repository: simpledotorg/simple-server
fetch-depth: 0 # Full clone needed for Heroku deploys (https://devcenter.heroku.com/changelog-items/775)
path: server-app
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.simple_server_branch || 'master' }}
- name: Create node dependency hash
id: create_node_modules_hash
run: android-app/.github/scripts/compute_node_dependency_hash.sh
- name: Cache node modules
id: node-dependency-cache
uses: actions/cache@v4
with:
path: |
node_modules
package-lock.json
key: ${{ runner.os }}-npm-${{ steps.create_node_modules_hash.outputs.node_dep_hash }}
- name: Install Heroku CLI
if: steps.node-dependency-cache.outputs.cache-hit != 'true'
run: npm install heroku
- name: Link Heroku CLI globally
run: npm link heroku
- name: Install Heroku Buildpacks registry
run: heroku plugins:install buildpack-registry
- name: Install heroku buildpacks plugin
run: heroku plugins:install buildpacks
- name: Deploy the server on Heroku
id: start-simple-server
run: |
android-app/.github/scripts/setup_heroku_instance.sh \
${{ needs.create_server_on_heroku.outputs.heroku_app_name }} \
${{ env.HEROKU_API_KEY }} \
${{ github.event_name == 'workflow_dispatch' && github.event.inputs.simple_server_branch || 'master' }} \
server-app \
android-app \
${{ needs.create_server_on_heroku.outputs.heroku_app_exists }} \
${{ secrets.HEROKU_SECRET_PROPERTIES }}
build_qa_android_tests_apk:
needs: create_server_on_heroku
runs-on: [ ubuntu-latest ]
timeout-minutes: 60
steps:
- name: Checkout Android source
uses: actions/checkout@v4
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Build QA Test Artifacts
id: build-instrumented-tests
run: |
./gradlew --build-cache --no-daemon -PmanifestEndpoint=${{ needs.create_server_on_heroku.outputs.heroku_app_url }}api/ assembleQaDebug assembleQaDebugAndroidTest
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: test-artifacts
path: app/build/outputs/apk
# reactivecircus/android-emulator-runner@v2 requires MacOS to run on
# https://github.com/ReactiveCircus/android-emulator-runner
qa_android_tests:
needs: [ deploy_server_on_heroku, build_qa_android_tests_apk ]
runs-on: [ ubuntu-latest ]
timeout-minutes: 60
env:
AVD_API_LEVEL: 34
AVD_ARCH: x86_64
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: Checkout Android source
uses: actions/checkout@v4
- name: Cache AVD
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: ${{ runner.os }}-avd-${{ env.AVD_API_LEVEL }}-${{ env.AVD_ARCH }}
- 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: ${{ env.AVD_API_LEVEL }}
arch: ${{ env.AVD_ARCH }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
disk-size: 8G
script: echo "Generated AVD snapshot for caching."
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Create build directory
run: mkdir app/build
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: test-artifacts
path: app/build/outputs/apk
- name: QA Android Tests
id: run-instrumented-tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.AVD_API_LEVEL }}
arch: ${{ env.AVD_ARCH }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
disk-size: 8G
script: |
adb root
mkdir -p app/build/outputs/test-artifacts
adb install app/build/outputs/apk/qa/debug/app-qa-debug.apk
adb install app/build/outputs/apk/androidTest/qa/debug/app-qa-debug-androidTest.apk
adb shell am instrument -w -e filter org.simple.clinic.benchmark.SelectBenchmarkTests -e benchmark_app_performance false org.simple.clinic.qa.debug.test/org.simple.clinic.AndroidTestJUnitRunner >app/build/outputs/test-artifacts/logs.txt 2>app/build/outputs/test-artifacts/logs.txt
cat app/build/outputs/test-artifacts/logs.txt
adb pull /storage/emulated/0/Android/data/org.simple.clinic.qa.debug/ app/build/outputs/test-artifacts/ || true
adb uninstall org.simple.clinic.qa.debug
adb uninstall org.simple.clinic.qa.debug.test
! grep -q "FAILURES\!\!\!" app/build/outputs/test-artifacts/logs.txt
- name: Upload failed test artifacts
if: always() && steps.run-instrumented-tests.outcome != 'success'
uses: actions/upload-artifact@v4
with:
name: failed-test-artifacts
path: app/build/outputs/test-artifacts
- name: Teardown Heroku instance
if: always() && (steps.start-simple-server.outcome != 'success' || contains(github.ref, '/release/'))
run: |
heroku apps:destroy \
--app=${{ needs.deploy_server_on_heroku.outputs.heroku_app_name }} \
--confirm=${{ needs.deploy_server_on_heroku.outputs.heroku_app_name }}
mobius_migration_tests:
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v4
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Mobius Migration Tests
run: ./gradlew :mobius-migration:test
verify_release_bundles:
runs-on: [ ubuntu-latest ]
env:
TERM: dumb
ORG_GRADLE_PROJECT_KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
ORG_GRADLE_PROJECT_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
ORG_GRADLE_PROJECT_KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
strategy:
matrix:
buildType: [ 'Production' ]
steps:
- uses: actions/checkout@v4
- name: set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
cache: 'gradle'
- name: Decrypt secrets
run: gpg --batch --yes --quiet --decrypt --passphrase=${{ secrets.KEYSTORE_PASSPHRASE }} --output release/simple.store release/simple.gpg
- name: Build ${{ matrix.buildType }} Release bundle
run: |
./gradlew \
-PrunProguard=true \
-PdefaultProguardFile=proguard-android.txt \
-PsentryUploadProguard=false \
bundle${{ matrix.buildType }}Release
- name: Clean secrets
run: |
rm -f release/simple.store
verify_room_schemas:
runs-on: [ ubuntu-latest ]
steps:
- name: Checkout master
uses: actions/checkout@v4
with:
ref: master
path: master
- name: Checkout current
uses: actions/checkout@v4
with:
path: current
- name: Verify existing Room schemas are not modified
run: current/.github/scripts/compare_directory_contents.sh master/app/schemas/org.simple.clinic.AppDatabase current/app/schemas/org.simple.clinic.AppDatabase
verify_pr_description:
runs-on: [ ubuntu-latest ]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Verify PR description
run: kotlinc -script ".github/scripts/PrCommentCheck.main.kts" "${{ github.event.pull_request.body }}"
verify_changelog_updated:
runs-on: [ ubuntu-latest ]
if: github.event_name == 'pull_request'
steps:
- name: Checkout master
uses: actions/checkout@v4
with:
ref: master
path: master
- name: Checkout current
uses: actions/checkout@v4
with:
path: current
- name: Verify CHANGELOG was updated
run: current/.github/scripts/verify_file_was_changed.sh master/CHANGELOG.md current/CHANGELOG.md
fix_strings_ellipsise:
runs-on: [ ubuntu-latest ]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
fetch-depth: 0
token: ${{ secrets.SERVICES_ACCESS_TOKEN }}
- name: Fix ellipsise in strings
run: .github/scripts/strings_reader.py
- name: Commit and push
env:
USER_NAME: ${{ secrets.USER_NAME }}
USER_EMAIL: ${{ secrets.USER_EMAIL }}
run: .github/scripts/commit_and_push_string_fixes.sh