From 2d2bbbe6cebef9ed82678255fa875e8b9dcaeba6 Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 29 Oct 2024 11:58:21 +0100 Subject: [PATCH 1/3] add coverage --- .github/workflows/build.yaml | 20 ++++++++++++++++++++ .gitignore | 3 +++ pyproject.toml | 2 +- setup.py | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9119a6e9..c86aafec 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -85,6 +85,22 @@ 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.event_name != 'pull_request' + run: | + pip install genbadge[coverage] + genbadge coverage --input-file coverage.xml --output-file ./dist/coverage-badge.svg + coverage html -d dist/coverage + - uses: actions/upload-artifact@v4 + with: + name: coverage + retention-days: 1 + path: dist + test-tf: runs-on: ubuntu-latest @@ -140,6 +156,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/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", From 26e3afc469813bc0ea161fa5d16c77a2d376d318 Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 29 Oct 2024 13:00:21 +0100 Subject: [PATCH 2/3] add pytest-cov to dev envs --- dev/env-py38.yaml | 1 + dev/env-tf.yaml | 1 + dev/env-wo-python.yaml | 1 + dev/env.yaml | 1 + 4 files changed, 4 insertions(+) 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 From dcdbffebd904e5843b3005b8e8a0a4de4beac667 Mon Sep 17 00:00:00 2001 From: fynnbe Date: Tue, 29 Oct 2024 13:20:37 +0100 Subject: [PATCH 3/3] add badge --- .github/workflows/build.yaml | 7 ++++--- README.md | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c86aafec..0945af6d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -90,12 +90,13 @@ jobs: with: coverageFile: coverage.xml token: ${{ secrets.GITHUB_TOKEN }} - - if: matrix.python-version == '3.12' && github.event_name != 'pull_request' + - 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-badge.svg + genbadge coverage --input-file coverage.xml --output-file ./dist/coverage/coverage-badge.svg coverage html -d dist/coverage - - uses: actions/upload-artifact@v4 + - if: matrix.python-version == '3.12' && github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v4 with: name: coverage retention-days: 1 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