8000 Automatically retry failed tests up to 5 times · devlooped/oss@8bc16a7 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 8bc16a7

Browse files
committed
Automatically retry failed tests up to 5 times
The added script works in all target platforms, and keeps running failing tests until there are no more failing tests or the max 5 retries is achieved.
1 parent a9f9d3f commit 8bc16a7

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,33 @@ jobs:
5555
run: dotnet build -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"
5656

5757
- name: 🧪 test
58-
run: dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m
58+
shell: bash --noprofile --norc {0}
59+
env:
60+
LC_ALL: en_US.utf8
61+
run: |
62+
counter=0
63+
exitcode=0
64+
reset="\e[0m"
65+
warn="\e[0;33m"
66+
while [ $counter -lt 6 ]
67+
do
68+
if [ $filter ]
69+
then
70+
echo -e "${warn}Retry $counter for $filter ${reset}"
71+
fi
72+
# run test and forward output also to a file in addition to stdout (tee command)
73+
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m --filter=$filter | tee ./output.log
74+
# capture dotnet test exit status, different from tee
75+
exitcode=${PIPESTATUS[0]}
76+
if [ $exitcode == 0 ]
77+
then
78+
exit 0
79+
fi
80+
# cat output, get failed test names, join as DisplayName=TEST with |, remove trailing |.
81+
filter=$(cat ./output.log | grep -o -P '(?<=\sFailed\s)\w*' | awk 'BEGIN { ORS="|" } { print("DisplayName=" $0) }' | grep -o -P '.*(?=\|$)')
82+
((counter++))
83+
done
84+
exit $exitcode
5985
6086
- name: 📦 pack
6187
run: dotnet pack -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"

.github/workflows/publish.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,33 @@ jobs:
2525
run: dotnet build -m:1 -p:version=${GITHUB_REF#refs/*/v}
2626

2727
- name: 🧪 test
28-
run: dotnet test --no-build -m:1
28+
shell: bash --noprofile --norc {0}
29+
env:
30+
LC_ALL: en_US.utf8
31+
run: |
32+
counter=0
33+
exitcode=0
34+
reset="\e[0m"
35+
warn="\e[0;33m"
36+
while [ $counter -lt 6 ]
37+
do
38+
if [ $filter ]
39+
then
40+
echo -e "${warn}Retry $counter for $filter ${reset}"
41+
fi
42+
# run test and forward output also to a file in addition to stdout (tee command)
43+
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m --filter=$filter | tee ./output.log
44+
# capture dotnet test exit status, different from tee
45+
exitcode=${PIPESTATUS[0]}
46+
if [ $exitcode == 0 ]
47+
then
48+
exit 0
49+
fi
50+
# cat output, get failed test names, join as DisplayName=TEST with |, remove trailing |.
51+
filter=$(cat ./output.log | grep -o -P '(?<=\sFailed\s)\w*' | awk 'BEGIN { ORS="|" } { print("DisplayName=" $0) }' | grep -o -P '.*(?=\|$)')
52+
((counter++))
53+
done
54+
exit $exitcode
2955
3056
- name: 📦 pack
3157
run: dotnet pack -m:1 -p:version=${GITHUB_REF#refs/*/v}

0 commit comments

Comments
 (0)
0