Skip to content

Commit 3eb7997

Browse files
committed
cocalc-api: coverage report, makefile help
1 parent c652d60 commit 3eb7997

File tree

4 files changed

+196
-1
lines changed

4 files changed

+196
-1
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ src/conf/tinc_hosts/
7171
# mocha: banket coverage report
7272
src/coverage
7373
src/*/coverage
74+
75+
# Python coverage files
76+
.coverage
77+
.coverage.*
78+
htmlcov/
79+
**/htmlcov/
7480
# comes up when testing in that directory
7581
src/rethinkdb_data/
7682
src/dev/project/rethinkdb_data/

src/python/cocalc-api/Makefile

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
all: install build-docs
22

3+
help:
4+
@echo "Available targets:"
5+
@echo " install - Install project dependencies"
6+
@echo " format - Format code using yapf"
7+
@echo " check - Run linting and type checking"
8+
@echo " test - Run tests"
9+
@echo " test-verbose - Run tests with verbose output"
10+
@echo " coverage - Run tests with coverage reporting (HTML + terminal)"
11+
@echo " coverage-report - Show coverage report in terminal"
12+
@echo " coverage-html - Generate HTML coverage report only"
13+
@echo " serve-docs - Serve documentation locally"
14+
@echo " build-docs - Build documentation"
15+
@echo " publish - Build and publish package"
16+
@echo " clean - Clean build artifacts and cache files"
17+
318
install:
419
uv --version >/dev/null 2> /dev/null || curl -LsSf https://astral.sh/uv/install.sh | sh
520
uv sync --dev
@@ -19,6 +34,15 @@ test:
1934
test-verbose:
2035
uv run pytest -v
2136

37+
coverage:
38+
uv run pytest --cov=src --cov-report=term-missing --cov-report=html
39+
40+
coverage-report:
41+
uv run coverage report
42+
43+
coverage-html:
44+
uv run coverage html
45+
2246
serve-docs:
2347
uv run mkdocs serve
2448

@@ -30,6 +54,6 @@ publish: install
3054
uv publish
3155

3256
clean:
33-
rm -rf dist build *.egg-info site .pytest_cache
57+
rm -rf dist build *.egg-info site .pytest_cache htmlcov .coverage
3458
find . -name "__pycache__" -type d -exec rm -rf {} +
3559
find . -name "*.pyc" -delete

src/python/cocalc-api/pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,46 @@ indent_width = 4
3939
line-length = 150
4040
lint.select = ["E", "F", "B"] # Pyflakes, pycodestyle, bugbear, etc.
4141

42+
[tool.coverage.run]
43+
source = ["src"]
44+
omit = [
45+
"*/tests/*",
46+
"*/test_*.py",
47+
"*/__pycache__/*",
48+
"*/venv/*",
49+
"*/env/*",
50+
]
51+
52+
[tool.coverage.report]
53+
exclude_lines = [
54+
"pragma: no cover",
55+
"def __repr__",
56+
"if self.debug:",
57+
"if settings.DEBUG",
58+
"raise AssertionError",
59+
"raise NotImplementedError",
60+
"if 0:",
61+
"if __name__ == .__main__.:",
62+
"class .*\\bProtocol\\):",
63+
"@(abc\\.)?abstractmethod",
64+
]
65+
show_missing = true
66+
precision = 1
67+
68+
[tool.coverage.html]
69+
directory = "htmlcov"
70+
4271
[dependency-groups]
4372
dev = [
73+
"coverage[toml]",
4474
"ipython",
4575
"mkdocs",
4676
"mkdocs-material",
4777
"mkdocstrings[python]",
4878
"mypy",
4979
"pyright",
5080
"pytest>=8.4.1",
81+
"pytest-cov",
5182
"ruff>=0.12.11",
5283
"yapf",
5384
]

0 commit comments

Comments
 (0)