diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml deleted file mode 100644 index b6fb029..0000000 --- a/.github/workflows/test-coverage.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Test Coverage - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - - name: Install Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - - name: Install Poetry - uses: Gr1N/setup-poetry@v8 - with: - poetry-version: '1.8.3' - - - name: Install dependencies - run: poetry install - - - name: Run tests coverage - run: | - poetry run coverage run -m pytest - poetry run coverage report - poetry run coverage xml - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: coverage.xml - flags: unittests - name: codecov-umbrella - fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a2ca8a..5104b17 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/check_coverage.py b/check_coverage.py new file mode 100644 index 0000000..24f7dac --- /dev/null +++ b/check_coverage.py @@ -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.") diff --git a/coverage.xml b/coverage.xml deleted file mode 100644 index 9ec597d..0000000 --- a/coverage.xml +++ /dev/null @@ -1,366 +0,0 @@ - - - - - - C:\opensource\OSIPI\pypi - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pyproject.toml b/pyproject.toml index a91ce00..47e5d66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -61,6 +66,8 @@ toml = "^0.10.2" coverage = "^7.6.1" pytest-cov = "^5.0.0" + + [tool.setuptools.packages.find] where = [ "src",]