Skip to content

Commit

Permalink
Added check coverage as a pre_commit-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedNasser8 committed Oct 1, 2024
1 parent 0b9dd17 commit ba8c37d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 405 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/test-coverage.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ 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
19 changes: 19 additions & 0 deletions check_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import subprocess
import sys


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}")
sys.exit(1)


if __name__ == "__main__":
print("Running coverage check...")
run_coverage()
print("Coverage check passed.")
Loading

0 comments on commit ba8c37d

Please sign in to comment.