diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9119a6e9..0945af6d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -85,6 +85,23 @@ jobs: run: pip install --no-deps -e . - name: pytest-spec-main run: pytest --disable-pytest-warnings + - if: matrix.python-version == '3.12' && github.event_name == 'pull_request' + uses: orgoro/coverage@v3.2 + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} + - if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main' + run: | + pip install genbadge[coverage] + genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg + coverage html -d dist/coverage + - if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v4 + with: + name: coverage + retention-days: 1 + path: dist + test-tf: runs-on: ubuntu-latest @@ -140,6 +157,10 @@ jobs: shell: bash -l {0} steps: - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: coverage + path: dist - uses: actions/setup-python@v5 with: python-version: '3.12' diff --git a/.gitignore b/.gitignore index 7fab0fab..d8be60be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +__pycache__/ +.coverage .env .idea/ .tox/ @@ -6,6 +8,7 @@ **/tmp build/ cache +coverage.xml dist/ docs/ typings/pooch/ diff --git a/README.md b/README.md index 59743839..333b5fab 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![downloads](https://static.pepy.tech/badge/bioimageio.core)](https://pepy.tech/project/bioimageio.core) [![conda-forge downloads](https://img.shields.io/conda/dn/conda-forge/bioimageio.core.svg?label=conda-forge)](https://anaconda.org/conda-forge/bioimageio.core/) ![code style](https://img.shields.io/badge/code%20style-black-000000.svg) +[![coverage](https://bioimage-io.github.io/core-bioimage-io-python/coverage/coverage-badge.svg)](https://bioimage-io.github.io/core-bioimage-io-python/coverage/index.html) # core-bioimage-io-python diff --git a/dev/env-py38.yaml b/dev/env-py38.yaml index 1acb6ec4..fd4aa65a 100644 --- a/dev/env-py38.yaml +++ b/dev/env-py38.yaml @@ -25,6 +25,7 @@ dependencies: - pydantic-settings - pyright - pytest + - pytest-cov - pytest-xdist - python-dotenv - python=3.8 # changed diff --git a/dev/env-tf.yaml b/dev/env-tf.yaml index 1e0d4dcc..7f8ae3a7 100644 --- a/dev/env-tf.yaml +++ b/dev/env-tf.yaml @@ -25,6 +25,7 @@ dependencies: - pydantic-settings - pyright - pytest + - pytest-cov - pytest-xdist - python-dotenv # - python=3.9 # removed diff --git a/dev/env-wo-python.yaml b/dev/env-wo-python.yaml index 26139649..6cb0a18e 100644 --- a/dev/env-wo-python.yaml +++ b/dev/env-wo-python.yaml @@ -25,6 +25,7 @@ dependencies: - pydantic-settings - pyright - pytest + - pytest-cov - pytest-xdist - python-dotenv # - python=3.9 # removed diff --git a/dev/env.yaml b/dev/env.yaml index 951029ef..7fa2ab7b 100644 --- a/dev/env.yaml +++ b/dev/env.yaml @@ -25,6 +25,7 @@ dependencies: - pydantic-settings - pyright - pytest + - pytest-cov - pytest-xdist - python-dotenv - python=3.9 diff --git a/pyproject.toml b/pyproject.toml index 083aaf84..9d6353a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ typeCheckingMode = "strict" useLibraryCodeForTypes = true [tool.pytest.ini_options] -addopts = " -n auto --capture=no --doctest-modules --failed-first" +addopts = "--cov=bioimageio --cov-report=xml -n auto --capture=no --doctest-modules --failed-first" [tool.ruff] line-length = 88 diff --git a/setup.py b/setup.py index 3ffc8e1f..98650cf1 100644 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ "pdoc", "psutil", # parallel pytest with 'pytest -n auto' "pyright", + "pytest-cov", "pytest-xdist", # parallel pytest "pytest", "torch>=1.6",