From d063c4ecca2e783d30dc75f44b8446f70c66d654 Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Wed, 12 Oct 2022 18:31:13 +0200
Subject: [PATCH] (ci) Add coverage integration into GitLab (#195, #167)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add coverage keyword and regex
Before GitLab v15.0, it used to be into the project settings
now, it’s into the CI config
This fixes previously working feature
https://docs.gitlab.com/ee/ci/pipelines/settings.html#merge-request-test-coverage-results

Add xml coverage report
base on that GitLab coverage integration
https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html#python-example

Create artifact already eventhough it is not yet deployed
to a web server (#167)
---
 .gitlab-ci.yml | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 760af18..c5478c5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,9 +100,19 @@ tests:3.8:
 
 tests:3.9:cov:
   extends: .tests
+  coverage: '/(?i)total.*\s+(\d+%)/'
   script:
     - poetry install
-    - poetry run pytest --cov duniterpy --cov-report html:cov_html --cov-report term
+    - poetry run pytest --cov duniterpy --cov-report html:cov_html --cov-report xml --cov-report term
+  artifacts:
+    paths:
+      - cov_html
+      - coverage.xml
+    expire_in: 2 days
+    reports:
+      coverage_report:
+        coverage_format: cobertura
+        path: coverage.xml
 
 tests:3.10:
   extends: .tests
-- 
GitLab