Skip to content
Snippets Groups Projects
Commit 77e61dc6 authored by lukas leufen's avatar lukas leufen
Browse files

merged pytest cov html and term call

parent 55da63d7
Branches
Tags
3 merge requests!90WIP: new release update,!89Resolve "release branch / CI on gpu",!85Resolve "new gitlab runner specialised for mlt"
Pipeline #33792 passed
...@@ -39,13 +39,10 @@ TEST_PASSED="$(echo "${TEST_PASSED}" | (grep -oP '\d*'))" ...@@ -39,13 +39,10 @@ TEST_PASSED="$(echo "${TEST_PASSED}" | (grep -oP '\d*'))"
if [[ -z "$TEST_FAILED" ]]; then if [[ -z "$TEST_FAILED" ]]; then
TEST_FAILED=0 TEST_FAILED=0
fi fi
#let "TEST_PASSED=${TEST_PASSED}-${TEST_FAILED}"
(( TEST_PASSED=TEST_PASSED-TEST_FAILED )) (( TEST_PASSED=TEST_PASSED-TEST_FAILED ))
# calculate metrics # calculate metrics
(( SUM=TEST_FAILED+TEST_PASSED )) (( SUM=TEST_FAILED+TEST_PASSED ))
(( TEST_PASSED_RATIO=TEST_PASSED*100/SUM )) (( TEST_PASSED_RATIO=TEST_PASSED*100/SUM ))
#let "SUM=${TEST_FAILED}+${TEST_PASSED}"
#let "TEST_PASSED_RATIO=${TEST_PASSED}*100/${SUM}"
# report # report
if [[ ${IS_FAILED} -eq 0 ]]; then if [[ ${IS_FAILED} -eq 0 ]]; then
......
#!/usr/bin/env bash #!/usr/bin/env bash
# run coverage twice, 1) for html deploy 2) for success evaluation # run coverage twice, 1) for html deploy 2) for success evaluation
python3.6 -m pytest --cov=src --cov-report html test/ python3.6 -m pytest --cov=src --cov-report term --cov-report html test/ | tee coverage_results.out
python3.6 -m pytest --cov=src --cov-report term test/ | tee coverage_results.out
IS_FAILED=$? IS_FAILED=$?
# move html coverage report # move html coverage report
mkdir coverage/ mkdir coverage/
BRANCH_NAME=$( echo -e "${CI_COMMIT_REF_NAME////_}") BRANCH_NAME=$( echo -e "${CI_COMMIT_REF_NAME////_}")
mkdir coverage/${BRANCH_NAME} mkdir "coverage/${BRANCH_NAME}"
mkdir coverage/recent mkdir "coverage/recent"
cp -r htmlcov/* coverage/${BRANCH_NAME}/. cp -r htmlcov/* "coverage/${BRANCH_NAME}/."
cp -r htmlcov/* coverage/recent/. cp -r htmlcov/* coverage/recent/.
if [[ "${CI_COMMIT_REF_NAME}" = "master" ]]; then if [[ "${CI_COMMIT_REF_NAME}" = "master" ]]; then
cp -r htmlcov/* coverage/. cp -r htmlcov/* coverage/.
...@@ -19,10 +18,10 @@ fi ...@@ -19,10 +18,10 @@ fi
# extract coverage information # extract coverage information
COVERAGE_RATIO="$(grep -oP '\d+\%' coverage_results.out | tail -1)" COVERAGE_RATIO="$(grep -oP '\d+\%' coverage_results.out | tail -1)"
COVERAGE_RATIO="$(echo ${COVERAGE_RATIO} | (grep -oP '\d*'))" COVERAGE_RATIO="$(echo "${COVERAGE_RATIO}" | (grep -oP '\d*'))"
# report # report
if [[ ${IS_FAILED} == 0 ]]; then if [[ ${IS_FAILED} -eq 0 ]]; then
if [[ ${COVERAGE_RATIO} -lt ${COVERAGE_PASS_THRESHOLD} ]]; then if [[ ${COVERAGE_RATIO} -lt ${COVERAGE_PASS_THRESHOLD} ]]; then
echo "only ${COVERAGE_RATIO}% covered" echo "only ${COVERAGE_RATIO}% covered"
echo "incomplete" > status.txt echo "incomplete" > status.txt
......
...@@ -9,13 +9,12 @@ import logging ...@@ -9,13 +9,12 @@ import logging
import math import math
import os import os
import socket import socket
import sys
import time import time
import keras.backend as K import keras.backend as K
import xarray as xr import xarray as xr
from typing import Dict, Callable from typing import Dict, Callable, Pattern, Union
def to_list(arg): def to_list(arg):
...@@ -157,7 +156,7 @@ def set_bootstrap_path(bootstrap_path, data_path, sampling): ...@@ -157,7 +156,7 @@ def set_bootstrap_path(bootstrap_path, data_path, sampling):
class PyTestRegex: class PyTestRegex:
"""Assert that a given string meets some expectations.""" """Assert that a given string meets some expectations."""
def __init__(self, pattern: str, flags: int = 0): def __init__(self, pattern: Union[str, Pattern], flags: int = 0):
self._regex = re.compile(pattern, flags) self._regex = re.compile(pattern, flags)
def __eq__(self, actual: str) -> bool: def __eq__(self, actual: str) -> bool:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment