diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..35cde5c --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,4 @@ +coverage: + status: + project: off + patch: off diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 21d5c35..cfab4d8 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -62,3 +62,45 @@ jobs: run: tox env: TOXENV: lint + + coverage: + name: Generate coverage + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + # Fetch all tags and branches because tests rely on it + with: + fetch-depth: 0 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install dependencies and coverage + run: python -m pip install tox + - name: Test with tox with coverage + run: tox + env: + TOXENV: coverage + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 48b39e1..75223f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Miscellaneous: * Add complete and working support for `toml` configuration files +* Add code coverage to the linter * Renamed `master` branch to `main` ## 2.5.3 diff --git a/README.md b/README.md index d3f8394..0935aba 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Detect backward incompatible migrations for your Django project. It will save you time by making sure migrations will not break with a older codebase. [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2F3YOURMIND%2Fdjango-migration-linter%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/3YOURMIND/django-migration-linter/goto?ref=main) +[![codecov](https://codecov.io/gh/3YOURMIND/django-migration-linter/branch/master/graph/badge.svg?token=pgNNXGbCf7)](https://codecov.io/gh/3YOURMIND/django-migration-linter) [![PyPI](https://img.shields.io/pypi/v/django-migration-linter.svg)](https://pypi.python.org/pypi/django-migration-linter/) [![PR_Welcome](https://img.shields.io/badge/PR-welcome-green.svg)](https://github.com/3YOURMIND/django-migration-linter/pulls) [![3YD_Hiring](https://img.shields.io/badge/3YOURMIND-Hiring-brightgreen.svg)](https://www.3yourmind.com/career) diff --git a/setup.py b/setup.py index 83c3fe9..2019fc6 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ setup( "django_add_default_value>=0.4.0", 'mock>=3.0.5;python_version<"3.3"', 'backports.tempfile>=1.0;python_version<="2.7"', + "coverage>=5.5", ], }, keywords="django migration lint linter database backward compatibility", diff --git a/tox.ini b/tox.ini index 07bfaea..8069efb 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py{35,36,37,38,39}-django22 py{36,37,38,39}-django{30,31,32} lint + coverage [gh-actions] python = @@ -38,3 +39,10 @@ commands = flake8 django_migration_linter/ black --check django_migration_linter/ tests/ manage.py setup.py isort --check-only . + +[testenv:coverage] +commands = + coverage run manage.py test --no-input {posargs} + coverage xml -i +extras = test +pip_pre = true