From 11656d4c813f2e03e72c5373af94b35cd75f374d Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sat, 22 May 2021 15:24:05 -0400 Subject: [PATCH 1/9] adding makefile --- Makefile | 69 +++++++++++++++++++++++++++++++++++++++++++ test_requirements.in | 5 +++- test_requirements.txt | 37 ++++++++++++++++++++++- 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..7d36d00d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ + +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 + +isort: + isort --recursive . + +flake: + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --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/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 From 21c3b7ad5562ac2b24c244a49bb090f518f47c7c Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sat, 22 May 2021 15:30:54 -0400 Subject: [PATCH 2/9] limiting flake to zappa --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7d36d00d2..93e310736 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ isort: isort --recursive . flake: - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + 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 From 5e1ec4837709a29dd4ace4cc16afcbc96ecfdd6c Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 08:41:11 -0400 Subject: [PATCH 3/9] travis uses make commands for consistency --- .travis.yml | 11 ++++++----- Makefile | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index fef1c93f2..8d87b5266 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,10 @@ python: - "3.7" - "3.8" dist: xenial +addons: + apt: + packages: + - cmake # command to install dependencies cache: - pip @@ -18,12 +22,9 @@ env: - 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 flake script: - - nosetests $TESTCASE --with-coverage --cover-package=zappa --with-timer + - make test-case # - coverage combine --append after_success: coveralls diff --git a/Makefile b/Makefile index 93e310736..7d369d528 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ mypy: black: black zappa tests +black-check: + black zappa tests --check + isort: isort --recursive . @@ -66,4 +69,7 @@ test-async: test-general: nosetests tests/tests.py --with-coverage --cover-package=zappa --with-timer +test-case: + nosetests ${TESTCASE} --with-coverage --cover-package=zappa --with-timer + tests: clean test-docs test-handler test-middleware test-placebo test-async test-general From c2916ac94ae2ff07b227ad75cc0f722b322a801a Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 08:49:33 -0400 Subject: [PATCH 4/9] using job stages for travis --- .travis.yml | 30 ++++++++++++++++-------------- Makefile | 3 --- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d87b5266..dae26eede 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,20 +12,22 @@ addons: 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: - - make flake -script: - - make test-case - # - coverage combine --append + - make requirements + - python setup.py install" + +jobs: + include: + - stage: lint + script: make flake + - stage: lint + script: make black-check + - script: make test-docs + - script: make test-handler + - script: make test-middleware + - script: make test-placebo + - script: make test-async + - script: make test-general + after_success: coveralls notifications: diff --git a/Makefile b/Makefile index 7d369d528..1cfe79df3 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,4 @@ test-async: test-general: nosetests tests/tests.py --with-coverage --cover-package=zappa --with-timer -test-case: - nosetests ${TESTCASE} --with-coverage --cover-package=zappa --with-timer - tests: clean test-docs test-handler test-middleware test-placebo test-async test-general From 5cb5a79cec719c248206dfe20a7101152e856382 Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 08:51:44 -0400 Subject: [PATCH 5/9] moving black check to other PR --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dae26eede..9e2d515a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,6 @@ jobs: include: - stage: lint script: make flake - - stage: lint - script: make black-check - script: make test-docs - script: make test-handler - script: make test-middleware From 687543e271d54a5b748119172a75b968d5d3456f Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 14:06:19 -0400 Subject: [PATCH 6/9] install pip-tools --- requirements.sh | 1 + 1 file changed, 1 insertion(+) 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 From 24d0a4884e42be42f809a0c841796f01f2979793 Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 14:11:26 -0400 Subject: [PATCH 7/9] missing a quote mark --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e2d515a2..48e8929de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ cache: - pip install: - make requirements - - python setup.py install" + - python setup.py install jobs: include: From 3e2fa9d5e6e4a6856917fbed1f86b0a3427c22e5 Mon Sep 17 00:00:00 2001 From: Matthew Crowson Date: Sun, 23 May 2021 14:22:36 -0400 Subject: [PATCH 8/9] going back to single script key --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 48e8929de..2f50f47e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,16 +15,14 @@ install: - make requirements - python setup.py install -jobs: - include: - - stage: lint - script: make flake - - script: make test-docs - - script: make test-handler - - script: make test-middleware - - script: make test-placebo - - script: make test-async - - script: make test-general +script: + - make flake + - make test-docs + - make test-handler + - make test-middleware + - make test-placebo + - make test-async + - make test-general after_success: coveralls From f4723a4fadf092cd963907d95c401aaae8494681 Mon Sep 17 00:00:00 2001 From: jiho lee Date: Tue, 23 Mar 2021 07:20:58 +0900 Subject: [PATCH 9/9] Fix: cli zappa github url adding makefile limiting flake to zappa travis uses make commands for consistency using job stages for travis use v2 LE endpoint moving black check to other PR install pip-tools missing a quote mark going back to single script key --- .travis.yml | 31 +++++++++---------- Makefile | 72 +++++++++++++++++++++++++++++++++++++++++++ requirements.sh | 1 + test_requirements.in | 5 ++- test_requirements.txt | 37 +++++++++++++++++++++- zappa/cli.py | 10 +++--- zappa/letsencrypt.py | 2 +- 7 files changed, 134 insertions(+), 24 deletions(-) create mode 100644 Makefile 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 diff --git a/zappa/cli.py b/zappa/cli.py index 1e6ad9290..9b3361c4e 100755 --- a/zappa/cli.py +++ b/zappa/cli.py @@ -715,7 +715,7 @@ def deploy(self, source_zip=None): click.style("Exception reported by AWS:", bold=True) + format(ce) + '\n' + "To fix this, see here: " + click.style( - "https://github.com/Miserlou/Zappa#custom-aws-iam-roles-and-policies-for-deployment", + "https://github.com/Zappa/Zappa#custom-aws-iam-roles-and-policies-for-deployment", bold=True) + '\n') @@ -902,7 +902,7 @@ def update(self, source_zip=None, no_upload=False): click.echo("You may " + click.style("lack the necessary AWS permissions", bold=True) + " to automatically manage a Zappa execution role.") click.echo("To fix this, see here: " + - click.style("https://github.com/Miserlou/Zappa#custom-aws-iam-roles-and-policies-for-deployment", + click.style("https://github.com/Zappa/Zappa#custom-aws-iam-roles-and-policies-for-deployment", bold=True)) sys.exit(-1) @@ -1797,7 +1797,7 @@ def init(self, settings_file="zappa_settings.json"): click.echo(click.style("\t$ zappa update %s" % env, bold=True)) click.echo("\nTo learn more, check out our project page on " + click.style("GitHub", bold=True) + - " here: " + click.style("https://github.com/Miserlou/Zappa", fg="cyan", bold=True)) + " here: " + click.style("https://github.com/Zappa/Zappa", fg="cyan", bold=True)) click.echo("and stop by our " + click.style("Slack", bold=True) + " channel here: " + click.style("https://zappateam.slack.com", fg="cyan", bold=True)) click.echo("\nEnjoy!,") @@ -1997,7 +1997,7 @@ def check_for_update(self): " A new version of " + click.style("Zappa", bold=True) + " is available!") click.echo("Upgrade with: " + click.style("pip install zappa --upgrade", bold=True)) click.echo("Visit the project page on GitHub to see the latest changes: " + - click.style("https://github.com/Miserlou/Zappa", bold=True)) + click.style("https://github.com/Zappa/Zappa", bold=True)) except Exception as e: # pragma: no cover print(e) return @@ -2749,7 +2749,7 @@ def shamelessly_promote(): "? Found a " + click.style("bug", fg='green', bold=True) + "? Let us " + click.style("know", fg='green', bold=True) + "! :D") click.echo("File bug reports on " + click.style("GitHub", bold=True) + " here: " - + click.style("https://github.com/Miserlou/Zappa", fg='cyan', bold=True)) + + click.style("https://github.com/Zappa/Zappa", fg='cyan', bold=True)) click.echo("And join our " + click.style("Slack", bold=True) + " channel here: " + click.style("https://zappateam.slack.com", fg='cyan', bold=True)) click.echo("Love!,") diff --git a/zappa/letsencrypt.py b/zappa/letsencrypt.py index 382c0ba93..696496466 100755 --- a/zappa/letsencrypt.py +++ b/zappa/letsencrypt.py @@ -34,7 +34,7 @@ # DEFAULT_CA = "https://acme-staging.api.letsencrypt.org" # Production -DEFAULT_CA = "https://acme-v01.api.letsencrypt.org" +DEFAULT_CA = "https://acme-v02.api.letsencrypt.org" LOGGER = logging.getLogger(__name__) LOGGER.addHandler(logging.StreamHandler())