From f0eb80b4a0b945de7e60a7f9f419446534daf016 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Jonglez?= <clement@jonglez.space>
Date: Mon, 15 Jul 2024 10:52:50 +0200
Subject: [PATCH] CI: split test and coverage stages, install pytest-cov and
 coverage

---
 .gitlab-ci.yml | 19 ++++++++++++++++---
 pyproject.toml |  2 ++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 983f027..7d789fd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -38,7 +38,7 @@ flake8:
       codequality: gl-code-quality-report.json
     expire_in: 1 month
 
-test-and-coverage:
+test:
   stage: test
   image: python:$PYTHON_VERSION-bookworm
   parallel:
@@ -50,10 +50,23 @@ test-and-coverage:
     - python3 -m pip install .
     - cd test
     - python3 -m pytest PyhelpersTest.py # First test setup_orekit_data without the orekitdata library
-    - pip install git+https://gitlab.orekit.org/orekit/orekit-data.git
-    - python3 -m pytest --cov=orekit_jpype --cov-report term --cov-report xml:coverage.xml
+    - python3 -m pip install git+https://gitlab.orekit.org/orekit/orekit-data.git
+    - python3 -m pytest
     - cd ../tests-jvm
     - find . -name "*.py" -exec python3 -m pytest {} \;
+
+coverage:
+  stage: test
+  image: python:3.11-bookworm
+  script:
+    - source venv/bin/activate
+    - export JAVA_HOME=`python3 set_java_home.py`
+    - python3 -m pip install .
+    - cd test
+    - python3 -m pip install git+https://gitlab.orekit.org/orekit/orekit-data.git
+    - python3 -m pytest --cov --cov-report term --cov-report xml:coverage.xml
+
+  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
   artifacts:
     reports:
       coverage_report:
diff --git a/pyproject.toml b/pyproject.toml
index e7f0523..aea0ab5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -39,6 +39,8 @@ forum = "https://forum.orekit.org/c/orekit-python-wrapper-usage/17"
 [project.optional-dependencies]
 tests = [
     "pytest",
+    "coverage",
+    "pytest-cov"
 ]
 
 [pytest]
-- 
GitLab