From de92740793070e728d695d58c96767a86b10e7f8 Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Wed, 14 Sep 2022 08:41:47 +0200
Subject: [PATCH] Code coverage job and integration with gitlab CI/CD

---
 .gitignore     |  2 ++
 .gitlab-ci.yml | 13 +++++++++++++
 tox.ini        |  7 ++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 67eac53..7e8ebcd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ dist/*
 *.pyc
 
 .coverage
+coverage.xml
+htmlcov/*
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5788612..b17457d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,6 +45,19 @@ run_pylint:
 #   script:
 #     - echo "build fortran/c/cpp extension source code"
 
+run_unit_tests_coverage:
+  stage: test
+  image: python:3.7
+  script:
+   - tox -e coverage
+  artifacts:
+    reports:
+      coverage_report:
+        coverage_format: cobertura
+        path: coverage.xml
+    paths:
+      - htmlcov/*
+
 run_unit_tests:
   stage: test
   image: python:3.${PY_VERSION}
diff --git a/tox.ini b/tox.ini
index 0c73407..bd77bdf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -16,7 +16,12 @@ deps =
     -r{toxinidir}/tests/requirements.txt
 commands =
     {envpython} --version
-    {envpython} -m pytest --cov=map
+    {envpython} -m pytest
+
+[testenv:coverage]
+commands =
+    {envpython} --version
+    {envpython} -m pytest --cov-report xml --cov-report html --cov=map
 
 # Use generative name and command prefixes to reuse the same virtualenv
 # for all linting jobs.
-- 
GitLab