From 3fe1a2775c837ab978136b08784c2ecf8554ab1d Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Sat, 28 Oct 2023 14:59:54 +0200 Subject: [PATCH] test(coverage): make coverage consistent and reproducible --- .github/workflows/ci.yml | 2 +- .gitignore | 1 + pyproject.toml | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a476761f..8a1d46806 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: python -m pip install poetry poetry-dynamic-versioning poetry install --with dev,docs -v - name: Run pytest - run: poetry run poe test --cov=./ --cov-report=xml -ra . + run: poetry run poe coverage - name: Upload coverage to Codecov continue-on-error: true uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 212bf0589..ad4a6b559 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ pip-wheel-metadata # Tests artifacts .coverage* htmlcov/ +coverage.xml # macOS .DS_Store diff --git a/pyproject.toml b/pyproject.toml index dcffc73d2..65d1899af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,8 +81,8 @@ script = "devtasks:clean" help = "remove build/python artifacts" [tool.poe.tasks.coverage] -cmd = "pytest --cov-report html --cov copier copier tests" -help = "generate an HTML report of the coverage" +cmd = "pytest -p pytest_cov --cov --cov-report=html --cov-report=xml --cov-append" +help = "generate an HTML+XML report of the coverage" [tool.poe.tasks.dev-setup] script = "devtasks:dev_setup" @@ -128,10 +128,24 @@ add_ignore = ["D105", "D107"] [tool.pytest.ini_options] addopts = "-n auto -ra" +testpaths = [ + "copier/", + "tests/", +] markers = [ "impure: needs network or is not 100% reproducible" ] +[tool.coverage.run] +source = [ + "copier/", + "tests/", +] +omit = [ + "*/demo*/*", +] + + [tool.commitizen] annotated_tag = true changelog_incremental = true