From ba33a0bfe0159197578b7088e44312088e2b81a0 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 22 Apr 2025 12:47:55 +0200 Subject: [PATCH] build: :hammer: build coverage report and badge --- .gitignore | 2 +- justfile | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 63bd79f..6346a65 100644 --- a/.gitignore +++ b/.gitignore @@ -52,9 +52,9 @@ htmlcov/ .nox/ .coverage .coverage.* +coverage.* .cache nosetests.xml -coverage.xml *.cover *.py,cover .hypothesis/ diff --git a/justfile b/justfile index a300524..2b32db7 100644 --- a/justfile +++ b/justfile @@ -6,11 +6,29 @@ run-all: install-deps format-python check-python test-python check-commits build # Install Python package dependencies install-deps: - uv sync + uv sync --all-extras --dev # Run the Python tests test-python: - uv run pytest + # - A short traceback (tb) mode to make it easier to view + # - Use the `src/` package (importlib) + # - Use code coverage on the `src/` package + # - If tests fail, do not generate coverage report + # - Create the coverage report in XML (for badge), terminal, and HTML + # - Trigger failure if below 90% code coverage + uv run pytest \ + --tb=short \ + --import-mode=importlib \ + --cov=src \ + --no-cov-on-fail \ + --cov-report=term \ + --cov-report=xml \ + --cov-report=html \ + --cov-fail-under=90 + # Make the badge from the coverage report + uv run genbadge coverage \ + -i coverage.xml \ + -o htmlcov/coverage.svg # Check Python code with the linter for any errors that need manual attention check-python: