diff --git a/.coveragerc b/.coveragerc index f7b135a6..9369b60a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,6 @@ [run] include = dependency_injector/* omit = tests/* + +[html] +directory=reports/unittests/ diff --git a/.gitignore b/.gitignore index a1c86b0b..54f697ba 100644 --- a/.gitignore +++ b/.gitignore @@ -33,7 +33,7 @@ pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports -htmlcov/ +reports/ .tox/ .coverage .cache @@ -62,8 +62,5 @@ venv/ # SQLite *.db -# JointJS Experiments -jointjs/ - # Vim Rope .ropeproject/ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..46b84088 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +VERSION:=$(shell python setup.py --version) + +clean: + # Clean sources + find dependency_injector -name '*.py[co]' -delete + find dependency_injector -name '__pycache__' -delete + find dependency_injector -name '*.c' -delete + find dependency_injector -name '*.so' -delete + # Clean tests + find tests -name '*.py[co]' -delete + find tests -name '__pycache__' -delete + # Clean examples + find examples -name '*.py[co]' -delete + find examples -name '__pycache__' -delete + +tests: clean + # Unit tests with coverage report + coverage erase + coverage run --rcfile=./.coveragerc -m unittest2 discover tests + coverage report --rcfile=./.coveragerc + coverage html --rcfile=./.coveragerc + coverage erase + # Static analysis + flake8 --max-complexity=10 dependency_injector/ + flake8 --max-complexity=10 examples/ + # Code style analysis + pydocstyle dependency_injector/ + pydocstyle examples/ + +publish: clean + # Create and upload build + python setup.py sdist upload + # Create and upload tag + git tag -a $(VERSION) -m 'version $(VERSION)' + git push --tags diff --git a/docs/main/changelog.rst b/docs/main/changelog.rst index 4de4f4e6..f0db1f01 100644 --- a/docs/main/changelog.rst +++ b/docs/main/changelog.rst @@ -10,6 +10,7 @@ follows `Semantic versioning`_ Development version ------------------- - Remove ``@inject`` decorator. +- Add makefile (``clean``, ``tests`` & ``publish`` commands). .. - No features. diff --git a/requirements-dev.txt b/requirements-dev.txt index d00c58f7..2b71e644 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,3 +4,6 @@ sphinx sphinx_rtd_theme sphinx_autobuild autodoc +coverage +flake8 +pydocstyle diff --git a/setup.py b/setup.py index 5a11962c..f6472771 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,8 @@ """`Dependency injector` setup script.""" -import os import re from setuptools import setup -from setuptools import Command # Getting description: @@ -20,26 +18,6 @@ with open('dependency_injector/__init__.py') as init_file: version = re.search('VERSION = \'(.*?)\'', init_file.read()).group(1) -class PublishCommand(Command): - """Setuptools `publish` command.""" - - description = "Publish current distribution to PyPi and create tag" - user_options = [] - - def initialize_options(self): - """Init options.""" - - def finalize_options(self): - """Finalize options.""" - - def run(self): - """Command execution.""" - self.run_command('sdist') - self.run_command('upload') - os.system('git tag -a {0} -m \'version {0}\''.format(version)) - os.system('git push --tags') - - setup(name='dependency-injector', version=version, description='Dependency injection microframework for Python', @@ -58,9 +36,6 @@ setup(name='dependency-injector', platforms=['any'], zip_safe=True, install_requires=requirements, - cmdclass={ - 'publish': PublishCommand, - }, keywords=[ 'DI', 'Dependency injection', diff --git a/tox.ini b/tox.ini index 2b8649a7..df81f63a 100644 --- a/tox.ini +++ b/tox.ini @@ -8,24 +8,6 @@ deps= commands= unit2 discover tests [] -[testenv:dev] -basepython=python2.7 -deps= - {[testenv]deps} - coverage - flake8 - pydocstyle -commands= - coverage erase - coverage run --rcfile=./.coveragerc -m unittest2 discover tests [] - coverage html --rcfile=./.coveragerc - - flake8 --max-complexity=10 dependency_injector/ - flake8 --max-complexity=10 examples/ - - pydocstyle dependency_injector/ - pydocstyle examples/ - [testenv:coveralls] basepython=python2.7 passenv=TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH