Skip to content

Commit e0b7d49

Browse files
committed
try fix "Elapsed time"
1 parent be84a60 commit e0b7d49

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

.github/workflows/tests.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,33 +76,37 @@ jobs:
7676
echo '| Test Suite | ✓ Passed | ✗ Failed | ↻ Skipped | ∑ Total | ⏱ Elapsed |' >> "$GITHUB_STEP_SUMMARY"
7777
echo '|:---------- | -------: | -------: | --------: | ------: | --------: |' >> "$GITHUB_STEP_SUMMARY"
7878
79-
summarize () {
79+
iso_to_epoch() {
80+
local ts="$1"
81+
ts="${ts%%.*}"
82+
ts="${ts%Z}"
83+
ts=$(echo "$ts" | sed -E 's/[+-][0-9]{2}:[0-9]{2}$//')
84+
date -u -d "$ts" +%s 2>/dev/null || echo ""
85+
}
86+
87+
summarize() {
8088
local name="$1"; local expected="$2"
8189
local path="$expected"
82-
83-
[ ! -f "$path" ] && \
84-
path=$(find "$(dirname "$expected")" -maxdepth 3 -name '*.trx' -print -quit)
90+
[ ! -f "$path" ] && path=$(find "$(dirname "$expected")" -maxdepth 3 -name '*.trx' -print -quit)
8591
8692
if [ -f "$path" ]; then
8793
local passed failed total executed skipped duration
88-
passed=$(grep -oP 'passed="\K\d+' "$path" | head -1 || echo 0)
89-
failed=$(grep -oP 'failed="\K\d+' "$path" | head -1 || echo 0)
90-
total=$(grep -oP 'total="\K\d+' "$path" | head -1 || echo 0)
94+
passed=$(grep -oP 'passed="\K\d+' "$path" | head -1 || echo 0)
95+
failed=$(grep -oP 'failed="\K\d+' "$path" | head -1 || echo 0)
96+
total=$(grep -oP 'total="\K\d+' "$path" | head -1 || echo 0)
9197
executed=$(grep -oP 'executed="\K\d+' "$path" | head -1 || echo 0)
9298
[ -z "$executed" ] && executed=$((passed+failed))
9399
skipped=$((total-executed))
94100
95101
duration=$(grep -oP 'duration="\K[0-9\.]+' "$path" | head -1)
96102
97103
if [ -z "$duration" ]; then
98-
local start finish
99-
start=$(grep -oP '<Times[^>]*start="\K[^"]+' "$path" | head -1)
104+
local start finish ds df
105+
start=$(grep -oP '<Times[^>]*start="\K[^"]+' "$path" | head -1)
100106
finish=$(grep -oP '<Times[^>]*finish="\K[^"]+' "$path" | head -1)
101107
if [ -n "$start" ] && [ -n "$finish" ]; then
102-
start=${start%%.*}; finish=${finish%%.*}
103-
local ds df
104-
ds=$(date -u -d "$start" +%s 2>/dev/null || true)
105-
df=$(date -u -d "$finish" +%s 2>/dev/null || true)
108+
ds=$(iso_to_epoch "$start")
109+
df=$(iso_to_epoch "$finish")
106110
[ -n "$ds" ] && [ -n "$df" ] && duration=$((df-ds))
107111
fi
108112
fi
@@ -137,7 +141,7 @@ jobs:
137141
steps:
138142
- name: Checkout code
139143
uses: actions/checkout@v4
140-
144+
141145
- name: Install Dotnet
142146
uses: actions/setup-dotnet@v4
143147
with:

0 commit comments

Comments
 (0)