Repository navigation
976 lines (913 loc) · 46.1 KB
/
Copy pathandroid-managed-device.yml
File metadata and controls
976 lines (913 loc) · 46.1 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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
name: Android Managed Device Test
# 모든 same-repository PR 에 기존 두 required context를 만들되, CI Test Plan이 none이면 에뮬레이터를
# 만들지 않는다. selected는 선언한 FQCN#method와 lane만, full은 API 30 전체와 API 34 smoke를 실행한다.
# minSdk API 26과 targetSdk API 36 경계 smoke는 scheduled_only라 정기/default-branch 수동 실행에서만
# 에뮬레이터를 띄우고 PR full 또는 복구 dispatch 비용을 늘리지 않는다.
# PR head SHA와 default branch에서 staging한 parser/verifier를 함께 검증한다. fork PR은 실행하지 않는다.
# 라벨 조정기의 자동 dispatch 도 PR head branch ref 에 생성하고 이벤트 SHA 를 현재 PR HEAD 와 다시
# 대조한다. 정기·일반 수동 실행만 default branch 를 사용하므로 PR 코드가 기본 브랜치 cache scope 에서
# 실행되지 않는다.
# 테스트 실패는 재시도하지 않는다. API 30/34가 테스트 XML과 실행 시작 신호 없이 GMD 준비
# 단계에서 멈춘 경우만 default branch의 별도 복구 workflow가 첫 실행의 해당 job을 새 runner에서
# 한 번 재실행한다. API 30은 Gradle timeout 종료 코드 124도 함께 요구한다.
on:
workflow_dispatch:
inputs:
pull_request_number:
description: "자동 복구할 열린 PR 번호, 0이면 default branch"
required: false
default: 0
type: number
expected_head_sha:
description: "PR 자동 복구가 관찰한 40자리 head SHA"
required: false
default: ""
type: string
expected_plan_digest:
description: "라벨 조정기가 관찰한 CI Test Plan SHA-256"
required: false
default: ""
type: string
generate_baseline_profile:
description: "선택한 branch ref에서 API 34 Baseline Profile artifact만 생성"
required: false
default: false
type: boolean
pull_request:
types: [opened, reopened, edited, synchronize]
# merge queue 는 큐 ref 에서 두 required lane 을 다시 요구한다. merge group 에는 PR 이
# 없어 CI Test Plan 을 읽을 수 없으므로 default branch 실행과 같은 full 로 판정한다.
merge_group:
types: [checks_requested]
schedule:
- cron: "17 18 * * 2,5"
permissions:
contents: read
pull-requests: read
concurrency:
group: android-managed-device-${{ github.event.pull_request.number || inputs.pull_request_number || github.ref }}
cancel-in-progress: true
jobs:
baseline-profile-generation:
name: Generate Baseline Profile artifact
if: >-
github.event_name == 'workflow_dispatch' &&
inputs.generate_baseline_profile &&
inputs.pull_request_number == 0
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Clone dispatched branch revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Verify checked out dispatch revision
run: test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
- name: Set up JDK
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: "21"
- name: Set up Gradle and validate wrapper
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
cache-provider: basic
cache-read-only: true
validate-wrappers: true
- name: Enable and verify KVM access
run: |
set -euo pipefail
runner_user="$(id -un)"
echo "KERNEL==\"kvm\", OWNER=\"${runner_user}\", GROUP=\"kvm\", MODE=\"0660\", OPTIONS+=\"static_node=kvm\"" \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm --settle
test -c /dev/kvm
test -r /dev/kvm
test -w /dev/kvm
"${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" emulator
"${ANDROID_HOME}/emulator/emulator" -accel-check
- name: Set up CI-only app configuration
uses: ./.github/actions/setup-ci-config
- name: Set up one-run release signing
uses: ./.github/actions/setup-ci-release-signing
- name: Generate API 34 Baseline Profile
id: baseline_profile
continue-on-error: true
timeout-minutes: 30
run: |
set -euo pipefail
log_dir="$RUNNER_TEMP/baseline-profile-log"
log_path="$log_dir/generate.log"
profile_dir="app/src/main/generated/baselineProfiles"
mkdir -p "$log_dir"
set +e
./gradlew :app:generateBaselineProfile \
-Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect \
-x :app:uploadCrashlyticsMappingFileRelease \
--no-daemon \
--stacktrace > "$log_path" 2>&1
status=$?
set -e
if [[ "$status" == "0" ]] &&
! find "$profile_dir" -type f -name '*-prof.txt' -size +0c -print -quit | grep -q .; then
echo 'Generated Baseline Profile is missing or empty.' >> "$log_path"
status=66
fi
{
echo "exit_code=$status"
echo "log_path=$log_path"
} >> "$GITHUB_OUTPUT"
exit "$status"
- name: Remove ephemeral release configuration
if: always()
run: |
rm -f app/google-services.json local.properties
for path in \
"${AFTERNOTE_CI_RELEASE_KEYSTORE:-}" \
"${AFTERNOTE_CI_RELEASE_STORE_PASSWORD_FILE:-}" \
"${AFTERNOTE_CI_RELEASE_KEY_PASSWORD_FILE:-}"; do
if [[ -n "$path" ]]; then
rm -f -- "$path"
fi
done
- name: Upload generated Baseline Profile and full log
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: baseline-profile-${{ github.sha }}-${{ github.run_id }}
if-no-files-found: warn
# 표준 보관 기간 7일 — 리포트·디버깅용 artifact 는 이 값 하나로 통일한다 (#1400).
retention-days: 7
path: |
app/src/main/generated/baselineProfiles/
${{ runner.temp }}/baseline-profile-log/
- name: Restore Baseline Profile generation exit code
if: always()
env:
GENERATION_EXIT_CODE: ${{ steps.baseline_profile.outputs.exit_code }}
GENERATION_OUTCOME: ${{ steps.baseline_profile.outcome }}
run: |
if [[ "$GENERATION_OUTCOME" != "success" ]]; then
echo "Baseline Profile generation did not complete: $GENERATION_OUTCOME"
fi
if ! [[ "$GENERATION_EXIT_CODE" =~ ^[0-9]+$ ]]; then
exit 124
fi
exit "$GENERATION_EXIT_CODE"
managed-device:
if: >-
github.event_name == 'schedule' ||
(github.event_name == 'workflow_dispatch' &&
!inputs.generate_baseline_profile &&
((inputs.pull_request_number == 0 &&
github.ref_name == github.event.repository.default_branch) ||
inputs.pull_request_number > 0)) ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
github.event_name == 'merge_group'
name: ${{ matrix.name }}
runs-on: ubuntu-latest
timeout-minutes: ${{ matrix.job_timeout_minutes }}
strategy:
fail-fast: false
matrix:
include:
- name: Pixel 2 API 26 minSdk smoke
task: pixel2Api26DebugAndroidTest
device: api26
job_timeout_minutes: 20
gradle_timeout_minutes: 16
gradle_step_timeout_minutes: 17
full_selector: com.afternote.afternote_fe.ApiBoundarySmokeAndroidTest
artifact: min-sdk-api26
scheduled_only: true
- name: Pixel 2 API 30 androidTest
task: pixel2Api30DebugAndroidTest
device: api30
job_timeout_minutes: 35
gradle_timeout_minutes: 30
gradle_step_timeout_minutes: 31
full_selector: ''
artifact: api30
scheduled_only: false
- name: Pixel 2 API 34 accessibility smoke
task: pixel2Api34DebugAndroidTest
device: api34
job_timeout_minutes: 15
gradle_timeout_minutes: 12
gradle_step_timeout_minutes: 13
full_selector: com.afternote.afternote_fe.AccessibilitySmokeAndroidTest
artifact: accessibility-api34
scheduled_only: false
- name: Pixel 2 API 36 targetSdk smoke
task: pixel2Api36DebugAndroidTest
device: api36
job_timeout_minutes: 20
gradle_timeout_minutes: 16
gradle_step_timeout_minutes: 17
full_selector: com.afternote.afternote_fe.ApiBoundarySmokeAndroidTest
artifact: target-sdk-api36
scheduled_only: true
steps:
- name: Clone trusted target policy
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- name: Stage trusted Android test policy
id: policy
run: |
set -euo pipefail
policy_dir="$RUNNER_TEMP/android-test-policy"
mkdir -p "$policy_dir"
if [[ -f .github/scripts/ci-test-plan.mjs &&
-f .github/scripts/resolve-android-test-plan.mjs &&
-f .github/scripts/resolve-pr-impact.mjs &&
-f .github/scripts/validate-pr-ci-test-plan.mjs &&
-f .github/scripts/verify-android-test-plan-result.mjs ]]; then
install -m 0644 \
.github/scripts/ci-test-plan.mjs \
"$policy_dir/ci-test-plan.mjs"
install -m 0644 \
.github/scripts/resolve-android-test-plan.mjs \
"$policy_dir/resolve-android-test-plan.mjs"
install -m 0644 \
.github/scripts/resolve-pr-impact.mjs \
"$policy_dir/resolve-pr-impact.mjs"
install -m 0644 \
.github/scripts/validate-pr-ci-test-plan.mjs \
"$policy_dir/validate-pr-ci-test-plan.mjs"
install -m 0644 \
.github/scripts/verify-android-test-plan-result.mjs \
"$policy_dir/verify-android-test-plan-result.mjs"
if [[ -f .github/scripts/render-android-test-results.mjs ]]; then
install -m 0644 \
.github/scripts/render-android-test-results.mjs \
"$policy_dir/render-android-test-results.mjs"
renderer=trusted
else
# 이 renderer를 처음 도입하는 PR만 tested revision의 summary-only 구현을 쓴다.
# selected 실행 증거 검증은 계속 위 trusted verifier가 소유한다.
renderer=bootstrap
fi
# 파일 존재가 아니라 report-android 명령의 존재로 가른다. 이 파일은 unit·screenshot
# 게이트용으로 이미 default branch 에 있어서, 존재만 보면 도입 PR 이 명령 없는
# 옛 사본을 실행해 스스로 red 가 된다.
if [[ -f .github/scripts/ci-expected-failures.mjs && -f .github/ci-expected-failures.json ]] &&
grep -q '"report-android"' .github/scripts/ci-expected-failures.mjs; then
install -m 0644 \
.github/scripts/ci-expected-failures.mjs \
"$policy_dir/ci-expected-failures.mjs"
install -D -m 0644 \
.github/ci-expected-failures.json \
"$policy_dir/root/.github/ci-expected-failures.json"
expected_failures=trusted
else
# 도입 PR 에서는 default branch 에 아직 없다. 목록이 없으면 모든 실패가
# 그대로 red 이므로 게이트가 느슨해지는 방향의 공백이 아니다.
expected_failures=unavailable
fi
if [[ -f .github/scripts/classify-android-managed-device-failure.mjs ]]; then
install -m 0644 \
.github/scripts/classify-android-managed-device-failure.mjs \
"$policy_dir/classify-android-managed-device-failure.mjs"
classifier=trusted
else
# 도입 PR에서는 default branch에 아직 없으므로 분류·자동 재실행을 생략한다.
# tested revision의 권한 없는 classifier를 신뢰 경계 밖에서 실행하지 않는다.
classifier=unavailable
fi
# dependabot PR 은 게이트가 CI Test Plan 을 채울 때까지 이 신뢰 사본으로 기다린다(#2212).
# 파일 존재가 아니라 await 명령의 존재로 가른다. 이 파일은 #2112 부터 default branch 에
# 있어서, 존재만 보면 도입 PR 이 명령 없는 옛 사본을 부른다.
if [[ -f .github/scripts/dependabot-pr-gate.mjs ]] &&
grep -q 'export async function awaitGate' .github/scripts/dependabot-pr-gate.mjs; then
install -m 0644 \
.github/scripts/dependabot-pr-gate.mjs \
"$policy_dir/dependabot-pr-gate.mjs"
dependabot_gate=trusted
else
# 도입 PR 은 사람이 연다. 기다릴 게이트가 없으니 종전처럼 이벤트 페이로드를 읽는다.
dependabot_gate=unavailable
fi
printf 'renderer=%s\nclassifier=%s\nexpected_failures=%s\ndependabot_gate=%s\nsource=trusted\n' \
"$renderer" "$classifier" "$expected_failures" "$dependabot_gate" >> "$GITHUB_OUTPUT"
elif [[ ! -e .github/scripts/ci-test-plan.mjs &&
! -e .github/scripts/resolve-android-test-plan.mjs &&
! -e .github/scripts/resolve-pr-impact.mjs &&
! -e .github/scripts/validate-pr-ci-test-plan.mjs &&
! -e .github/scripts/verify-android-test-plan-result.mjs ]]; then
# 최초 도입 PR에서는 default branch에 새 helper들이 아직 없다. 선언 검증을 target
# 코드에 맡기지 않고, 아래 단계가 selected/full 선언을 금지하는 fail-closed 예외다.
echo "::warning::default branch에 Android test policy가 없어 bootstrap mode를 사용합니다"
printf '%s\n' \
renderer=bootstrap \
classifier=unavailable \
expected_failures=unavailable \
dependabot_gate=unavailable \
source=bootstrap >> "$GITHUB_OUTPUT"
else
echo "::error::Android test policy가 부분 설치된 상태입니다"
exit 1
fi
- name: Resolve and verify tested revision
id: target
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DEPENDABOT_GATE: ${{ steps.policy.outputs.dependabot_gate }}
DISPATCH_REF_NAME: ${{ github.ref_name }}
DISPATCH_PR_NUMBER: ${{ inputs.pull_request_number || 0 }}
DEVICE: ${{ matrix.device }}
EVENT_NAME: ${{ github.event_name }}
EVENT_PR_AUTHOR: ${{ github.event.pull_request.user.login }}
EVENT_PR_BRANCH: ${{ github.event.pull_request.head.ref }}
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
EVENT_PR_SHA: ${{ github.event.pull_request.head.sha }}
EXPECTED_HEAD_SHA: ${{ inputs.expected_head_sha || '' }}
EXPECTED_PLAN_DIGEST: ${{ inputs.expected_plan_digest || '' }}
EXECUTION_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
FULL_SELECTOR: ${{ matrix.full_selector }}
POLICY_SOURCE: ${{ steps.policy.outputs.source }}
SCHEDULED_ONLY: ${{ matrix.scheduled_only }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
pull_request_file="$RUNNER_TEMP/android-test-pull-request.json"
if [[ "$EVENT_NAME" == "pull_request" ]]; then
target_pr="$EVENT_PR_NUMBER"
target_branch="$EVENT_PR_BRANCH"
target_sha="$EVENT_PR_SHA"
if [[ "$EVENT_PR_AUTHOR" == "dependabot[bot]" && "$DEPENDABOT_GATE" == "trusted" ]]; then
# dependabot-pr-gate 가 같은 순간 GITHUB_TOKEN 으로 CI Test Plan 을 채운다. 그 edited 는
# 이 워크플로를 다시 깨우지 못하고 페이로드는 opened 시점 값이다(#2212). 페이로드 제목에
# 대표 이슈 번호가 이미 있으면 API 없이 그대로 쓰고, 없으면 게이트가 채울 때까지 live PR 을
# 기다린다. 재실행으로 풀면 실제 테스트가 attempt 2 에서 돌아 1회차 인프라 복구를 잃는다.
# lane timeout 이 15분 이상이라 3분까지 기다린다.
PR_NUMBER="$EVENT_PR_NUMBER" AWAIT_TIMEOUT_SECONDS=180 \
node "$RUNNER_TEMP/android-test-policy/dependabot-pr-gate.mjs" await "$pull_request_file"
live_head_sha="$(jq -r '.head.sha' "$pull_request_file")"
if [[ "$live_head_sha" != "$EVENT_PR_SHA" ]]; then
echo "::error::기다리는 사이 PR head 가 $EVENT_PR_SHA 에서 $live_head_sha 로 움직였습니다. 새 head 의 run 이 판정합니다"
exit 1
fi
else
jq '.pull_request' "$GITHUB_EVENT_PATH" > "$pull_request_file"
fi
elif [[ "$EVENT_NAME" == "workflow_dispatch" && "$DISPATCH_PR_NUMBER" != "0" ]]; then
if ! [[ "$DISPATCH_PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
echo "::error::유효한 pull_request_number 가 필요합니다"
exit 1
fi
if ! [[ "$EXPECTED_HEAD_SHA" =~ ^[0-9a-f]{40}$ ]]; then
echo "::error::expected_head_sha 는 40자리 lowercase commit SHA 여야 합니다"
exit 1
fi
if ! [[ "$EXPECTED_PLAN_DIGEST" =~ ^[0-9a-f]{64}$ ]]; then
echo "::error::expected_plan_digest 는 64자리 lowercase SHA-256 이어야 합니다"
exit 1
fi
pull_request="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$DISPATCH_PR_NUMBER")"
printf '%s' "$pull_request" > "$pull_request_file"
state="$(jq -r '.state' <<< "$pull_request")"
head_repository="$(jq -r '.head.repo.full_name // ""' <<< "$pull_request")"
target_branch="$(jq -r '.head.ref' <<< "$pull_request")"
target_sha="$(jq -r '.head.sha' <<< "$pull_request")"
if [[ "$state" != "open" || "$head_repository" != "$GITHUB_REPOSITORY" ]]; then
echo "::error::PR #$DISPATCH_PR_NUMBER 는 열린 same-repository PR 이어야 합니다"
exit 1
fi
if [[ "$target_sha" != "$EXPECTED_HEAD_SHA" ]]; then
echo "::error::PR head $target_sha 가 dispatch 기대값 $EXPECTED_HEAD_SHA 와 다릅니다"
exit 1
fi
if [[ "$target_branch" != "$DISPATCH_REF_NAME" ]]; then
echo "::error::dispatch ref $DISPATCH_REF_NAME 가 현재 PR branch $target_branch 와 다릅니다"
exit 1
fi
target_pr="$DISPATCH_PR_NUMBER"
else
target_pr="none"
target_branch="$DEFAULT_BRANCH"
target_sha="$EXECUTION_SHA"
fi
if [[ "$target_sha" != "$EXECUTION_SHA" ]]; then
echo "::error::실행 event SHA $EXECUTION_SHA 가 검증한 target $target_sha 와 다릅니다"
exit 1
fi
plan_file="$RUNNER_TEMP/android-test-plan.json"
plan_digest=""
if [[ "$target_pr" != "none" ]]; then
if [[ "$POLICY_SOURCE" == "trusted" ]]; then
resolution="$(node "$RUNNER_TEMP/android-test-policy/resolve-android-test-plan.mjs" "$pull_request_file")"
jq -c '.plan' <<< "$resolution" > "$plan_file"
plan_digest="$(jq -r '.digest' <<< "$resolution")"
else
if [[ -n "$EXPECTED_PLAN_DIGEST" ]]; then
echo "::error::bootstrap mode에서는 expected_plan_digest를 사용할 수 없습니다"
exit 1
fi
if jq -r '.body // ""' "$pull_request_file" \
| grep -Eq '"mode"[[:space:]]*:[[:space:]]*"selected"'; then
echo "::error::bootstrap mode에서는 selected selector를 신뢰된 parser 없이 실행할 수 없습니다"
exit 1
fi
if jq -r '.body // ""' "$pull_request_file" \
| grep -Eq '"mode"[[:space:]]*:[[:space:]]*"full"'; then
jq -nc '{androidTest:{mode:"full",reason:"trusted CI Test Plan policy bootstrap full run"}}' > "$plan_file"
else
jq -nc '{androidTest:{mode:"none",reason:"trusted CI Test Plan policy bootstrap"}}' > "$plan_file"
fi
fi
else
jq -nc '{androidTest:{mode:"full",reason:"trusted default-branch scheduled or manual run"}}' > "$plan_file"
fi
if [[ "$EVENT_NAME" == "workflow_dispatch" && "$target_pr" != "none" &&
"$plan_digest" != "$EXPECTED_PLAN_DIGEST" ]]; then
echo "::error::현재 PR의 CI Test Plan digest가 dispatch 기대값과 다릅니다"
exit 1
fi
mode="$(jq -r '.androidTest.mode' "$plan_file")"
selectors_json='[]'
run_lane=false
if [[ "$SCHEDULED_ONLY" != "true" && "$SCHEDULED_ONLY" != "false" ]]; then
echo "::error::scheduled_only matrix 값은 true 또는 false여야 합니다"
exit 1
fi
if [[ "$SCHEDULED_ONLY" == "true" && "$target_pr" != "none" ]] ||
[[ "$SCHEDULED_ONLY" == "true" && "$EVENT_NAME" == "merge_group" ]]; then
# API 경계 lane은 default branch의 정기/일반 수동 실행만 허용한다.
# merge group 도 target_pr 이 none 이지만 required 인 API 30·34 만 돌리면
# 되므로 경계 lane 을 큐에서 함께 뺀다.
run_lane=false
elif [[ "$mode" == "full" ]]; then
run_lane=true
if [[ -n "$FULL_SELECTOR" ]]; then
selectors_json="$(jq -nc --arg selector "$FULL_SELECTOR" '[$selector]')"
fi
elif [[ "$mode" == "selected" ]]; then
selectors_json="$(jq -c --arg device "$DEVICE" \
'[.androidTest.tests[] | select(.device == $device) | .selector]' "$plan_file")"
if [[ "$(jq 'length' <<< "$selectors_json")" -gt 0 ]]; then
run_lane=true
fi
elif [[ "$mode" != "none" ]]; then
echo "::error::알 수 없는 androidTest mode: $mode"
exit 1
fi
selectors="$(jq -r 'join(",")' <<< "$selectors_json")"
{
echo "pr=$target_pr"
echo "branch=$target_branch"
echo "sha=$target_sha"
echo "mode=$mode"
echo "plan_digest=$plan_digest"
echo "pull_request_file=$pull_request_file"
echo "run_lane=$run_lane"
echo "selectors=$selectors"
echo "selectors_json=$selectors_json"
} >> "$GITHUB_OUTPUT"
- name: Clone tested revision
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# pull_request 는 head SHA, dispatch·schedule 은 그 branch/tag 에 결박된 event SHA 다.
# API 응답에서 유래한 step output 을 checkout ref 로 직접 사용하지 않는다.
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: Verify checked out revision
env:
EXPECTED_SHA: ${{ steps.target.outputs.sha }}
run: |
set -euo pipefail
actual_sha="$(git rev-parse HEAD)"
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
echo "::error::checkout $actual_sha 가 검증한 target $EXPECTED_SHA 와 다릅니다"
exit 1
fi
- name: Stage bootstrap result renderer from the tested revision
if: >-
steps.policy.outputs.renderer == 'bootstrap' &&
steps.target.outputs.run_lane == 'true'
run: |
set -euo pipefail
renderer=".github/scripts/render-android-test-results.mjs"
if [[ ! -f "$renderer" ]]; then
echo "::error::bootstrap result renderer가 tested revision에 없습니다"
exit 1
fi
install -m 0644 \
"$renderer" \
"$RUNNER_TEMP/android-test-policy/render-android-test-results.mjs"
- name: Stage bootstrap result verifier from the tested revision
if: >-
steps.policy.outputs.source == 'bootstrap' &&
steps.target.outputs.run_lane == 'true' &&
steps.target.outputs.selectors_json != '[]'
run: |
set -euo pipefail
verifier=".github/scripts/verify-android-test-plan-result.mjs"
if [[ ! -f "$verifier" ]]; then
echo "::error::bootstrap result verifier가 tested revision에 없습니다"
exit 1
fi
install -m 0644 \
"$verifier" \
"$RUNNER_TEMP/android-test-policy/verify-android-test-plan-result.mjs"
- name: Validate selected tests in the tested revision
if: steps.target.outputs.mode == 'selected'
env:
PULL_REQUEST_FILE: ${{ steps.target.outputs.pull_request_file }}
run: >-
node "$RUNNER_TEMP/android-test-policy/validate-pr-ci-test-plan.mjs"
"$PULL_REQUEST_FILE"
"$GITHUB_WORKSPACE"
- name: Record tested revision
env:
TARGET_BRANCH: ${{ steps.target.outputs.branch }}
TARGET_MODE: ${{ steps.target.outputs.mode }}
TARGET_PR: ${{ steps.target.outputs.pr }}
TARGET_RUN_LANE: ${{ steps.target.outputs.run_lane }}
TARGET_SELECTORS: ${{ steps.target.outputs.selectors }}
TARGET_SHA: ${{ steps.target.outputs.sha }}
run: |
{
echo "## Android Managed Device target"
echo
echo "- PR: $TARGET_PR"
echo "- Branch: \`$TARGET_BRANCH\`"
echo "- Commit: \`$TARGET_SHA\`"
echo "- Plan mode: \`$TARGET_MODE\`"
echo "- This lane boots an emulator: \`$TARGET_RUN_LANE\`"
if [[ -n "$TARGET_SELECTORS" ]]; then
echo "- Selectors: \`$TARGET_SELECTORS\`"
fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Set up JDK
if: steps.target.outputs.run_lane == 'true'
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: temurin
java-version: "21"
- name: Set up Gradle and validate wrapper
if: steps.target.outputs.run_lane == 'true'
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
with:
cache-provider: basic
cache-read-only: true
validate-wrappers: true
- name: Enable and verify KVM access
if: steps.target.outputs.run_lane == 'true'
run: |
runner_user="$(id -un)"
echo "KERNEL==\"kvm\", OWNER=\"${runner_user}\", GROUP=\"kvm\", MODE=\"0660\", OPTIONS+=\"static_node=kvm\"" \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm --settle
id
ls -l /dev/kvm
if [[ ! -c /dev/kvm || ! -r /dev/kvm || ! -w /dev/kvm ]]; then
echo "::error::/dev/kvm must be a character device readable and writable by the runner"
exit 1
fi
"${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" "emulator"
"${ANDROID_HOME}/emulator/emulator" -accel-check
- name: Set up CI-only app configuration
if: steps.target.outputs.run_lane == 'true'
uses: ./.github/actions/setup-ci-config
# selected 모드의 다중 Class#method 목록은 기기 러너가 비결정적으로 일부를
# 떨어뜨린다(#1378 실측 — 클래스당 2개뿐인 4항목 목록조차 런에 따라 중간이
# 사라진다). 단일 selector invocation 은 full_selector 레인들이 상시 증명하는
# 신뢰 경로이므로: 1차는 전체 목록으로 돌리고, 그 결과 XML 에 없는 선언
# selector 만 단일 항목으로 재실행해 합본한다. 뒤 단계(verify·render)는 재귀
# 탐색이라 합본을 무수정으로 읽는다. Gradle 시간 예산은 invocation 수와
# 무관하게 GRADLE_TIMEOUT_MINUTES 전체를 공유한다.
- name: Run managed-device androidTest
id: android_test
if: steps.target.outputs.run_lane == 'true'
timeout-minutes: ${{ matrix.gradle_step_timeout_minutes }}
env:
ARTIFACT_KEY: ${{ matrix.artifact }}
DEVICE_TASK: ${{ matrix.task }}
GRADLE_TIMEOUT_MINUTES: ${{ matrix.gradle_timeout_minutes }}
TEST_SELECTORS_JSON: ${{ steps.target.outputs.selectors_json }}
run: |
set -euo pipefail
log_directory="$RUNNER_TEMP/android-test-logs"
gradle_log="$log_directory/$ARTIFACT_KEY.log"
mkdir -p "$log_directory"
: > "$gradle_log"
results_root="app/build/outputs/androidTest-results/managedDevice"
chunk_store="$RUNNER_TEMP/android-test-chunk-results"
deadline=$(( $(date +%s) + GRADLE_TIMEOUT_MINUTES * 60 ))
run_gradle() { # $1: selector 목록(빈 문자열 = 필터 없음), $2: 로그 라벨
local selectors="$1" label="$2" remaining rc=0
local test_arguments=() jvm_arguments=()
# #1824 merge-group API34: cold APK packaging exhausted the 2Gi heap
# in ApkFlinger. The 15Gi runner still had 7Gi available, so reserve
# 4Gi and preserve the existing UTF-8 JVM flag.
# #2250 merge-group API30 (#1837 큐): 같은 ApkFlinger OOM 이 :app:packageDebug 에서
# 시스템 이미지 설치와 겹쳐 났다. 전체 androidTest 레인도 같은 4Gi 를 쓴다.
if [[ "$DEVICE_TASK" == "pixel2Api34DebugAndroidTest" ||
"$DEVICE_TASK" == "pixel2Api30DebugAndroidTest" ]]; then
jvm_arguments+=("-Dorg.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8")
fi
if [[ -n "$selectors" ]]; then
test_arguments+=("-Pandroid.testInstrumentationRunnerArguments.class=$selectors")
fi
if [[ -n "$label" ]]; then
echo "=== $label ===" >> "$gradle_log"
fi
remaining=$(( deadline - $(date +%s) ))
if (( remaining <= 0 )); then
echo "Managed-device Gradle budget exhausted before: $label" >> "$gradle_log"
return 124
fi
# errexit 를 함수 안에서 켜고 끄지 않는다. 여기서 set -e 를 되살리면 호출부의 set +e 가
# 무너져 Gradle 이 실패하는 순간 스텝이 exit_code 를 쓰기 전에 빠진다(#2157).
timeout --signal=TERM --kill-after=30s "${remaining}s" \
./gradlew "$DEVICE_TASK" "${test_arguments[@]}" "${jvm_arguments[@]}" \
-Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect \
--console=plain \
--stacktrace >> "$gradle_log" 2>&1 || rc=$?
return "$rc"
}
# verifier 와 같은 판정(name·classname 속성 쌍)으로 live XML 에 실행
# 기록이 있는지 본다.
selector_recorded() { # $1: Class#method
local cls="${1%%#*}" method="${1#*#}"
grep -rqE "<testcase[^>]*(name=\"$method\"[^>]*classname=\"$cls\"|classname=\"$cls\"[^>]*name=\"$method\")" \
"$results_root" 2>/dev/null
}
preserve_results() { # $1: 보존 디렉터리 이름
[[ -d "$results_root" ]] || return 0
mkdir -p "$chunk_store/$1"
(cd "$results_root" && find . -name '*.xml' -print0 | tar --null -cf - -T -) \
| tar -xf - -C "$chunk_store/$1"
}
if [[ -z "$TEST_SELECTORS_JSON" || "$TEST_SELECTORS_JSON" == "[]" ]]; then
status=0
run_gradle "" "" || status=$?
else
declared=()
while IFS= read -r entry; do
declared+=("$entry")
done < <(jq -r '.[]' <<< "$TEST_SELECTORS_JSON")
joined="$(jq -r 'join(",")' <<< "$TEST_SELECTORS_JSON")"
status=0
run_gradle "$joined" "selected invocation: 전체 목록 ${#declared[@]}개" || status=$?
# 누락 판정은 1차 런의 live 결과에 대해 한 번만 한다 — 재실행이 시작되면
# live 는 마지막 invocation 결과로 바뀌기 때문이다.
missing=()
if (( status == 0 )); then
for selector in "${declared[@]}"; do
[[ "$selector" == *"#"* ]] || continue
if ! selector_recorded "$selector"; then
missing+=("$selector")
fi
done
fi
retried=0
for selector in ${missing[@]+"${missing[@]}"}; do
preserve_results "invocation-$retried"
# 재실행이 테스트 태스크 전에 실패하면 live 가 이전 XML 을 그대로 들고 있어 합본에서
# 두 번 집계된다. 보존한 뒤 비워 live 가 이번 invocation 결과만 갖게 한다.
rm -rf "$results_root"
retried=$(( retried + 1 ))
status=0
run_gradle "$selector" "selected retry $retried/${#missing[@]}: $selector (목록 실행에서 누락 — #1378)" \
|| status=$?
if (( status != 0 )); then
break
fi
done
# 재실행이 있었으면 이전 invocation 들의 XML 을 합본으로 되돌린다.
# 각 invocation 의 결과는 다음 invocation 직전 한 번만 보존되므로
# testcase 중복이 없다(마지막 invocation 은 live 디렉터리가 소유).
if (( retried > 0 )) && [[ -d "$chunk_store" ]]; then
mkdir -p "$results_root/chunks"
cp -R "$chunk_store/." "$results_root/chunks/"
fi
fi
{
echo "exit_code=$status"
echo "log_path=$gradle_log"
} >> "$GITHUB_OUTPUT"
echo "Managed-device Gradle exit code: $status (full log is in the artifact)"
# Gradle 상한을 job 상한보다 먼저 끝내 아래 증거를 업로드할 시간을 확보한다. 환경 변수,
# process 인자, AVD 설정 파일은 수집하지 않아 CI 설정값이 artifact로 새지 않게 한다.
- name: Collect managed-device infrastructure diagnostics
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
(steps.android_test.outcome != 'success' ||
steps.android_test.outputs.exit_code != '0')
run: |
set +e
diagnostics="$RUNNER_TEMP/android-test-diagnostics"
mkdir -p "$diagnostics"
{
date --iso-8601=seconds
uname -a
id
ls -l /dev/kvm
df -h
free -h
ps -eo pid,ppid,etimes,stat,%cpu,%mem,comm
} > "$diagnostics/runner.txt" 2>&1
timeout 15s adb devices -l > "$diagnostics/adb-devices.txt" 2>&1 || true
timeout 15s adb -e shell getprop > "$diagnostics/emulator-getprop.txt" 2>&1 || true
timeout 15s "${ANDROID_HOME}/emulator/emulator" -accel-check \
> "$diagnostics/emulator-accel-check.txt" 2>&1 || true
- name: Classify managed-device infrastructure failure
id: infrastructure_failure
if: >-
always() &&
steps.policy.outputs.classifier == 'trusted' &&
steps.target.outputs.run_lane == 'true' &&
(steps.android_test.outcome != 'success' ||
steps.android_test.outputs.exit_code != '0')
env:
ANDROID_TEST_EXIT_CODE: ${{ steps.android_test.outputs.exit_code }}
ANDROID_TEST_OUTCOME: ${{ steps.android_test.outcome }}
ARTIFACT_KEY: ${{ matrix.artifact }}
DEVICE: ${{ matrix.device }}
TARGET_SHA: ${{ steps.target.outputs.sha }}
run: |
marker="$RUNNER_TEMP/android-test-diagnostics/retry.json"
node "$RUNNER_TEMP/android-test-policy/classify-android-managed-device-failure.mjs" \
"$RUNNER_TEMP/android-test-logs/$ARTIFACT_KEY.log" \
app/build/outputs/androidTest-results/managedDevice \
"$marker"
{
echo "## Managed-device infrastructure classification"
echo
echo "- Retry eligible: \`$(jq -r '.retryable' "$marker")\`"
echo "- Reason: \`$(jq -r '.reason' "$marker")\`"
} >> "$GITHUB_STEP_SUMMARY"
# PR이 고른 selector의 실행 증거는 계속 default branch에서 staging한 verifier가 소유한다.
# 오류는 다음 renderer가 summary와 annotation에 함께 싣도록 파일과 종료 코드로 넘긴다.
- name: Verify selected androidTest results
id: selected_android_test
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
steps.target.outputs.selectors_json != '[]'
env:
TARGET_SELECTORS_JSON: ${{ steps.target.outputs.selectors_json }}
run: |
verification_log="$RUNNER_TEMP/android-test-selected-verification.log"
set +e
node "$RUNNER_TEMP/android-test-policy/verify-android-test-plan-result.mjs" \
"$TARGET_SELECTORS_JSON" \
app/build/outputs/androidTest-results/managedDevice \
> "$verification_log" 2>&1
status=$?
set -e
{
echo "exit_code=$status"
echo "log_path=$verification_log"
} >> "$GITHUB_OUTPUT"
echo "Selected androidTest verifier exit code: $status"
# Gradle 또는 selected verifier 실패와 무관하게 XML을 읽고 한 화면짜리 summary와
# file/line annotation을 만든다. 도입 PR 이후에는 default branch의 trusted renderer다.
- name: Summarize androidTest results
id: android_test_results
if: always() && steps.target.outputs.run_lane == 'true'
env:
ANDROID_TEST_ANNOTATION_DIR: ${{ runner.temp }}/android-test-annotations
SELECTED_VERIFIER_EXIT_CODE: ${{ steps.selected_android_test.outputs.exit_code }}
SELECTED_VERIFIER_LOG: ${{ steps.selected_android_test.outputs.log_path }}
run: |
set +e
node "$RUNNER_TEMP/android-test-policy/render-android-test-results.mjs" \
app/build/outputs/androidTest-results/managedDevice \
"$GITHUB_WORKSPACE" \
"$SELECTED_VERIFIER_LOG" \
"$SELECTED_VERIFIER_EXIT_CODE"
status=$?
set -e
echo "exit_code=$status" >> "$GITHUB_OUTPUT"
# GitHub는 한 step의 error annotation을 10개로 제한한다. renderer가 job 한도인
# 50개까지 나눈 파일을 서로 다른 step에서 재생해 각 annotation을 UI에 보존한다.
- name: Publish androidTest annotations 1
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
fromJSON(steps.android_test_results.outputs.annotation_chunks || '0') >= 1
run: cat "$RUNNER_TEMP/android-test-annotations/chunk-1.log"
- name: Publish androidTest annotations 2
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
fromJSON(steps.android_test_results.outputs.annotation_chunks || '0') >= 2
run: cat "$RUNNER_TEMP/android-test-annotations/chunk-2.log"
- name: Publish androidTest annotations 3
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
fromJSON(steps.android_test_results.outputs.annotation_chunks || '0') >= 3
run: cat "$RUNNER_TEMP/android-test-annotations/chunk-3.log"
- name: Publish androidTest annotations 4
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
fromJSON(steps.android_test_results.outputs.annotation_chunks || '0') >= 4
run: cat "$RUNNER_TEMP/android-test-annotations/chunk-4.log"
- name: Publish androidTest annotations 5
if: >-
always() &&
steps.target.outputs.run_lane == 'true' &&
fromJSON(steps.android_test_results.outputs.annotation_chunks || '0') >= 5
run: cat "$RUNNER_TEMP/android-test-annotations/chunk-5.log"
- name: Upload managed-device infrastructure retry marker
if: >-
always() &&
steps.infrastructure_failure.outputs.retryable == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: android-managed-device-retry-${{ matrix.device }}-${{ github.run_id }}-${{ github.run_attempt }}
if-no-files-found: error
# 예외: job 간 전송용 — 소비하는 job 이 같은 run 안에서 끝나므로 1일이면 족하다 (#1400).
retention-days: 1
path: ${{ runner.temp }}/android-test-diagnostics/retry.json
- name: Upload androidTest reports and failure evidence
if: always() && steps.target.outputs.run_lane == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: android-managed-device-${{ matrix.artifact }}-${{ github.run_id }}-${{ github.run_attempt }}
if-no-files-found: warn
# 표준 보관 기간 7일 — 리포트·디버깅용 artifact 는 이 값 하나로 통일한다 (#1400).
retention-days: 7
path: |
app/build/reports/androidTests/managedDevice/
app/build/outputs/androidTest-results/managedDevice/
app/build/outputs/managed_device_android_test_additional_output/
${{ runner.temp }}/android-test-logs/
${{ runner.temp }}/android-test-annotations/
${{ runner.temp }}/android-test-diagnostics/
${{ runner.temp }}/android-test-selected-verification.log
# default branch 의 full 실행은 어떤 required check 도 건드리지 않아, 여기서 깨진
# androidTest 는 게이트에도 목록에도 잡히지 않고 아무도 통보받지 못했다(#1439).
# 실행 결과 XML 을 기대 실패 목록과 대조해 «의도된 red» 와 «새 회귀» 를 가른다.
- name: Evaluate androidTest expected failures
id: expected_failures
if: >-
always() &&
steps.policy.outputs.expected_failures == 'trusted' &&
steps.target.outputs.run_lane == 'true'
env:
DEVICE: ${{ matrix.device }}
EXPECTED_FAILURES_ROOT: ${{ runner.temp }}/android-test-policy/root
run: |
set +e
node "$RUNNER_TEMP/android-test-policy/ci-expected-failures.mjs" \
report-android \
app/build/outputs/androidTest-results/managedDevice \
"$DEVICE"
status=$?
set -e
echo "exit_code=$status" >> "$GITHUB_OUTPUT"
# XML 요약과 artifact 업로드를 끝낸 뒤에만 red로 만든다. Gradle이 실패했다면 원래
# 종료 코드를 우선 복원하고, Gradle 성공 뒤 result verifier만 실패한 경우 그 코드를 쓴다.
- name: Restore managed-device androidTest exit code
if: always() && steps.target.outputs.run_lane == 'true'
env:
ANDROID_TEST_EXIT_CODE: ${{ steps.android_test.outputs.exit_code }}
ANDROID_TEST_OUTCOME: ${{ steps.android_test.outcome }}
EXPECTED_ABSORBED: ${{ steps.expected_failures.outputs.absorbed }}
EXPECTED_FAILURES_EXIT_CODE: ${{ steps.expected_failures.outputs.exit_code }}
EXPECTED_UNEXPECTED: ${{ steps.expected_failures.outputs.unexpected }}
EXPECTED_XPASSED: ${{ steps.expected_failures.outputs.xpassed }}
RESULT_RENDERER_EXIT_CODE: ${{ steps.android_test_results.outputs.exit_code }}
SELECTED_VERIFIER_EXIT_CODE: ${{ steps.selected_android_test.outputs.exit_code }}
run: |
if [[ "$ANDROID_TEST_OUTCOME" != "success" ]]; then
echo "Managed-device Gradle step did not complete: $ANDROID_TEST_OUTCOME"
exit 124
fi
# 목록 밖 실패나 XPASS 는 그 자체로 red 다 — Gradle 이 통과했더라도.
if [[ -n "$EXPECTED_FAILURES_EXIT_CODE" && "$EXPECTED_FAILURES_EXIT_CODE" != "0" ]]; then
echo "Expected-failure evaluation failed (unexpected=$EXPECTED_UNEXPECTED xpassed=$EXPECTED_XPASSED)."
exit "$EXPECTED_FAILURES_EXIT_CODE"
fi
if [[ -n "$ANDROID_TEST_EXIT_CODE" && "$ANDROID_TEST_EXIT_CODE" != "0" ]]; then
# 기대 실패가 실제로 잡혔고 목록 밖 실패·XPASS 가 0 일 때만 흡수한다.
# 실패가 하나도 안 잡힌 채 Gradle 만 죽은 것은 인프라 실패이므로 그대로 red 다.
if [[ "${EXPECTED_ABSORBED:-0}" != "0" &&
"${EXPECTED_UNEXPECTED:-0}" == "0" &&
"${EXPECTED_XPASSED:-0}" == "0" ]]; then
echo "Gradle exit $ANDROID_TEST_EXIT_CODE 는 기대 실패 $EXPECTED_ABSORBED 건으로만 설명된다 — 흡수한다."
else
echo "Restoring managed-device Gradle exit code: $ANDROID_TEST_EXIT_CODE"
exit "$ANDROID_TEST_EXIT_CODE"
fi
fi
if [[ -n "$SELECTED_VERIFIER_EXIT_CODE" && "$SELECTED_VERIFIER_EXIT_CODE" != "0" ]]; then
echo "Selected androidTest result verification failed."
exit "$SELECTED_VERIFIER_EXIT_CODE"
fi
if [[ -n "$RESULT_RENDERER_EXIT_CODE" && "$RESULT_RENDERER_EXIT_CODE" != "0" ]]; then
echo "Android test XML summary failed."
exit "$RESULT_RENDERER_EXIT_CODE"
fi