From 0e753327106b0a6acd5ffbb9dccd85a5ad1432ac Mon Sep 17 00:00:00 2001
From: Klaas Kliffen <kliffen@astron.nl>
Date: Wed, 22 Mar 2023 14:28:35 +0100
Subject: [PATCH] Add coverage in pipeline and badges to readmes

---
 README.md                                    | 3 +++
 {{cookiecutter.project_slug}}/.gitlab-ci.yml | 1 +
 {{cookiecutter.project_slug}}/README.md      | 5 +++++
 3 files changed, 9 insertions(+)

diff --git a/README.md b/README.md
index 34766ec..4ca5706 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
 # Example Python Package
 
+![Build status](https://git.astron.nl/templates/python-package/badges/main/pipeline.svg)
+![Test coverage](https://git.astron.nl/templates/python-package/badges/main/coverage.svg)
+
 An example repository of an CI/CD pipeline for building, testing and publishing a python package.
 
 If you find some missing functionality with regards to CI/CD, testing, linting or something else, feel free to make a merge request with the proposed changes.
diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
index b17457d..b398023 100644
--- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml
+++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
@@ -50,6 +50,7 @@ run_unit_tests_coverage:
   image: python:3.7
   script:
    - tox -e coverage
+  coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
   artifacts:
     reports:
       coverage_report:
diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md
index e0127fb..4a0ae90 100644
--- a/{{cookiecutter.project_slug}}/README.md
+++ b/{{cookiecutter.project_slug}}/README.md
@@ -1,5 +1,10 @@
 # {{cookiecutter.project_name}}
 
+<!-- TODO: replace  -->
+![Build status](https://git.astron.nl/templates/python-package/badges/main/pipeline.svg)
+![Test coverage](https://git.astron.nl/templates/python-package/badges/main/coverage.svg)
+<!-- ![Latest release](https://git.astron.nl/templates/python-package/badges/main/release.svg) -->
+
 An example repository of an CI/CD pipeline for building, testing and publishing a python package.
 
 ## Installation
-- 
GitLab