Skip to content

Commit 0df9840

Browse files
authored
feat: Add coverage package and update dependencies
feat: Add coverage package and update dependencies
2 parents fd2f16a + ae5a841 commit 0df9840

7 files changed

Lines changed: 188 additions & 3 deletions

File tree

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
permissions:
1212
contents: read
1313
env:
14-
UV_VERSION: '0.8.4'
14+
UV_VERSION: '0.9.27'
1515
PYTHON_VERSION: '3.13'
1616

1717
steps:
@@ -41,7 +41,9 @@ jobs:
4141
run: uv sync
4242

4343
- name: Run pylint
44-
run: uv run -- pylint src
44+
run: |
45+
uv run -- pylint src
46+
uv run -- pylint tests
4547
4648
- name: Save uv caches
4749
if: steps.cache-restore.outputs.cache-hit != 'true'

.github/workflows/pytest.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Unit Test & Coverage
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
unit-test-coverage:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
env:
14+
UV_VERSION: '0.9.27'
15+
PYTHON_VERSION: '3.13'
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Restore uv caches
21+
id: cache-restore
22+
uses: actions/cache/restore@v4
23+
with:
24+
path: |
25+
~/.cache/uv
26+
~/.local/share/uv
27+
.venv
28+
key: uv-main-${{ env.UV_VERSION }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}
29+
restore-keys: |
30+
uv-main-
31+
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v6
34+
with:
35+
version: ${{ env.UV_VERSION }}
36+
python-version: ${{ env.PYTHON_VERSION }}
37+
enable-cache: false
38+
39+
- name: Install dependencies
40+
run: uv sync
41+
42+
- name: Run Unit Tests with Coverage
43+
run: |
44+
uv run -- coverage run -m pytest
45+
uv run -- coverage report --show-missing
46+
47+
- name: Save uv caches
48+
if: steps.cache-restore.outputs.cache-hit != 'true'
49+
uses: actions/cache/save@v4
50+
with:
51+
path: |
52+
~/.cache/uv
53+
~/.local/share/uv
54+
.venv
55+
key: uv-main-${{ env.UV_VERSION }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml', 'uv.lock') }}

.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
profile = black

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
[tool.coverage.run]
2+
source = ["src"]
3+
4+
[tool.coverage.report]
5+
omit = ["tests/*"]
16
[project]
27
name = "python-app-template"
38
version = "0.1.0"
@@ -6,6 +11,7 @@ readme = "README.md"
611
requires-python = ">=3.13"
712
dependencies = [
813
"black>=26.1.0",
14+
"coverage>=7.13.2",
915
"isort>=7.0.0",
1016
"loguru>=0.7.3",
1117
"pathlib>=1.0.1",
@@ -15,3 +21,14 @@ dependencies = [
1521
"pylint-pydantic>=0.4.1",
1622
"pytest>=9.0.2",
1723
]
24+
25+
[project.optional-dependencies]
26+
build = ["uv ~= 0.9.27"]
27+
28+
[tool.semantic_release]
29+
build_command = """
30+
python -m pip install -e '.[build]'
31+
uv lock --upgrade-package "$PACKAGE_NAME"
32+
git add uv.lock
33+
uv build
34+
"""

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ def main():
1111
logger.info("Hello from python-app-template!")
1212

1313

14-
if __name__ == "__main__":
14+
if __name__ == "__main__": # pragma: no cover
1515
main()

tests/test_main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,22 @@
22
Docstring for tests.test_main
33
"""
44

5+
import subprocess
6+
import sys
7+
58
from src.main import main
69

710

11+
def test_main_subprocess():
12+
result = subprocess.run(
13+
[sys.executable, "-m", "src.main"],
14+
capture_output=True,
15+
text=True,
16+
check=True,
17+
)
18+
assert result.returncode == 0
19+
20+
821
def test_main_runs(capfd):
922
main()
1023
out, _ = capfd.readouterr()

uv.lock

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)