From 151da64710794e2b15a6c6b36dd87be28ee1b0f5 Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Sun, 25 Sep 2022 19:09:17 +0200
Subject: [PATCH] (ci) Add coverage integration into GitLab (#447)
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
---
 .gitlab-ci.yml | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fc66c120..ddc43cd1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -124,13 +124,19 @@ tests:3.8:
 tests:3.9:coverage:
   extends: .tests
   tags: [redshift]
+  coverage: '/(?i)total.*\s+(\d+%)/'
   script:
     - poetry install
-    - poetry run pytest --cov silkaj --cov-report html:cov_html --cov-report term
+    - poetry run pytest --cov silkaj --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