Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage #51

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: local
hooks:
- id: custom-script-py
name: Check Coverage
entry: poetry run python check_coverage.py
language: system
pass_filenames: false
args: [--fix]
11 changes: 11 additions & 0 deletions check_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import subprocess


def run_coverage():
try:
# Run tests with coverage
subprocess.run(["poetry", "run", "coverage", "run", "-m", "pytest"], check=True)
# Generate coverage report and check threshold
subprocess.run(["poetry", "run", "coverage", "report", "--fail-under=95"], check=True)
except subprocess.CalledProcessError as e:
print(f"Coverage check failed: {e}")
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ line-ending = "auto"
docstring-code-format = true
docstring-code-line-length = 100

[tool.coverage.run]
omit = [
"tests/*"
]

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.21.2"
Expand All @@ -58,6 +63,10 @@ matplotlib = "3.9.0"
requests = "^2.32.3"
semantic-version = "^2.10.0"
toml = "^0.10.2"
coverage = "^7.6.1"
pytest-cov = "^5.0.0"



[tool.setuptools.packages.find]
where = [ "src",]
Expand Down
Loading