Merge branch 'develop' into 'main'

try coverage

See merge request DasMoorhuhn/autopicture-v3!4
This commit is contained in:
2023-12-12 02:31:17 +00:00
3 changed files with 17 additions and 3 deletions

View File

@@ -1,10 +1,9 @@
pytest: pytest:
image: python:3.10-alpine image: python:3.10-alpine
only:
- main
script: script:
- sh tests/start_tests_gitlab.sh - sh tests/start_tests_gitlab.sh
- sed -i "s#<source>/builds/DasMoorhuhn/autopicture-v3/src</source>#<source>${CI_PROJECT_DIR}</source>#g" coverage.xml - sed -i "s#<source>/builds/DasMoorhuhn/autopicture-v3/src</source>#<source>${CI_PROJECT_DIR}</source>#g" coverage.xml
coverage: '/Code coverage: \d+(?:\.\d+)?/'
artifacts: artifacts:
name: "$CI_JOB_NAME" name: "$CI_JOB_NAME"
reports: reports:

View File

@@ -0,0 +1,14 @@
with open(file="coverage.xml") as file:
file_content = file.readlines()
line_rate = None
for line in file_content:
try:
line = line.strip().split("<")[1].split(">")[0].split(" ")
if line[0] == "package":
line_rate = "Code coverage: " + str(int(round(float(line[2].split("=\"")[1].split("\"")[0])*100, 0))) + "%"
except:
pass
print(line_rate)

View File

@@ -5,4 +5,5 @@ sh tests/start_tests.sh
cp tests/coverage/coverage.xml ./coverage.xml cp tests/coverage/coverage.xml ./coverage.xml
cp tests/coverage/report.xml ./report.xml cp tests/coverage/report.xml ./report.xml
# python3.10 tests/edit_source.py
python3.10 tests/get_coverage_percent.py