diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..b14a77a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,36 @@ +name: Coverage + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Run tests + run: | + tox -e coverage + tox -e report + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 65c1e34..6f4187b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/tests.yml?label=tests) ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/seluj78/flask-utils/linting.yml?label=linting) ![GitHub License](https://img.shields.io/github/license/seluj78/flask-utils) +[![codecov](https://codecov.io/gh/Seluj78/flask-utils/graph/badge.svg?token=ChUOweAp4b)](https://codecov.io/gh/Seluj78/flask-utils) [//]: # (TODO: Uncomment when flask-utils had been freed from pypi) [//]: # (![PyPI - Downloads](https://img.shields.io/pypi/dm/flask-utils)) diff --git a/requirements-dev.txt b/requirements-dev.txt index 81ee991..ba4a28a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,12 @@ -r requirements.txt black +coverage flake8 mypy packaging pre-commit pytest +pytest-cov pytest-flask reorder-python-imports sphinx-lint diff --git a/tox.ini b/tox.ini index 689022d..3795f1f 100644 --- a/tox.ini +++ b/tox.ini @@ -11,3 +11,23 @@ deps = flask30: Flask==3.* flasklatest: Flask commands = pytest + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase + +[testenv:coverage] +commands = pytest --cov --cov-report=term-missing +deps = + pytest + pytest-cov + coverage + flask + +[testenv:report] +commands = + coverage report + coverage html +deps = coverage +skip_install = true