From 60344a0cf523607b4a109a5369b3a88d13810eef Mon Sep 17 00:00:00 2001 From: bronsen <kontakt+gitcommit@nrrd.de> Date: Tue, 18 Mar 2025 00:12:51 +0100 Subject: [PATCH] [tests,dependencies] install and configure coverage reports The reports will be printed on the terminal and written in xml. A new just recipe is added as well: `just cov` closes: #9 --- .woodpecker/workflow.yaml | 2 +- justfile | 2 ++ pyproject.toml | 19 +++++++++++++++++++ requirements/test.in | 1 + requirements/test.txt | 4 +++- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.woodpecker/workflow.yaml b/.woodpecker/workflow.yaml index 0bdbe9e..b818927 100644 --- a/.woodpecker/workflow.yaml +++ b/.woodpecker/workflow.yaml @@ -23,7 +23,7 @@ steps: - python -m venv venv - . venv/bin/activate - python -m pip install --disable-pip-version-check --no-input --quiet -r requirements/test.txt - - python -m pytest + - python -m pytest --cov --cov-report term services: - name: database diff --git a/justfile b/justfile index b6c14fb..2e7aae2 100644 --- a/justfile +++ b/justfile @@ -24,4 +24,6 @@ serve: test *ARGS: ENV_PATH=.env.test python -m pytest {{ARGS}} +cov *ARGS: + just test --cov --cov-report xml --cov-report term --junitxml=reports/junit/junit.xml {{ARGS}} alias fd := freshdeps diff --git a/pyproject.toml b/pyproject.toml index 9c87656..667696a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,25 @@ addopts = [ "--capture=sys", ] +[tool.coverage] +branch = true + +[tool.coverage.report] +skip_covered = true +skip_empty = true +show_missing = true + +[tool.coverage.run] +omit = [ + "*/migrations/*", + "VERSION.py", + "manage.py", + "config/[aw]sgi.py", +] + +[tool.coverage.xml] +output = "reports/coverage/coverage.xml" + [build-system] requires = ["pdm-backend"] build-backend = "pdm.backend" diff --git a/requirements/test.in b/requirements/test.in index 2c801fa..13b5dec 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -3,3 +3,4 @@ hypothesis[django] pytest pytest-django +pytest-cov diff --git a/requirements/test.txt b/requirements/test.txt index a038000..564af85 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,4 +1,4 @@ -# SHA1:9bf147356ad56dbe073ef0973141bdfb94631c9b +# SHA1:5d0aacdba01d54c2715a30c8df5ee5aef977d83c # # This file is autogenerated by pip-compile-multi # To update, run: @@ -7,10 +7,12 @@ # -r prod.txt attrs==25.3.0 +coverage==7.7.0 hypothesis==6.129.3 iniconfig==2.0.0 packaging==24.2 pluggy==1.5.0 pytest==8.3.5 +pytest-cov==6.0.0 pytest-django==4.10.0 sortedcontainers==2.4.0