Skip to content

Commit e8aea6d

Browse files
authored
chore: fix playwright result
chore: fix playwright result
2 parents 8fc7017 + 5368762 commit e8aea6d

File tree

3 files changed

+104
-47
lines changed

3 files changed

+104
-47
lines changed

.github/utils/send_mesage.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,6 @@ def send_kbcli_message(url_v, result_v, title_v):
16871687
print(res.text)
16881688

16891689
def send_playwright_message(url_v, result_v, title_v):
1690-
print(f"--- Raw Input result_v ---\n{result_v}\n--------------------------")
16911690
import json
16921691
import requests
16931692

@@ -1736,7 +1735,6 @@ def send_playwright_message(url_v, result_v, title_v):
17361735
color = 'red' if "ERROR" in test_ret or "FAILED" in test_ret else 'green'
17371736

17381737
if is_first_row:
1739-
# 注意:这里使用 engine_type (parts[0]) 和 ret_url (parts[1])
17401738
type_content = f"<a href='{ret_url}'>{engine_type}</a>"
17411739
is_first_row = False
17421740
else:

.github/utils/utils.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ get_playwright_test_result() {
478478
for search_key in "${job_keys[@]}"; do
479479

480480
local search_pattern="###${search_key}###"
481-
local replacement_pattern="###${search_key}####${jobs_url}###"
481+
local replacement_pattern="###${search_key}###${jobs_url}###"
482482

483483
if [[ "$FINAL_RESULT" == *"$search_pattern"* ]]; then
484484
FINAL_RESULT=$(echo "$FINAL_RESULT" | sed "s|${search_pattern}|${replacement_pattern}|g")
@@ -495,10 +495,15 @@ get_playwright_test_result() {
495495

496496
get_playwright_test_result_total() {
497497
local cleaned_data_block
498-
cleaned_data_block=$(printf "%s" "$TEST_RESULT" | \
499-
tr '\n' ' ' | tr -s ' ' | xargs | \
498+
local TEST_RESULT_SAFE="$TEST_RESULT"
499+
echo "TEST_RESULT: $TEST_RESULT"
500+
501+
cleaned_data_block=$(printf "%s" "$TEST_RESULT_SAFE" | \
502+
tr -d '\r\t\xa0' | \
503+
tr '\n' ' ' | \
504+
tr -s ' ' | \
500505
sed -E 's/.*RESULT[[:space:]]*//' | \
501-
sed -E 's/[[:space:]]+[0-9]+$//' | \
506+
sed -E 's/[[:space:]]*PLAYWRIGHT TEST (SUCCESS!|FAILED, CODE: [0-9]+)$//' | \
502507
xargs
503508
)
504509

@@ -507,21 +512,25 @@ get_playwright_test_result_total() {
507512
fi
508513

509514
local engine_type
510-
engine_type=$(echo "$cleaned_data_block" | awk '{print $1}')
515+
engine_type=$(printf "%s" "$cleaned_data_block" | awk '{print $1}')
516+
517+
if [[ -z "$engine_type" ]]; then
518+
return 0
519+
fi
511520

512521
local accumulated_specs
513-
accumulated_specs=$(echo "$cleaned_data_block" | awk -v expected_engine="$engine_type" '
522+
accumulated_specs=$(printf "%s" "$cleaned_data_block" | awk -v expected_engine="$engine_type" '
514523
{
515524
FS="[[:space:]]+"
516525
accumulated_specs = ""
517526
518527
for (i = 1; i <= NF; i += 3) {
519-
if (i + 2 <= NF && $i == expected_engine) {
520528
529+
if (i + 2 <= NF && $i == expected_engine) {
521530
spec = $(i + 1)
522531
result = $(i + 2)
523532
524-
current_pair = spec "|" result
533+
current_pair = spec "##" result
525534
526535
if (accumulated_specs == "") {
527536
accumulated_specs = current_pair
@@ -537,8 +546,9 @@ get_playwright_test_result_total() {
537546
}')
538547

539548
if [[ -n "$accumulated_specs" ]]; then
540-
echo "###${engine_type}###${accumulated_specs}"
549+
echo "###$engine_type###$accumulated_specs"
541550
fi
551+
542552
}
543553

544554
set_cloud_test_runs_jobs() {

.github/workflows/cloud-e2e-web.yml

Lines changed: 85 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
test_engines="${test_engines},{\"test-engine\":\"${engine_tmp}\",\"test-job-index\":\"${test_job_index_tmp}\"}"
103103
fi
104104
done
105-
105+
106106
echo "${test_engines}"
107107
echo "${test_engines_all}"
108108
echo "test-engines={\"include\":[${test_engines}]}" >> $GITHUB_OUTPUT
@@ -302,10 +302,58 @@ jobs:
302302
set -e
303303
304304
cat ${test_file_log_path}
305-
TEST_RESULT="$(awk '/PLAYWRIGHT-RESULT/{found=1} found' "${test_file_log_path}" || true)"
306-
echo "TEST_RESULT:${TEST_RESULT}"
307-
TEST_RESULT=$(bash .github/utils/utils.sh --type 47 --test-result "$TEST_RESULT" )
308-
echo "test result total:${TEST_RESULT}"
305+
TEST_RESULT_ALL="$(awk '/PLAYWRIGHT-RESULT/{found=1} found' "${test_file_log_path}" || true)"
306+
307+
cleaned_data_block=$(printf "%s" "$TEST_RESULT_ALL" | \
308+
tr -d '\r\t\xa0' | \
309+
tr '\n' ' ' | \
310+
tr -s ' ' | \
311+
sed -E 's/.*RESULT[[:space:]]*//' | \
312+
sed -E 's/[[:space:]]*PLAYWRIGHT TEST (SUCCESS!|FAILED, CODE: [0-9]+)$//' | \
313+
xargs
314+
)
315+
316+
if [[ -z "$cleaned_data_block" ]]; then
317+
return 0
318+
fi
319+
320+
engine_type=$(printf "%s" "$cleaned_data_block" | awk '{print $1}')
321+
322+
if [[ -z "$engine_type" ]]; then
323+
return 0
324+
fi
325+
326+
accumulated_specs=$(printf "%s" "$cleaned_data_block" | awk -v expected_engine="$engine_type" '
327+
{
328+
FS="[[:space:]]+"
329+
accumulated_specs = ""
330+
331+
for (i = 1; i <= NF; i += 3) {
332+
333+
if (i + 2 <= NF && $i == expected_engine) {
334+
spec = $(i + 1)
335+
result = $(i + 2)
336+
337+
current_pair = spec "|" result
338+
339+
if (accumulated_specs == "") {
340+
accumulated_specs = current_pair
341+
} else {
342+
accumulated_specs = accumulated_specs "##" current_pair
343+
}
344+
}
345+
}
346+
}
347+
348+
END {
349+
printf "%s", accumulated_specs
350+
}')
351+
352+
TEST_RESULT=""
353+
if [[ -n "$accumulated_specs" ]]; then
354+
TEST_RESULT="###$engine_type###$accumulated_specs"
355+
fi
356+
echo TEST_RESULT="$TEST_RESULT"
309357
310358
if [[ -z "$TEST_RESULT" ]]; then
311359
TEST_RESULT=$(sed -n '/short test summary info/,$p' "${test_file_log_path}" | (egrep 'PASSED|FAILED|ERROR' | tail -n 1 || true))
@@ -465,7 +513,7 @@ jobs:
465513
echo "$delimiter" >> $GITHUB_OUTPUT
466514
;;
467515
esac
468-
516+
469517

470518
send-message:
471519
needs: [ get-test-engine, e2e-web-test ]
@@ -493,123 +541,124 @@ jobs:
493541
case "${test_job_index}" in
494542
01)
495543
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-1 }}"
496-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
544+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
545+
497546
;;
498547
02)
499548
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-2 }}"
500-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
549+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
501550
;;
502551
03)
503552
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-3 }}"
504-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
553+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
505554
;;
506555
04)
507556
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-4 }}"
508-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
557+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
509558
;;
510559
05)
511560
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-5 }}"
512-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
561+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
513562
;;
514563
06)
515564
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-6 }}"
516-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
565+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
517566
;;
518567
07)
519568
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-7 }}"
520-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
569+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
521570
;;
522571
08)
523572
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-8 }}"
524-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
573+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
525574
;;
526575
09)
527576
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-9 }}"
528-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
577+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
529578
;;
530579
10)
531580
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-10 }}"
532-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
581+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
533582
;;
534583
11)
535584
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-11 }}"
536-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
585+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
537586
;;
538587
12)
539588
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-12 }}"
540-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
589+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
541590
;;
542591
13)
543592
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-13 }}"
544-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
593+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
545594
;;
546595
14)
547596
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-14 }}"
548-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
597+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
549598
;;
550599
15)
551600
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-15 }}"
552-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
601+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
553602
;;
554603
16)
555604
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-16 }}"
556-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
605+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
557606
;;
558607
17)
559608
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-17 }}"
560-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
609+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
561610
;;
562611
18)
563612
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-18 }}"
564-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
613+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
565614
;;
566615
19)
567616
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-19 }}"
568-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
617+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
569618
;;
570619
20)
571620
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-20 }}"
572-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
621+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
573622
;;
574623
21)
575624
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-21 }}"
576-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
625+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
577626
;;
578627
22)
579628
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-22 }}"
580-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
629+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
581630
;;
582631
23)
583632
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-23 }}"
584-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
633+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
585634
;;
586635
24)
587636
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-24 }}"
588-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
637+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
589638
;;
590639
25)
591640
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-25 }}"
592-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
641+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
593642
;;
594643
26)
595644
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-26 }}"
596-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
645+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
597646
;;
598647
27)
599648
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-27 }}"
600-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
649+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
601650
;;
602651
28)
603652
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-28 }}"
604-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
653+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
605654
;;
606655
29)
607656
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-29 }}"
608-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
657+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
609658
;;
610659
30)
611660
TEST_RESULT="${{ needs.e2e-web-test.outputs.test-result-30 }}"
612-
TEST_RESULT_ALL="${TEST_RESULT_ALL}##${test_engines}|${TEST_RESULT}"
661+
TEST_RESULT_ALL="${TEST_RESULT_ALL}${TEST_RESULT}"
613662
;;
614663
esac
615664
done

0 commit comments

Comments
 (0)