diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 08dc49e..84a8e58 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -2,9 +2,8 @@ name: Test against different Python version on: push: - branches: master - pull_request: branches: [ master ] + pull_request: jobs: python_tests: @@ -17,7 +16,7 @@ jobs: matrix: # Python version(s) to use when running the tests # # https://github.com/actions/python-versions/blob/main/versions-manifest.json - python: + python-version: - "3.6" - "3.7" - "3.8" @@ -43,7 +42,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python }} + python-version: ${{ matrix.python-version }} # https://github.com/actions/cache/blob/main/examples.md#using-pip-to-get-cache-location - name: Get pip cache dir @@ -75,5 +74,13 @@ jobs: "./sql/populate.sh" mysql --protocol=tcp --port=53306 -uindex_digest -pqwerty index_digest -v -e '\s; SHOW TABLES; SHOW DATABASES;' - - name: Tests - run: make test + - name: Tests with code coverage + run: make coverage + + # https://coveralls-python.readthedocs.io/en/latest/usage/index.html + # upload coverage report for just one of Python version matrix runs + - name: Upload coverage report to Coveralls + if: matrix.python-version == '3.9' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: coveralls --service=github diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 75e4e9e..580d8f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ name: Integration tests on: push: - branches: master + branches: [ master ] pull_request: jobs: diff --git a/Makefile b/Makefile index 163b47f..b574f0b 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,14 @@ -project_name = indexdigest -coverage_options = --include='$(project_name)/*' --omit='$(project_name)/test/*' - install: pip install -U -e .[dev] test: - pytest -x $(project_name) -o log_cli=true -o log_cli_level=warning + pytest -vv -o log_cli=true -o log_cli_level=warning coverage: - rm -f .coverage* - rm -rf htmlcov/* - coverage run -p -m pytest -x $(project_name) - coverage combine - coverage html -d htmlcov $(coverage_options) - coverage xml -i - coverage report $(coverage_options) + pytest -vv --cov=indexdigest --cov-report=term --cov-report=xml --cov-report=html --cov-fail-under=93 lint: - pylint $(project_name)/ --ignore=test + pylint indexdigest/ --ignore=test demo: docker run --network=host -t macbre/index-digest:latest mysql://index_digest:qwerty@127.0.0.1/index_digest --analyze-data --skip-checks=non_utf_columns --skip-tables=0028_no_time diff --git a/README.md b/README.md index 1f05747..9590f7f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![PyPI](https://img.shields.io/pypi/v/indexdigest.svg)](https://pypi.python.org/pypi/indexdigest) [![Docker Hub](https://img.shields.io/docker/pulls/macbre/index-digest.svg)](https://hub.docker.com/r/macbre/index-digest/) +[![Coverage Status](https://coveralls.io/repos/github/macbre/index-digest/badge.svg?branch=master)](https://coveralls.io/github/macbre/index-digest?branch=master) Analyses your database queries and schema and suggests indices improvements. You can use `index-digest` as **your database linter**. The goal is to **provide the user with actionable reports** instead of just a list of statistics and schema details. Inspired by [Percona's `pt-index-usage`](https://www.percona.com/doc/percona-toolkit/LATEST/pt-index-usage.html). diff --git a/setup.py b/setup.py index 109b3e5..fe58a8c 100644 --- a/setup.py +++ b/setup.py @@ -50,8 +50,10 @@ extras_require={ 'dev': [ 'coverage==5.5', + 'coveralls==3.1.0', 'pylint==2.8.3', 'pytest==6.2.4', + 'pytest-cov==2.12.1', 'twine==3.4.1', ] },