forked from cgeo/cgeo
-
Notifications
You must be signed in to change notification settings - Fork 0
543 lines (488 loc) · 22.4 KB
/
Copy pathtests.yml
File metadata and controls
543 lines (488 loc) · 22.4 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
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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
name: Unit tests
concurrency:
group: ci-tests-${{ github.event.pull_request.head.label || github.ref }}
cancel-in-progress: ${{ !((github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release') && github.event_name == 'push') }}
on:
push:
pull_request_target:
types: [opened, labeled, synchronize, reopened]
workflow_dispatch:
inputs:
JDK_VERSION:
description: The JDK version to use
type: number
default: 17
env:
JDK_VERSION: ${{ inputs.JDK_VERSION || '17' }}
permissions:
actions: write
contents: write
checks: write
pull-requests: write
jobs:
check-websites:
if: >
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
# On push, use the push commit sha. On PR from cgeo/cgeo use the PR commit sha; on forks fall back to master
ref: ${{ !github.event.pull_request && github.sha || github.event.pull_request && github.event.pull_request.head.repo.full_name == 'cgeo/cgeo' && github.event.pull_request.head.sha || 'master' }}
- name: Check websites status
uses: ./.github/actions/check-websites
check-secrets:
if: >
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
github.event.action == 'opened' || github.event.action == 'reopened' ||
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
runs-on: ubuntu-latest
steps:
- name: Debug concurrency-group
run: |
# concurrency:
# group: ci-tests-${{ github.event.pull_request.head.label || github.ref }}
# cancel-in-progress: ${{ !((github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release') && github.event_name == 'push') }}
- name: Debug
uses: raven-actions/debug@v1
- name: Check secrets
run: |
if [ -z "${{ secrets.KEY_STORE }}" ]; then
echo "::error::No secret defined or no access to secrets"
exit 1
fi
echo "::notice::Secrets seems available"
- name: Report Gradle cache key length
run: |
KEY="${{ secrets.GRADLE_ENCRYPTION_KEY }}"
if [ -z "$KEY" ]; then
echo "::warning::GRADLE_ENCRYPTION_KEY is empty"
else
KEY_LEN=${#KEY}
echo "::notice::GRADLE_ENCRYPTION_KEY length: ${KEY_LEN}"
if [ "$KEY_LEN" -ne 16 ] && [ "$KEY_LEN" -ne 24 ] && [ "$KEY_LEN" -ne 32 ]; then
echo "::error::GRADLE_ENCRYPTION_KEY length must be 16, 24, or 32 bytes"
exit 1
fi
fi
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
- name: Check User Permission
if: >
steps.checkAccess.outputs.require-result == 'false' &&
!contains(github.event.pull_request.labels.*.name, 'ok-to-test') &&
github.actor != 'dependabot[bot]' &&
github.actor != 'github-actions[bot]' &&
github.actor != 'github-merge-queue[bot]'
run: |
echo "::error::${{ github.triggering_actor }} does not have permissions on this repo.\nCurrent permission level is ${{ steps.checkAccess.outputs.user-permission }}\nJob originally triggered by ${{ github.actor }}"
exit 1
# Using if to restrict to pull_request_target events, as the workflow will exit with error from previous step if the user does not have permissions,
# so we can be sure that only users with permissions will reach this step and get the label added
- name: Add ok-to-test label
if: github.event_name == 'pull_request_target'
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: gh pr edit ${{ github.event.pull_request.number }} --add-label ok-to-test
check-code-changed:
if: >
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
runs-on: ubuntu-latest
outputs:
code-changed: ${{ steps.detect.outputs.has-code-changes }}
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Detect code changes
id: changes
uses: tj-actions/changed-files@v47
with:
files: |
main/**
gradle/**
build.gradle
settings.gradle
mapswithme-api/**
organicmaps-api/**
files_ignore: |
.github/**
- name: Set code-changed output
id: detect
run: echo "has-code-changes=${{ steps.changes.outputs.any_changed }}" >> $GITHUB_OUTPUT
checkstyle:
if: >
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
runs-on: ubuntu-latest
needs: check-secrets
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup cgeo preferences and keystore
uses: ./.github/actions/cgeo-preferences
with:
KEY_STORE: ${{ secrets.KEY_STORE }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS_PASSWORD: ${{ secrets.KEY_ALIAS_PASSWORD }}
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
MAPS_API_KEY_MARKET: ${{ secrets.MAPS_API_KEY_MARKET }}
MAPS_API2_KEY: ${{ secrets.MAPS_API2_KEY }}
OCDE_OKAPI_CONSUMER_KEY: ${{ secrets.OCDE_OKAPI_CONSUMER_KEY }}
OCDE_OKAPI_CONSUMER_SECRET: ${{ secrets.OCDE_OKAPI_CONSUMER_SECRET }}
OCPL_OKAPI_CONSUMER_KEY: ${{ secrets.OCPL_OKAPI_CONSUMER_KEY }}
OCPL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCPL_OKAPI_CONSUMER_SECRET }}
OCUS_OKAPI_CONSUMER_KEY: ${{ secrets.OCUS_OKAPI_CONSUMER_KEY }}
OCUS_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUS_OKAPI_CONSUMER_SECRET }}
OCNL_OKAPI_CONSUMER_KEY: ${{ secrets.OCNL_OKAPI_CONSUMER_KEY }}
OCNL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCNL_OKAPI_CONSUMER_SECRET }}
OCRO_OKAPI_CONSUMER_KEY: ${{ secrets.OCRO_OKAPI_CONSUMER_KEY }}
OCRO_OKAPI_CONSUMER_SECRET: ${{ secrets.OCRO_OKAPI_CONSUMER_SECRET }}
OCUK_OKAPI_CONSUMER_KEY: ${{ secrets.OCUK_OKAPI_CONSUMER_KEY }}
OCUK_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUK_OKAPI_CONSUMER_SECRET }}
SU_CONSUMER_KEY: ${{ secrets.SU_CONSUMER_KEY }}
SU_CONSUMER_SECRET: ${{ secrets.SU_CONSUMER_SECRET }}
THUNDERFOREST_API_KEY: ${{ secrets.THUNDERFOREST_API_KEY }}
ALC_CONSUMER_KEY: ${{ secrets.ALC_CONSUMER_KEY }}
PREF_COOKIESTORE: ${{ secrets.PREF_COOKIESTORE }}
PREF_USERNAME: ${{ secrets.PREF_USERNAME }}
PREF_PASSWORD: ${{ secrets.PREF_PASSWORD }}
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v5
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: Report Gradle cache key length
run: |
KEY="${{ secrets.GRADLE_ENCRYPTION_KEY }}"
if [ -z "$KEY" ]; then
echo "::warning::GRADLE_ENCRYPTION_KEY is empty"
else
KEY_LEN=${#KEY}
echo "::notice::GRADLE_ENCRYPTION_KEY length: ${KEY_LEN}"
if [ "$KEY_LEN" -ne 16 ] && [ "$KEY_LEN" -ne 24 ] && [ "$KEY_LEN" -ne 32 ]; then
echo "::error::GRADLE_ENCRYPTION_KEY length must be 16, 24, or 32 bytes"
exit 1
fi
fi
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
add-job-summary-as-pr-comment: never # Valid values are 'never' (default), 'always', and 'on-failure'
- name: Run checkstyle
run: ./gradlew --no-daemon --scan checkstyle
- uses: lcollins/checkstyle-github-action@v3.2.0
with:
path: 'main/build/reports/checkstyle/checkstyle.xml'
lint:
if: >
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
runs-on: ubuntu-latest
needs: check-secrets
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup cgeo preferences and keystore
uses: ./.github/actions/cgeo-preferences
with:
KEY_STORE: ${{ secrets.KEY_STORE }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS_PASSWORD: ${{ secrets.KEY_ALIAS_PASSWORD }}
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
MAPS_API_KEY_MARKET: ${{ secrets.MAPS_API_KEY_MARKET }}
MAPS_API2_KEY: ${{ secrets.MAPS_API2_KEY }}
OCDE_OKAPI_CONSUMER_KEY: ${{ secrets.OCDE_OKAPI_CONSUMER_KEY }}
OCDE_OKAPI_CONSUMER_SECRET: ${{ secrets.OCDE_OKAPI_CONSUMER_SECRET }}
OCPL_OKAPI_CONSUMER_KEY: ${{ secrets.OCPL_OKAPI_CONSUMER_KEY }}
OCPL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCPL_OKAPI_CONSUMER_SECRET }}
OCUS_OKAPI_CONSUMER_KEY: ${{ secrets.OCUS_OKAPI_CONSUMER_KEY }}
OCUS_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUS_OKAPI_CONSUMER_SECRET }}
OCNL_OKAPI_CONSUMER_KEY: ${{ secrets.OCNL_OKAPI_CONSUMER_KEY }}
OCNL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCNL_OKAPI_CONSUMER_SECRET }}
OCRO_OKAPI_CONSUMER_KEY: ${{ secrets.OCRO_OKAPI_CONSUMER_KEY }}
OCRO_OKAPI_CONSUMER_SECRET: ${{ secrets.OCRO_OKAPI_CONSUMER_SECRET }}
OCUK_OKAPI_CONSUMER_KEY: ${{ secrets.OCUK_OKAPI_CONSUMER_KEY }}
OCUK_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUK_OKAPI_CONSUMER_SECRET }}
SU_CONSUMER_KEY: ${{ secrets.SU_CONSUMER_KEY }}
SU_CONSUMER_SECRET: ${{ secrets.SU_CONSUMER_SECRET }}
THUNDERFOREST_API_KEY: ${{ secrets.THUNDERFOREST_API_KEY }}
ALC_CONSUMER_KEY: ${{ secrets.ALC_CONSUMER_KEY }}
PREF_COOKIESTORE: ${{ secrets.PREF_COOKIESTORE }}
PREF_USERNAME: ${{ secrets.PREF_USERNAME }}
PREF_PASSWORD: ${{ secrets.PREF_PASSWORD }}
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v5
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: Report Gradle cache key length
run: |
KEY="${{ secrets.GRADLE_ENCRYPTION_KEY }}"
if [ -z "$KEY" ]; then
echo "::warning::GRADLE_ENCRYPTION_KEY is empty"
else
KEY_LEN=${#KEY}
echo "::notice::GRADLE_ENCRYPTION_KEY length: ${KEY_LEN}"
if [ "$KEY_LEN" -ne 16 ] && [ "$KEY_LEN" -ne 24 ] && [ "$KEY_LEN" -ne 32 ]; then
echo "::error::GRADLE_ENCRYPTION_KEY length must be 16, 24, or 32 bytes"
exit 1
fi
fi
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
add-job-summary-as-pr-comment: never # Valid values are 'never' (default), 'always', and 'on-failure'
- name: Run lintBasicDebug
run: ./gradlew --no-daemon --scan lintBasicDebug
- name: Check and report lint results
uses: hidakatsuya/action-report-android-lint@v1
with:
result-path: 'main/build/reports/lint-results-basicDebug.xml'
fail-on-warning: false
integration-tests:
if: >
needs.check-code-changed.outputs.code-changed == 'true' &&
(
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
)
# > It is now recommended to use the Ubuntu (ubuntu-latest) runners which
# > are 2-3 times faster than the macOS ones which are also a lot more expensive.
# https://github.com/ReactiveCircus/android-emulator-runner#running-hardware-accelerated-emulators-on-linux-runners
runs-on: ubuntu-latest
needs: [check-secrets, check-websites, check-code-changed]
strategy:
fail-fast: false
matrix:
api-level: [26, 30, 34]
steps:
- name: Checkout the latest code
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
- 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: Setup cgeo preferences and keystore
uses: ./.github/actions/cgeo-preferences
with:
KEY_STORE: ${{ secrets.KEY_STORE }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS_PASSWORD: ${{ secrets.KEY_ALIAS_PASSWORD }}
MAPS_API_KEY: ${{ secrets.MAPS_API_KEY }}
MAPS_API_KEY_MARKET: ${{ secrets.MAPS_API_KEY_MARKET }}
MAPS_API2_KEY: ${{ secrets.MAPS_API2_KEY }}
OCDE_OKAPI_CONSUMER_KEY: ${{ secrets.OCDE_OKAPI_CONSUMER_KEY }}
OCDE_OKAPI_CONSUMER_SECRET: ${{ secrets.OCDE_OKAPI_CONSUMER_SECRET }}
OCPL_OKAPI_CONSUMER_KEY: ${{ secrets.OCPL_OKAPI_CONSUMER_KEY }}
OCPL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCPL_OKAPI_CONSUMER_SECRET }}
OCUS_OKAPI_CONSUMER_KEY: ${{ secrets.OCUS_OKAPI_CONSUMER_KEY }}
OCUS_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUS_OKAPI_CONSUMER_SECRET }}
OCNL_OKAPI_CONSUMER_KEY: ${{ secrets.OCNL_OKAPI_CONSUMER_KEY }}
OCNL_OKAPI_CONSUMER_SECRET: ${{ secrets.OCNL_OKAPI_CONSUMER_SECRET }}
OCRO_OKAPI_CONSUMER_KEY: ${{ secrets.OCRO_OKAPI_CONSUMER_KEY }}
OCRO_OKAPI_CONSUMER_SECRET: ${{ secrets.OCRO_OKAPI_CONSUMER_SECRET }}
OCUK_OKAPI_CONSUMER_KEY: ${{ secrets.OCUK_OKAPI_CONSUMER_KEY }}
OCUK_OKAPI_CONSUMER_SECRET: ${{ secrets.OCUK_OKAPI_CONSUMER_SECRET }}
SU_CONSUMER_KEY: ${{ secrets.SU_CONSUMER_KEY }}
SU_CONSUMER_SECRET: ${{ secrets.SU_CONSUMER_SECRET }}
THUNDERFOREST_API_KEY: ${{ secrets.THUNDERFOREST_API_KEY }}
ALC_CONSUMER_KEY: ${{ secrets.ALC_CONSUMER_KEY }}
PREF_COOKIESTORE: ${{ secrets.PREF_COOKIESTORE }}
PREF_USERNAME: ${{ secrets.PREF_USERNAME }}
PREF_PASSWORD: ${{ secrets.PREF_PASSWORD }}
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v5
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: Report Gradle cache key length
run: |
KEY="${{ secrets.GRADLE_ENCRYPTION_KEY }}"
if [ -z "$KEY" ]; then
echo "::warning::GRADLE_ENCRYPTION_KEY is empty"
else
KEY_LEN=${#KEY}
echo "::notice::GRADLE_ENCRYPTION_KEY length: ${KEY_LEN}"
if [ "$KEY_LEN" -ne 16 ] && [ "$KEY_LEN" -ne 24 ] && [ "$KEY_LEN" -ne 32 ]; then
echo "::error::GRADLE_ENCRYPTION_KEY length must be 16, 24, or 32 bytes"
exit 1
fi
fi
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-read-only: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/release' }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
add-job-summary-as-pr-comment: never # Valid values are 'never' (default), 'always', and 'on-failure'
- name: Build binary
run: |
./gradlew --scan packageBasicDebug
./gradlew packageBasicDebugAndroidTest
- name: Upload resulting APK
uses: actions/upload-artifact@v7
with:
name: "cgeo-apk-api${{ matrix.api-level }}"
path: '*/build/outputs/apk/basic/**/cgeo*.apk'
overwrite: true
- name: AVD cache
uses: actions/cache@v6
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:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
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."
# Allow only one job at a time (prevent errors on live GC tests)
- name: Wait for lock on live tests
id: lock-tests
run: |
function unlock() {
curl -X POST -qSs "https://mutex.kumy.org/api/client/${{ secrets.MUTEX_SECRET }}/mutex/unit-test?unlock"
}
# Unlock immediatelly if we just get the lock and the step is cancelled
trap unlock SIGINT
TIMEOUT_MINUTES=120
i=0
locked=false
while [ "$i" -lt $(( 6 * $TIMEOUT_MINUTES )) ] && ! curl -X POST -qSs "https://mutex.kumy.org/api/client/${{ secrets.MUTEX_SECRET }}/mutex/unit-test?lock&waitTimeoutMs=10000" --fail
do ((i+=1))
done && locked=true
- name: Run Unit Tests
uses: reactivecircus/android-emulator-runner@v2
env:
# Define BUILD_NUMBER environment variable else the change from commit
# https://github.com/cgeo/cgeo/commit/cfa797e3a48cbd581a31f470703ee15ddb191f49
# prevent us to be recognized as a runner, which lead to appID being suffixed
# by ".developer" thus leading to failure installing the cgeo prefrences
BUILD_NUMBER: ${{ github.run_number }}
with:
api-level: ${{ matrix.api-level }}
target: google_apis
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
# Capture logcat output ; see https://github.com/ReactiveCircus/android-emulator-runner/issues/228
adb logcat -c || true
adb logcat > /tmp/cgeo-apk-api${{ matrix.api-level }}.logcat.txt &
./gradlew --scan testDebug -Pandroid.testInstrumentationRunnerArguments.notAnnotation=cgeo.geocaching.test.NotForIntegrationTests || { killall -INT crashpad_handler; false; }
killall -INT crashpad_handler || true
- name: Unlock live tests
# unlock only if we locked it
if: always() && steps.lock-tests.conclusion == 'success'
run: |
curl -X POST -qSs "https://mutex.kumy.org/api/client/${{ secrets.MUTEX_SECRET }}/mutex/unit-test?unlock"
- name: Upload logcat
uses: actions/upload-artifact@v7
if: always()
with:
name: "cgeo-apk-api${{ matrix.api-level }}.logcat"
path: '/tmp/cgeo-apk-api*.logcat.txt'
overwrite: true
# - name: Add PR comment with logcat output
# if: failure() && (github.event_name == 'pull_request_target' || github.event_name == 'pull_request')
# uses: thollander/actions-comment-pull-request@v3
# with:
# file-path: /tmp/cgeo-apk-api${{ matrix.api-level }}.logcat.txt
# comment-tag: cgeo-apk-api${{ matrix.api-level }}.logcat
# reactions: eyes, rocket
- name: Publish Test Report
uses: mikepenz/action-junit-report@v6
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/**/*.xml'
rerun-on-failure:
needs: integration-tests
if: >
failure() && fromJSON(github.run_attempt) < 3 &&
(
github.event_name != 'pull_request_target' ||
(
github.event.pull_request.head.repo.full_name != github.repository &&
(
(github.event.action == 'labeled' && github.event.label.name == 'ok-to-test') ||
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'ok-to-test'))
)
)
)
runs-on: ubuntu-latest
steps:
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GH_DEBUG: api
run: gh workflow run unit-tests-rerun.yml -F run_id=${{ github.run_id }}