Skip to content

Commit

Permalink
Ensure we retry failing tests for samples too
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Jul 11, 2024
1 parent 2a5e198 commit 9e1c122
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ jobs:
echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> .bash_profile
- name: 🧪 test
run: dotnet test --no-build -l trx
working-directory: samples/dotnet
uses: ./.github/workflows/test
with:
working-directory: samples/dotnet

- name: 🧪 show
if: always()
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: test
description: runs dotnet tests with retry
inputs:
working-directory:

runs:
using: "composite"
steps:
- name: 🧪 test
shell: bash --noprofile --norc {0}
env:
LC_ALL: en_US.utf8
run: |
[ -f .bash_profile ] && source .bash_profile
counter=0
exitcode=0
reset="\e[0m"
warn="\e[0;33m"
while [ $counter -lt 6 ]
do
# run test and forward output also to a file in addition to stdout (tee command)
if [ $filter ]
then
echo -e "${warn}Retry $counter for $filter ${reset}"
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m --filter=$filter | tee ./output.log
else
dotnet test --no-build -m:1 --blame-hang --blame-hang-timeout 5m | tee ./output.log
fi
# capture dotnet test exit status, different from tee
exitcode=${PIPESTATUS[0]}
if [ $exitcode == 0 ]
then
exit 0
fi
# cat output, get failed test names, remove trailing whitespace, sort+dedupe, join as FQN~TEST with |, remove trailing |.
filter=$(cat ./output.log | grep -o -P '(?<=\sFailed\s)[\w\._]*' | sed 's/ *$//g' | sort -u | awk 'BEGIN { ORS="|" } { print("FullyQualifiedName~" $0) }' | grep -o -P '.*(?=\|$)')
((counter++))
done
exit $exitcode
5 changes: 5 additions & 0 deletions .netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@
sha = 2f8a7d3dffc4409dbda61afb43326ab9d871c1ec
etag = c8f63b95f4631df1e1bdc1e3fa592260f40c86e36032a979b572b880cf5a4fff
weak
[file ".github/workflows/test/action.yml"]
url = https://github.com/devlooped/oss/blob/main/.github/workflows/test/action.yml
sha = 9a1b07589b9bde93bc12528e9325712a32dec418
etag = b54216ac431a83ce5477828d391f02046527e7f6fffd21da1d03324d352c3efb
weak

0 comments on commit 9e1c122

Please sign in to comment.