Skip to content

Commit

Permalink
Review/Cleanup of master for release prep (#1147)
Browse files Browse the repository at this point in the history
* 🔧 update for case where expected metadata for given package does not contain 'releases'

* :penicl: add warning for case where expected `package_version` is not found.

* 🔧 change pipenv req to version greater than previously reported problem version.

* 🙈 Add `Pipfile.lock` to `.gitignore` (When supporting multiple versions of python with pipenv don't include the lock file.

* 🔧 fix pipenv version restriction.

* 🎨 run black on `core.py`

* 🎨 fix flake8, run black

* 🔧 adjust caching (requirements.txt no longer used.

* 🐛 fix Pipfile typo

* 🔥 The python3.6 runtime is deprecated by aws (July 18, 2022 [phase-1], Aug 17, 2022 [phase-2]) remove from tests for next release candidate

* 🎨 run black
🔧 update black check command.

* 🎨 run isort

* 📝 change version 0.54.1 -> 0.55.1
🔥 remove 3.6 from SUPPORTED_VERSIONS

* 🔥 remove 3.6 support

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.
🔥 remove 3.6 support from README

* 🔀 merge with `0.54.2-release` branch to apply 3.9 support documentation updates.

* ⏪️revert __version__ back to available pypi version

Without a pypi available release the `test_slim_handler` testcase fails.

```
ERROR: No matching distribution found for zappa==0.55.1
E...................
======================================================================
ERROR: test_slim_handler (tests.tests.TestZappa)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/Zappa/Zappa/tests/tests.py", line 2211, in test_slim_handler
    zappa_cli.create_package()
  File "/home/runner/work/Zappa/Zappa/zappa/cli.py", line 2430, in create_package
    venv=self.zappa.create_handler_venv(),
  File "/home/runner/work/Zappa/Zappa/zappa/core.py", line 494, in create_handler_venv
    raise EnvironmentError("Pypi lookup failed")
OSError: Pypi lookup failed
-------------------- >> begin captured stdout << ---------------------
```

* 📝 update CHANGELOG with committed changes since last release (5b6e241)

* 🔥 remove 3.6 from docs

* 🔧 address review comments

* ✨ change release to 0.55.1

* ♻️ Update to allow specification of the latest pypi version for `test_slim_handler()`

* ✅ update `test_slim_handler()` so that lastest pypi version is *not* hardcoded (get from "git tags" result)

* 🎨 run black/isort

* 🔧 attempt to update github action to retrieve the latest tags.

* 🔧 fix bad ci command definition

* 📝 created and added issue for python3.6 support removal.

* ✨ add `python_requires` to setup().

* 📝 fix issue #900

* 📝 add link to https://slackautoinviter.herokuapp.com to join slack. (the zappateam.slack may be private?)

* 🔥 remove `future` (past) requirements basestring usage, replacing with isinstance(x, str)
🔧 change usage of utcnow() -> datetime.datetime.now(datetime.timezone.utc)

* 🔥 Remove 'futures' package requirement (#826)

* 📝 fix issue #900

* 🔥 remove unnecessary __future__ import
🔧 Start versioning at 0; 0.55.1 -> 0.55.0

* 🎨 fix flake8

* 🐛 fix cd.yaml to only run on push of tag meeting the release tag criteria. (#1152)

* 📝 add 1152 to CHANGELOG
  • Loading branch information
monkut authored Jul 27, 2022
1 parent a1e842c commit fff5ed8
Show file tree
Hide file tree
Showing 33 changed files with 602 additions and 1,581 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--- Provide a general summary of the issue in the Title above -->
## Context
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.6/3.7/3.8 -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.7/3.8/3.9 -->

## Expected Behavior
<!--- Tell us what should happen -->
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Before you submit this PR, please make sure that you meet these criteria:
* Did you **make sure this code actually works on Lambda**, as well as locally?
* Did you test this code with all of **Python 3.6**, **Python 3.7** and **Python 3.8** ?
* Did you test this code with all of **Python 3.7**, **Python 3.8** and **Python 3.9** ?
* Does this commit ONLY relate to the issue at hand and have your linter shit all over the code?
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: CD

on: # yamllint disable-line rule:truthy
create:
# From documentation:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
# on.push.tags: If you define only tags/tags-ignore or only branches/branches-ignore, the workflow won't run for events affecting the undefined Git ref.
#
# This workflow will only run when a tag matching the criteria is pushed
push:
tags: ["v?[0-9]+.[0-9]+.[0-9]+"]

jobs:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9]
python: [3.7, 3.8, 3.9]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
Expand All @@ -22,8 +22,10 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
key: ${{ runner.os }}-pip${{ matrix.python }}-${{ hashFiles('Pipfile') }}
restore-keys: ${{ runner.os }}-pip${{ matrix.python }}-
- name: make sure we have version tags
run: git fetch --unshallow --tags
- name: Setup Virtualenv
run: python -m venv .venv
- name: Install
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*~
*.zip
Pipfile.lock

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Zappa Changelog

## 0.55.0
* Fix "cd workflow fired event outside of the create tags event" (#1152)
* Remove 'futures' package requirement (#826,#808)
* Remove function invoke command does not need quotes around function (#900)
* Add python_requires to setup.py (#1111)
* Remove python 3.6 support (#1151)
* Update handler to be global if INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT=True (#1096)
* Fix async invocation in Python 3 (#1006)
* Drastically reduce cold start times by calling LambdaHandler externally (#982)
* Support Newest Manylinux Version for dependencies (#1083)
* Decode zappa invoke output regardless of --no-color option (#1069)
* Convert project to using 'pipenv' to manage dependencies (#1077)
* Ensure unique scheduled event names (#1080)
* Check isort in CI (#1078)
* Use 'black' everywhere (#1076)
* Update setup.py (#1050)

## 0.54.2
* Update documentation to reflect python 3.9 support (#1137)

## 0.54.1
* Increase Lambda client read timeout to 15m (#1065)
* Unpin `Werkzeug` from `v0.x` (#1067)
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ clean:
rm -f .coverage

requirements:
pip install pipenv==2021.11.09
pip install pipenv>2021.11.15
pipenv lock
pipenv sync --dev

Expand All @@ -39,10 +39,10 @@ mypy:
mypy --show-error-codes --pretty --ignore-missing-imports --strict zappa tests

black:
black .
black --line-length 127 .

black-check:
black . --check
black --line-length 127 . --check
@echo "If this fails, simply run: make black"

isort:
Expand All @@ -53,7 +53,7 @@ isort-check:

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
flake8 zappa --count --exit-zero --max-complexity=55 --max-line-length=127 --statistics --ignore F403,F405,E203,E231,E252,W503

test-docs:
nosetests tests/tests_docs.py --with-coverage --cover-package=zappa --with-timer
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ mock = "*"
mypy = "*"
nose = "*"
nose-timer = "*"
pipenv = "==2021.11.09"
pipenv = ">2021.11.15"
packaging = "*"

[packages]
argcomplete = "*"
boto3 = ">=1.17.28"
durationpy = "*"
future = "*"
hjson = "*"
jmespath = "*"
kappa = "==0.6.0"
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ __Awesome!__

## Installation and Configuration

_Before you begin, make sure you are running Python 3.6/3.7/3.8 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._
_Before you begin, make sure you are running Python 3.7/3.8/3.9 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._

**Zappa** can easily be installed through pip, like so:

Expand Down Expand Up @@ -394,11 +394,11 @@ You can execute any function in your application directly at any time by using t

For instance, suppose you have a basic application in a file called "my_app.py", and you want to invoke a function in it called "my_function". Once your application is deployed, you can invoke that function at any time by calling:

$ zappa invoke production 'my_app.my_function'
$ zappa invoke production my_app.my_function

Any remote print statements made and the value the function returned will then be printed to your local console. **Nifty!**

You can also invoke interpretable Python 3.6/3.7/3.8 strings directly by using `--raw`, like so:
You can also invoke interpretable Python 3.7/3.8/3.9 strings directly by using `--raw`, like so:

$ zappa invoke production "print(1 + 2 + 3)" --raw

Expand Down Expand Up @@ -929,7 +929,7 @@ to change Zappa's behavior. Use these at your own risk!
"role_name": "MyLambdaRole", // Name of Zappa execution role. Default <project_name>-<env>-ZappaExecutionRole. To use a different, pre-existing policy, you must also set manage_roles to false.
"role_arn": "arn:aws:iam::12345:role/app-ZappaLambdaExecutionRole", // ARN of Zappa execution role. Default to None. To use a different, pre-existing policy, you must also set manage_roles to false. This overrides role_name. Use with temporary credentials via GetFederationToken.
"route53_enabled": true, // Have Zappa update your Route53 Hosted Zones when certifying with a custom domain. Default true.
"runtime": "python3.6", // Python runtime to use on Lambda. Can be one of "python3.6", "python3.7" or "python3.8". Defaults to whatever the current Python being used is.
"runtime": "python3.9", // Python runtime to use on Lambda. Can be one of "python3.7", "python3.8", or "python3.9". Defaults to whatever the current Python being used is.
"s3_bucket": "dev-bucket", // Zappa zip bucket,
"slim_handler": false, // Useful if project >50M. Set true to just upload a small handler to Lambda and load actual project from S3 at runtime. Default false.
"settings_file": "~/Projects/MyApp/settings/dev_settings.py", // Server side settings file location,
Expand Down Expand Up @@ -1538,6 +1538,7 @@ If you are adding a non-trivial amount of new code, please include a functioning
Please include the GitHub issue or pull request URL that has discussion related to your changes as a comment in the code ([example](https://github.com/zappa/Zappa/blob/fae2925431b820eaedf088a632022e4120a29f89/zappa/zappa.py#L241-L243)). This greatly helps for project maintainability, as it allows us to trace back use cases and explain decision making. Similarly, please make sure that you meet all of the requirements listed in the [pull request template](https://raw.githubusercontent.com/zappa/Zappa/master/.github/PULL_REQUEST_TEMPLATE.md).

Please feel free to work on any open ticket, especially any ticket marked with the "help-wanted" label. If you get stuck or want to discuss an issue further, please join [our Slack channel](https://zappateam.slack.com/), where you'll find a community of smart and interesting people working dilligently on hard problems.
[Zappa Slack Auto Invite](https://slackautoinviter.herokuapp.com)

Zappa does not intend to conform to PEP8, isolate your commits so that changes to functionality with changes made by your linter.

Expand Down
27 changes: 6 additions & 21 deletions example/authmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,10 @@ def _addMethod(self, effect, verb, resource, conditions):
the internal list contains a resource ARN and a condition statement. The condition
statement can be null."""
if verb != "*" and not hasattr(HttpVerb, verb):
raise NameError(
"Invalid HTTP verb " + verb + ". Allowed verbs in HttpVerb class"
)
raise NameError("Invalid HTTP verb " + verb + ". Allowed verbs in HttpVerb class")
resourcePattern = re.compile(self.pathRegex)
if not resourcePattern.match(resource):
raise NameError(
"Invalid resource path: "
+ resource
+ ". Path should match "
+ self.pathRegex
)
raise NameError("Invalid resource path: " + resource + ". Path should match " + self.pathRegex)

if resource[:1] == "/":
resource = resource[1:]
Expand All @@ -137,13 +130,9 @@ def _addMethod(self, effect, verb, resource, conditions):
)

if effect.lower() == "allow":
self.allowMethods.append(
{"resourceArn": resourceArn, "conditions": conditions}
)
self.allowMethods.append({"resourceArn": resourceArn, "conditions": conditions})
elif effect.lower() == "deny":
self.denyMethods.append(
{"resourceArn": resourceArn, "conditions": conditions}
)
self.denyMethods.append({"resourceArn": resourceArn, "conditions": conditions})

def _getEmptyStatement(self, effect):
"""Returns an empty statement object prepopulated with the correct action and the
Expand Down Expand Up @@ -222,11 +211,7 @@ def build(self):
"policyDocument": {"Version": self.version, "Statement": []},
}

policy["policyDocument"]["Statement"].extend(
self._getStatementForEffect("Allow", self.allowMethods)
)
policy["policyDocument"]["Statement"].extend(
self._getStatementForEffect("Deny", self.denyMethods)
)
policy["policyDocument"]["Statement"].extend(self._getStatementForEffect("Allow", self.allowMethods))
policy["policyDocument"]["Statement"].extend(self._getStatementForEffect("Deny", self.denyMethods))

return policy
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
pipfile = ConfigParser()
pipfile.read(Path(__file__).parent.resolve() / "Pipfile")
required = [
"{}{}".format(name, version.strip('"')) if version != '"*"' else name
for name, version in pipfile["packages"].items()
"{}{}".format(name, version.strip('"')) if version != '"*"' else name for name, version in pipfile["packages"].items()
]
test_required = [
"{}{}".format(name, version.strip('"')) if version != '"*"' else name
for name, version in pipfile["dev-packages"].items()
"{}{}".format(name, version.strip('"')) if version != '"*"' else name for name, version in pipfile["dev-packages"].items()
]

setup(
name="zappa",
version=__version__,
packages=["zappa"],
install_requires=required,
python_requires=">=3.7, <3.10",
tests_require=test_required,
test_suite="nose.collector",
include_package_data=True,
Expand All @@ -46,7 +45,6 @@
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
4 changes: 1 addition & 3 deletions tests/data/test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@


def greet():
print(
"There is more stupidity than hydrogen in the universe, and it has a longer shelf life."
)
print("There is more stupidity than hydrogen in the universe, and it has a longer shelf life.")
4 changes: 1 addition & 3 deletions tests/test_bot_exception_handler_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
LOG_LEVEL = "DEBUG"
PROJECT_NAME = "wsgi_script_name_settings"
COGNITO_TRIGGER_MAPPING = {}
AWS_BOT_EVENT_MAPPING = {
"intent-name:DialogCodeHook": "tests.test_handler.raises_exception"
}
AWS_BOT_EVENT_MAPPING = {"intent-name:DialogCodeHook": "tests.test_handler.raises_exception"}
EXCEPTION_HANDLER = "tests.test_handler.mocked_exception_handler"
4 changes: 1 addition & 3 deletions tests/test_bot_handler_being_triggered.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@
LOG_LEVEL = "DEBUG"
PROJECT_NAME = "wsgi_script_name_settings"
COGNITO_TRIGGER_MAPPING = {}
AWS_BOT_EVENT_MAPPING = {
"intent-name:DialogCodeHook": "tests.test_handler.handle_bot_intent"
}
AWS_BOT_EVENT_MAPPING = {"intent-name:DialogCodeHook": "tests.test_handler.handle_bot_intent"}
3 changes: 0 additions & 3 deletions tests/test_event_script_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import print_function


def handler_for_events(event, context):
print("Event:", event)
return True
4 changes: 1 addition & 3 deletions tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ def test_run_function(self):
self.assertEqual(LambdaHandler.run_function(one_arg, "e", "c"), "e")
self.assertEqual(LambdaHandler.run_function(two_args, "e", "c"), ("e", "c"))
self.assertEqual(LambdaHandler.run_function(var_args, "e", "c"), ("e", "c"))
self.assertEqual(
LambdaHandler.run_function(var_args_with_one, "e", "c"), ("e", "c")
)
self.assertEqual(LambdaHandler.run_function(var_args_with_one, "e", "c"), ("e", "c"))

try:
LambdaHandler.run_function(unsupported, "e", "c")
Expand Down
Loading

0 comments on commit fff5ed8

Please sign in to comment.