From 0037e2e21ad525b06a8b20afee005885cea4cb19 Mon Sep 17 00:00:00 2001
From: JanHab <Jan.Habscheid@web.de>
Date: Tue, 26 Nov 2024 18:02:50 +0100
Subject: [PATCH] Add Coverage?

---
 .gitlab-ci.yml | 9 ++++++++-
 Dockerfile     | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f5d26fc..15763ec 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -49,7 +49,14 @@ test:
   tags:
     - docker
   script:
-    - python -m pytest # Run the tests
+    # - python -m pytest # Run the tests
+    - pytest --cov=fxdgm --cov-report=xml --cov-report=term-missing tests/ # Run the tests and store coverage 
+  artifacts:
+    paths:
+      - coverage.xml # Save the coverage report
+    expire_in: 12 month  # Optional: Set how long to keep the artifacts (default: 30 days)
+  coverage: '/^TOTAL.*\s+(\d+\%)$/'
+
   
 # Job to deploy documentation to GitLab Pages
 pages:
diff --git a/Dockerfile b/Dockerfile
index 23fafbd..6dcdddf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -9,7 +9,7 @@ ENV HOME /root
 # Create the environment and install packages
 # FEniCSx backend + documentation and testing dependencies
 RUN conda create --name ${CONDA_DEFAULT_ENV} python=3.12.3 -y && \
-    conda install -n ${CONDA_DEFAULT_ENV} -c conda-forge fenics-dolfinx=0.8.0 mpich=4.2.1 pyvista=0.43.10 gcc=12.4.0 sphinx=7.3.7 myst-parser=4.0.0 sphinx-copybutton=0.5.2 sphinx-rtd-theme=3.0.1 pytest==8.3.3 -y
+    conda install -n ${CONDA_DEFAULT_ENV} -c conda-forge fenics-dolfinx=0.8.0 mpich=4.2.1 pyvista=0.43.10 gcc=12.4.0 sphinx=7.3.7 myst-parser=4.0.0 sphinx-copybutton=0.5.2 sphinx-rtd-theme=3.0.1 pytest==8.3.3 pytest-cov==6.0.0  -y
 # fxdgm package from git
 RUN pip install git+https://git.rwth-aachen.de/JanHab/bsc-electrolytemodels@Package
 
-- 
GitLab