Skip to content

Commit

Permalink
feat: Integrate coverage HTML report into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 10, 2021
1 parent 12213ab commit d450918
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ args = $(foreach a,$($(subst -,_,$1)_args),$(if $(value $a),$a="$($a)"))
check_code_quality_args = files
docs_serve_args = host port
release_args = version
test_args = match
test_args = cleancov match

BASIC_DUTIES = \
changelog \
Expand Down
7 changes: 5 additions & 2 deletions project/duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,18 @@ def coverage(ctx):
ctx.run("coverage html --rcfile=config/coverage.ini")


@duty(pre=[duty(lambda ctx: ctx.run("rm -f .coverage", silent=True))])
def test(ctx, match=""):
@duty
def test(ctx, cleancov: bool = True, match: str = ""):
"""
Run the test suite.
Arguments:
ctx: The context instance (passed automatically).
cleancov: Whether to remove the `.coverage` file before running the tests.
match: A pytest expression to filter selected tests.
"""
if cleancov:
ctx.run("rm -f .coverage", silent=True)
ctx.run(
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "tests"],
title="Running tests",
Expand Down
3 changes: 3 additions & 0 deletions project/mkdocs.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ nav:
- Development:
- Contributing: contributing.md
- Code of Conduct: code_of_conduct.md
- Coverage report: coverage.md

theme:
name: material
Expand Down Expand Up @@ -42,6 +43,8 @@ markdown_extensions:

plugins:
- search
- coverage:
html_report_dir: build/coverage
- mkdocstrings:
watch:
- src/[[ python_package_import_name ]]
1 change: 1 addition & 0 deletions project/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ipython = "^7.2"
isort = {version = "<5", extras = ["pyproject"]}
jinja2-cli = "^0.7.0"
mkdocs = "^1.1.2"
mkdocs-coverage = "^0.2.1"
mkdocs-material = "^6.2.7"
mkdocstrings = "^0.14.0"
mypy = "^0.800"
Expand Down
4 changes: 4 additions & 0 deletions tests/test_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ git add -A .
git commit -am "feat: Initial commit"
git tag v0.1.0
echo
echo ">>> Faking coverage HTML report"
mkdir -p build/coverage
touch build/coverage/index.html
echo
echo ">>> Setting up Python environments"
make --no-print-directory setup
echo
Expand Down

0 comments on commit d450918

Please sign in to comment.