From 57ecfca8626aa1063a3d3785286b4e12713f44f0 Mon Sep 17 00:00:00 2001 From: Rajat Gupta <31777800+morgoth9808@users.noreply.github.com> Date: Sat, 30 Sep 2023 23:56:49 +0530 Subject: [PATCH] Setup codecov.io to measure test coverage #696 (#739) --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 9 +++++++++ Makefile | 5 ++++- pyproject.toml | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index c40f56e8..c357e514 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -37,4 +37,4 @@ jobs: - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9e280f5..faa1bd1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,3 +26,12 @@ jobs: run: make ci_lint - name: Test with pytest run: make ci_test + - name: Generate coverage report + run: make coverage + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + file: coverage.xml + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + diff --git a/Makefile b/Makefile index 932cfbc7..a83d57e8 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PIP := $(PYTHON) -m pip PROJECT_NAME := embedchain # Targets -.PHONY: install format lint clean test ci_lint ci_test +.PHONY: install format lint clean test ci_lint ci_test coverage install: poetry install @@ -39,3 +39,6 @@ ci_lint: ci_test: poetry run pytest + +coverage: + poetry run pytest --cov=$(PROJECT_NAME) --cov-report=xml diff --git a/pyproject.toml b/pyproject.toml index af113c4c..189fff78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,6 +118,7 @@ pytest-mock = "^3.10.0" pytest-env = "^0.8.1" click = "^8.1.3" isort = "^5.12.0" +pytest-cov = "^4.1.0" [tool.poetry.extras] streamlit = ["streamlit"]