diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 13c1b73ad..f6ea4ab27 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -33,7 +33,14 @@ jobs: pip install 'numpy<2' pip install pywin32 } - python -m unittest discover -v -s ./comtypes/test -t comtypes\test + pip install coverage[toml] + coverage run -m unittest discover -v -s comtypes\test -t comtypes\test + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: true + network_filter: comtype + token: ${{ secrets.CODECOV_TOKEN }} - name: Unregister the OutProc COM server run: | cd source/CppTestSrv diff --git a/README.md b/README.md index 4c88625b3..f155a28d0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![PyPI - License](https://img.shields.io/pypi/l/comtypes)](https://pypi.org/project/comtypes/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/comtypes)](https://pypi.org/project/comtypes/) [![GitHub Repo stars](https://img.shields.io/github/stars/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/stargazers) [![GitHub forks](https://img.shields.io/github/forks/enthought/comtypes?style=social)](https://github.com/enthought/comtypes/network/members) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Tidelift Subscription](https://tidelift.com/badges/package/pypi/comtypes)](https://tidelift.com/subscription/pkg/pypi-comtypes?utm_source=pypi-comtypes&utm_medium=readme) +[![Coverage](https://img.shields.io/codecov/c/github/enthought/comtypes)](https://app.codecov.io/github/enthought/comtypes) `comtypes` is a lightweight pure Python [COM](https://learn.microsoft.com/en-us/windows/win32/com/component-object-model--com--portal) package based on the [`ctypes`](https://docs.python.org/library/ctypes.html) foreign function interface library. diff --git a/pyproject.toml b/pyproject.toml index d56bdaee4..0f1217eb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,3 +40,15 @@ ignore = ["E402"] "comtypes/test/test_subinterface.py" = ["E401", "F401", "F403", "F405"] "comtypes/test/test_urlhistory.py" = ["E401", "F401", "F403", "F405", "F841"] "comtypes/test/test_variant.py" = ["F401", "F821", "F841"] + +[tool.coverage.run] +# Specify the source directory to avoid tracking temporary files created by "test_client_regenerate_modules.py". +# Without this, coverage track these temporary files, leading to error when trying to generate a report. +source = ["comtypes"] +omit = ["comtypes/gen/*"] + +[tool.coverage.report] +exclude_also = [ + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +]