Skip to content

Commit 39b7f34

Browse files
committed
fix summarize function
1 parent 3fc58db commit 39b7f34

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

.github/workflows/tests.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,33 @@ jobs:
8080
local name="$1"; local expected="$2"
8181
local path="$expected"
8282
83-
# если точного файла нет, ищем любой *.trx в каталоге проекта (включая TestResults)
8483
if [ ! -f "$path" ]; then
8584
local base_dir; base_dir="$(dirname "$expected")"
86-
local found
87-
found=$(find "$base_dir" -maxdepth 3 -type f -name '*.trx' -print -quit 2>/dev/null || true)
88-
if [ -n "$found" ]; then path="$found"; fi
85+
path=$(find "$base_dir" -maxdepth 3 -type f -name '*.trx' -print -quit 2>/dev/null || true)
8986
fi
9087
9188
if [ -f "$path" ]; then
92-
local counters passed failed skipped total duration
93-
counters=$(grep '<Counters' "$path" | head -1 || true)
94-
passed=$(echo "$counters" | sed -n 's/.*passed="\([0-9]*\)".*/\1/p'); [ -z "$passed" ] && passed=0
95-
failed=$(echo "$counters" | sed -n 's/.*failed="\([0-9]*\)".*/\1/p'); [ -z "$failed" ] && failed=0
96-
skipped=$(echo "$counters" | sed -n 's/.*skipped="\([0-9]*\)".*/\1/p'); [ -z "$skipped" ] && skipped=0
97-
total=$(echo "$counters" | sed -n 's/.*total="\([0-9]*\)".*/\1/p'); [ -z "$total" ] && total=0
98-
duration=$(grep -oP 'duration="\K[0-9\.]+' "$path" | head -1 || true); [ -z "$duration" ] && duration='-'
89+
local passed failed skipped total duration
90+
passed=$(grep -oP 'passed="\K\d+' "$path" | head -1 || echo 0)
91+
failed=$(grep -oP 'failed="\K\d+' "$path" | head -1 || echo 0)
92+
skipped=$(grep -oP 'skipped="\K\d+' "$path" | head -1 || echo 0)
93+
total=$(grep -oP 'total="\K\d+' "$path" | head -1 || echo 0)
94+
95+
duration=$(grep -oP 'duration="\K[0-9\.]+' "$path" | head -1 || true)
96+
if [ -z "$duration" ]; then
97+
local start finish
98+
start=$(grep -oP '<Times[^>]*start="\K[^"]+' "$path" | head -1 || true)
99+
finish=$(grep -oP '<Times[^>]*finish="\K[^"]+' "$path" | head -1 || true)
100+
if [ -n "$start" ] && [ -n "$finish" ]; then
101+
local ds df
102+
ds=$(date -u -d "$start" +%s 2>/dev/null || true)
103+
df=$(date -u -d "$finish" +%s 2>/dev/null || true)
104+
if [ -n "$ds" ] && [ -n "$df" ]; then
105+
duration=$((df-ds))
106+
fi
107+
fi
108+
fi
109+
[ -z "$duration" ] && duration='-'
99110
100111
echo "| $name | $passed | $failed | $skipped | $total | ${duration}s |" >> $GITHUB_STEP_SUMMARY
101112
else

0 commit comments

Comments
 (0)