Skip to content

Commit 70d5d34

Browse files
test: add coverage
1 parent 70ae3b9 commit 70d5d34

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

.github/CONTRIBUTING.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,23 @@ Run the tests:
9898
pytest
9999
```
100100

101-
Install the package with `pipx`:
101+
Run the tests with [coverage](https://coverage.readthedocs.io/):
102+
103+
```sh
104+
coverage run -m pytest
105+
```
106+
107+
Generate a coverage report:
108+
109+
```sh
110+
coverage report
111+
```
112+
113+
```sh
114+
coverage html
115+
```
116+
117+
Install the package with [pipx](https://pipx.pypa.io/):
102118

103119
```sh
104120
pipx install .

.github/workflows/test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,13 @@ jobs:
2020
- name: Install dependencies
2121
run: pip install -e .[test]
2222

23-
- name: Run pytest
24-
run: pytest
23+
- name: Run tests and collect coverage
24+
run: |
25+
coverage run -m pytest
26+
coverage report
27+
coverage xml
28+
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v5
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# python_cli_template
22

33
[![PyPI version](https://badgen.net/pypi/v/python_cli_template)](https://pypi.org/project/python_cli_template/)
4-
[![test](https://github.com/remarkablemark/python_cli_template/actions/workflows/test.yml/badge.svg)](https://github.com/remarkablemark/python_cli_template/actions/workflows/test.yml)
4+
[![codecov](https://codecov.io/gh/remarkablemark/python_cli_template/graph/badge.svg?token=l6pg0nf9aJ)](https://codecov.io/gh/remarkablemark/python_cli_template)
55
[![lint](https://github.com/remarkablemark/python_cli_template/actions/workflows/lint.yml/badge.svg)](https://github.com/remarkablemark/python_cli_template/actions/workflows/lint.yml)
66

77
🐍 Python CLI Template

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ build = [
2828
]
2929
test = [
3030
"black==25.1.0",
31+
"coverage==7.7.1",
3132
"isort==6.0.1",
3233
"pre-commit==4.2.0",
3334
"pytest==8.3.5",

src/python_cli_template/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ def main(argv: list[str] = None) -> None:
3434
print(f"{color}{hello(args.name)}")
3535

3636

37-
if __name__ == "__main__":
37+
if __name__ == "__main__": # pragma: no cover
3838
main()

0 commit comments

Comments
 (0)