diff --git a/.travis.yml b/.travis.yml index fef1c93f2..2f50f47e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,27 +4,26 @@ python: - "3.7" - "3.8" dist: xenial +addons: + apt: + packages: + - cmake # command to install dependencies cache: - pip install: - - "pip install --upgrade pip; pip install --upgrade setuptools; pip install -r test_requirements.txt; pip install -e git+https://github.com/django/django-contrib-comments.git#egg=django-contrib-comments; python setup.py install" -# command to run tests -env: - - TESTCASE=tests/tests_docs.py - - TESTCASE=tests/test_handler.py - - TESTCASE=tests/tests_middleware.py - - TESTCASE=tests/tests_placebo.py - - TESTCASE=tests/tests_async.py - - TESTCASE=tests/tests.py -before_script: - # stop the build if there are Python syntax errors or undefined names - - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - make requirements + - python setup.py install + script: - - nosetests $TESTCASE --with-coverage --cover-package=zappa --with-timer - # - coverage combine --append + - make flake + - make test-docs + - make test-handler + - make test-middleware + - make test-placebo + - make test-async + - make test-general + after_success: coveralls notifications: diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..1cfe79df3 --- /dev/null +++ b/Makefile @@ -0,0 +1,72 @@ + +help: + @echo 'Zappa Make Targets' + @echo '-----------------------' + @echo 'These targets are aimed at making development, testing, and building easier' + @echo '' + @echo 'Setup' + @echo 'make clean: Remove the built files, local caches, mypy and coverage information' + @echo 'make requirements: Generate requirements from requirements.in and install them to the current environment' + @echo 'make build: Build the source and wheel' + @echo '' + @echo 'Linting' + @echo 'make flake: Flake8 checking' + @echo 'make mypy: Run static type checking for zappa and tests directories' + @echo 'make isort: Sort imports' + @echo 'make black: Format project code according to Black convention' + @echo '' + @echo 'Testing' + @echo 'make tests: Run all project tests. Additional make targets exist for subsets of the tests. Inspect the Makefile for details' + +.PHONY: clean requirements build flake mypy isort black tests + +clean: + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + rm -rf .mypy_cache dist build *.egg-info + rm -f .coverage + +requirements: + ./requirements.sh + pip install -r requirements.txt + pip install -r test_requirements.txt + +build: clean requirements-install + python setup.py sdist + python setup.py bdist_wheel + +mypy: + mypy --show-error-codes --pretty --ignore-missing-imports --strict zappa tests + +black: + black zappa tests + +black-check: + black zappa tests --check + +isort: + isort --recursive . + +flake: + flake8 zappa --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 zappa --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + +test-docs: + nosetests tests/tests_docs.py --with-coverage --cover-package=zappa --with-timer + +test-handler: + nosetests tests/test_handler.py --with-coverage --cover-package=zappa --with-timer + +test-middleware: + nosetests tests/tests_middleware.py --with-coverage --cover-package=zappa --with-timer + +test-placebo: + nosetests tests/tests_placebo.py --with-coverage --cover-package=zappa --with-timer + +test-async: + nosetests tests/tests_async.py --with-coverage --cover-package=zappa --with-timer + +test-general: + nosetests tests/tests.py --with-coverage --cover-package=zappa --with-timer + +tests: clean test-docs test-handler test-middleware test-placebo test-async test-general diff --git a/requirements.sh b/requirements.sh index 26e9c4772..195992c2d 100755 --- a/requirements.sh +++ b/requirements.sh @@ -7,6 +7,7 @@ if [ "$1" == "--upgrade" ]; then ARGS="-U" fi +pip install -U pip-tools pip-compile ${ARGS} -o test_requirements.txt requirements.in test_requirements.in cp test_requirements.txt requirements.txt pip-compile -o requirements.txt requirements.in diff --git a/test_requirements.in b/test_requirements.in index 359301c31..e0ec2d3de 100644 --- a/test_requirements.in +++ b/test_requirements.in @@ -1,10 +1,13 @@ +black +boto3-stubs coveralls Django +django-stubs flake8 Flask mock +mypy nose nose-timer placebo isort - diff --git a/test_requirements.txt b/test_requirements.txt index 0a550c7e9..47a67ce65 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -4,10 +4,16 @@ # # pip-compile --output-file=test_requirements.txt requirements.in test_requirements.in # +appdirs==1.4.4 + # via black argcomplete==1.12.2 # via -r requirements.in asgiref==3.3.1 # via django +black==21.5b1 + # via -r test_requirements.in +boto3-stubs==1.17.78 + # via -r test_requirements.in boto3==1.17.44 # via # -r requirements.in @@ -24,6 +30,7 @@ chardet==4.0.0 # via requests click==7.1.2 # via + # black # cfn-flip # flask # kappa @@ -32,8 +39,15 @@ coverage==5.5 # via coveralls coveralls==3.0.1 # via -r test_requirements.in -django==3.1.7 +django-stubs-ext==0.2.0 + # via django-stubs +django-stubs==1.8.0 # via -r test_requirements.in +django==3.1.7 + # via + # -r test_requirements.in + # django-stubs + # django-stubs-ext docopt==0.6.2 # via coveralls durationpy==0.5 @@ -48,6 +62,8 @@ hjson==3.0.2 # via -r requirements.in idna==2.10 # via requests +isort==5.8.0 + # via -r test_requirements.in itsdangerous==1.1.0 # via flask jinja2==2.11.3 @@ -65,12 +81,22 @@ mccabe==0.6.1 # via flake8 mock==4.0.3 # via -r test_requirements.in +mypy-extensions==0.4.3 + # via + # black + # mypy +mypy==0.812 + # via + # -r test_requirements.in + # django-stubs nose-timer==1.0.1 # via -r test_requirements.in nose==1.3.7 # via # -r test_requirements.in # nose-timer +pathspec==0.8.1 + # via black pep517==0.10.0 # via pip-tools pip-tools==6.0.1 @@ -96,6 +122,8 @@ pyyaml==5.4.1 # -r requirements.in # cfn-flip # kappa +regex==2021.4.4 + # via black requests==2.25.1 # via # -r requirements.in @@ -114,11 +142,18 @@ text-unidecode==1.3 toml==0.10.2 # via # -r requirements.in + # black # pep517 tqdm==4.59.0 # via -r requirements.in troposphere==2.7.0 # via -r requirements.in +typed-ast==1.4.3 + # via mypy +typing-extensions==3.10.0.0 + # via + # django-stubs + # mypy urllib3==1.26.4 # via # botocore