فهرست منبع

Setup codecov.io to measure test coverage #696 (#739)

Rajat Gupta 1 سال پیش
والد
کامیت
57ecfca862
4فایلهای تغییر یافته به همراه15 افزوده شده و 2 حذف شده
  1. 1 1
      .github/workflows/cd.yml
  2. 9 0
      .github/workflows/ci.yml
  3. 4 1
      Makefile
  4. 1 0
      pyproject.toml

+ 1 - 1
.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

+ 9 - 0
.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 }}
+      

+ 4 - 1
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

+ 1 - 0
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"]