diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2932b08..8733545 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,9 @@
pytest:
image: python:3.10-alpine
- only:
- - main
script:
- sh tests/start_tests_gitlab.sh
- sed -i "s#/builds/DasMoorhuhn/autopicture-v3/src#${CI_PROJECT_DIR}#g" coverage.xml
+ coverage: '/Code coverage: \d+(?:\.\d+)?/'
artifacts:
name: "$CI_JOB_NAME"
reports:
diff --git a/tests/get_coverage_percent.py b/tests/get_coverage_percent.py
new file mode 100644
index 0000000..9574d65
--- /dev/null
+++ b/tests/get_coverage_percent.py
@@ -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)
diff --git a/tests/start_tests_gitlab.sh b/tests/start_tests_gitlab.sh
index 961ee74..265d5e4 100755
--- a/tests/start_tests_gitlab.sh
+++ b/tests/start_tests_gitlab.sh
@@ -5,4 +5,5 @@ sh tests/start_tests.sh
cp tests/coverage/coverage.xml ./coverage.xml
cp tests/coverage/report.xml ./report.xml
-# python3.10 tests/edit_source.py
+
+python3.10 tests/get_coverage_percent.py