add code coverage bade & ci: fix pytest-cov

This commit is contained in:
scito
2022-12-30 00:58:52 +01:00
parent 51094a1a18
commit 04d864c093
7 changed files with 107 additions and 5 deletions
+7 -1
View File
@@ -238,7 +238,7 @@ eval "$cmd"
# Test
cmd="pytest --cov=test_extract_otp_secret_keys_pytest"
cmd="pytest --cov=test_extract_otp_secret_keys_pytest --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt"
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
eval "$cmd"
@@ -246,6 +246,12 @@ cmd="$PIPENV run pytest --cov=test_extract_otp_secret_keys_pytest"
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
eval "$cmd"
# Update Code Coverage in README.md
# https://github.com/marketplace/actions/pytest-coverage-comment
# Coverage-95%25-yellowgreen
TOTAL_COVERAGE=$(cat pytest-coverage.txt | grep 'TOTAL' | perl -ne 'print "$&" if /\b(\d{1,3})%/') && perl -i -pe "s/coverage-(\d{1,3}%)25-/coverage-${TOTAL_COVERAGE}25-/" README.md
# Build docker
cmd="docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull"