From 97d3f0596853ec8c9c002ac1814068746d4ea9d9 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Sat, 20 Aug 2022 05:59:31 +0200 Subject: [PATCH] gitlab-ci: generate test coverage --- .gitlab-ci.yml | 9 ++++++--- pytest.sh | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f12941..4dd69d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,16 +27,19 @@ pytest: image: archlinux before_script: - pacman -Sy --noconfirm --needed archlinux-keyring && pacman -Su --noconfirm python python-pip sudo git base-devel - - pip install pytest -r requirements.txt + - pip install pytest pytest-cov -r requirements.txt - 'echo "kupfer ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/kupfer_all' - useradd -m kupfer - chmod 777 . script: - - script -e -c 'su kupfer -s /bin/bash -c ./pytest.sh' + - script -e -c 'su kupfer -s /bin/bash -c "./pytest.sh --cov=. --cov-branch --cov-report=term --cov-report=xml:coverage.xml"' + coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' artifacts: reports: junit: pytest-report.xml - + coverage_report: + coverage_format: cobertura + path: coverage.xml build_docker: stage: build image: docker:latest diff --git a/pytest.sh b/pytest.sh index 1fe988c..99ad17c 100755 --- a/pytest.sh +++ b/pytest.sh @@ -1,4 +1,4 @@ #!/bin/bash sudo -v -python -m pytest --junit-xml=pytest-report.xml -v ./*/test_*.py +python -m pytest --junit-xml=pytest-report.xml -v "$@" ./*/test_*.py