diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 5359a8d..d55acbf 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -65,4 +65,16 @@ jobs: - name: Run tests run: | - poetry run pytest \ No newline at end of file + poetry run pytest --cov --cov-report=xml + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + directory: ./coverage/reports/ + env_vars: OS,PYTHON + fail_ci_if_error: true + files: ./coverage.xml,!./cache + flags: unittests + name: coverage-neurobench + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7e707e6..749df77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,39 @@ testpaths = [ "tests/test_metrics.py", ] +[tool.coverage.run] +branch = true +include = [ + "neurobench/*", +] +omit = [ + "neurobench/examples/*", + "neurobench/datasets/*", + "neurobench/tests/*", +] + +[tool.coverage.report] + +exclude_also = [ + "def __repr__", + "if self\\.debug", + "raise AssertionError", + "raise NotImplementedError", + + # Don't complain if non-runnable code isn't run: + "if 0:", + "if __name__ == .__main__.:", + + # Don't complain about abstract methods, they aren't run: + "@(abc\\.)?abstractmethod", + ] + +ignore_errors = true +format = 'markdown' + +[tool.coverage.xml] +output = "coverage/reports/coverage.xml" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"