Skip to content

Commit

Permalink
Merge pull request #51 from OSIPI/add-code-coverage
Browse files Browse the repository at this point in the history
Add code coverage
  • Loading branch information
ltorres6 authored Dec 3, 2024
2 parents 0c93b83 + 75eb771 commit f5e94e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
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

0 comments on commit f5e94e4

Please sign in to comment.