Skip to content

Commit

Permalink
Merge pull request #5 from tackle-io/zappa-master
Browse files Browse the repository at this point in the history
Pull changes from Zappa/Zappa into our fork
  • Loading branch information
andrewphahn authored Nov 24, 2021
2 parents e758d16 + b749528 commit 0adae96
Show file tree
Hide file tree
Showing 65 changed files with 6,765 additions and 4,582 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on: # yamllint disable-line rule:truthy
pull_request:
branches: ["master"]
push:
branches: ["master"]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip${{ matrix.python }}-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-pip${{ matrix.python }}-
- name: Setup Virtualenv
run: python -m venv .venv
- name: Install
run: source .venv/bin/activate && make requirements && python setup.py install
- name: Lint
run: source .venv/bin/activate && make flake black-check isort-check
- name: Test
run: source .venv/bin/activate && make tests
- name: Upload Coverage
run: .venv/bin/coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: py${{ matrix.python }}
COVERALLS_PARALLEL: true

coverage:
needs: test
runs-on: ubuntu-20.04
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Finalise Coverage
run: pip3 install --upgrade coveralls && coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Zappa Changelog

## 0.54.1
* Increase Lambda client read timeout to 15m (#1065)
* Unpin `Werkzeug` from `v0.x` (#1067)

## 0.54.0
* Pin troposphere version and update to 3.x (#1029)
* Relax stage name restrictions when not using apigateway (#993)
* Wait for lambda to become active during deploy/update (#992)
* add support for Python 3.9 (#1026)

## 0.53.0
* Deprecated ACME v1 for Lets Encrypt
* Global black formatting
* Update & deploy using a docker container
* See [blog post](https://ianwhitestone.work/zappa-serverless-docker/) for more details on the current functionality and how it works
* See [PR](https://github.com/zappa/Zappa/pull/967) or [original issue](https://github.com/Miserlou/Zappa/issues/2188) for discussion around what is currently supported & next steps

## 0.52.0
* Remove dateutil version restriction
* Fix failed downloads of wheel packages with non-alphanumeric characters
Expand Down
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Contributing to Zappa
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
We actively welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Issue that pull request!

## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using Github's [issues](https://github.com/zappa/Zappa/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/zappa/Zappa/issues/new); it's that easy!

## Write bug reports with detail, background, and sample code
Here are two great examples:
- [http://stackoverflow.com/q/12488905/180626](http://stackoverflow.com/q/12488905/180626)
- [http://www.openradar.me/11905408](http://www.openradar.me/11905408)

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

People *love* thorough bug reports, not even kidding.

## License
By contributing, you agree that your contributions will be licensed under its MIT License.

## References
This document was adapted from the basic template for contributing guideliens by @briandk
[Contributing to Transcriptase](https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62). The template itself is based on the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md)
76 changes: 76 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

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:
pip install pipenv==2021.11.09
pipenv lock
pipenv sync --dev

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 .

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

isort:
isort . --profile=black

isort-check:
isort --check . --profile=black

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
48 changes: 48 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
black = "*"
boto3-stubs = "*"
coveralls = "*"
Django = "<4"
django-stubs = "*"
flake8 = "*"
Flask = "*"
isort = "*"
mock = "*"
mypy = "*"
nose = "*"
nose-timer = "*"
pipenv = "==2021.11.09"

[packages]
argcomplete = "*"
boto3 = ">=1.17.28"
durationpy = "*"
future = "*"
hjson = "*"
jmespath = "*"
kappa = "==0.6.0"
pip = ">=9.0.1"
# Workaround until tests are updated to work with 'placebo' 0.10
# Move to 'dev-packages' when unpinned
placebo = "<0.10"
python-dateutil = "*"
python-slugify = "*"
PyYAML = "*"
# previous versions don't work with urllib3 1.24
requests = ">=2.20.0"
six = "*"
toml = "*"
tqdm = "*"
troposphere = ">=3.0"
Werkzeug = "*"
wheel = "*"
wsgi-request-logger = "*"

[pipenv]
# Required for 'black' since all of its release tags contain 'b'
allow_prereleases = true
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Zappa - Serverless Python

[![Build Status](https://travis-ci.org/zappa/Zappa.svg)](https://travis-ci.org/zappa/Zappa)
[![CI](https://github.com/zappa/Zappa/actions/workflows/ci.yaml/badge.svg?branch=master&event=push)](https://github.com/zappa/Zappa/actions/workflows/ci.yaml)
[![Coverage](https://img.shields.io/coveralls/zappa/Zappa.svg)](https://coveralls.io/github/zappa/Zappa)
[![PyPI](https://img.shields.io/pypi/v/Zappa.svg)](https://pypi.python.org/pypi/zappa)
[![Slack](https://img.shields.io/badge/chat-slack-ff69b4.svg)](https://zappateam.slack.com/)
Expand All @@ -21,6 +21,7 @@
- [Basic Usage](#basic-usage)
- [Initial Deployments](#initial-deployments)
- [Updates](#updates)
- [Docker Workflows](#docker-workflows)
- [Rollback](#rollback)
- [Scheduling](#scheduling)
- [Advanced Scheduling](#advanced-scheduling)
Expand Down Expand Up @@ -216,6 +217,10 @@ If your application has already been deployed and you only need to upload new Py

This creates a new archive, uploads it to S3 and updates the Lambda function to use the new code, but doesn't touch the API Gateway routes.

#### Docker Workflows

In [version 0.53.0](https://github.com/zappa/Zappa/blob/master/CHANGELOG.md), support was added to deploy & update Lambda functions using Docker. Refer to [the blog post](https://ianwhitestone.work/zappa-serverless-docker/) for more details about how to leverage this functionality, and when you may want to.

### Rollback

You can also `rollback` the deployed code to a previous version by supplying the number of revisions to return to. For instance, to rollback to the version deployed 3 versions ago:
Expand Down Expand Up @@ -415,8 +420,6 @@ Commands which require direct user input, such as `createsuperuser`, should be [

For more Django integration, take a look at the [zappa-django-utils](https://github.com/Miserlou/zappa-django-utils) project.

_(Please note that commands which take over 30 seconds to execute may time-out preventing output from being returned - but the command may continue to run. See [this related issue](https://github.com/Miserlou/Zappa/issues/205#issuecomment-236391248) for a work-around.)_

### SSL Certification

Zappa can be deployed to custom domain names and subdomains with custom SSL certificates, Let's Encrypt certificates, and [AWS Certificate Manager](https://aws.amazon.com/certificate-manager/) (ACM) certificates.
Expand Down
11 changes: 7 additions & 4 deletions example/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import logging

from flask import Flask

app = Flask(__name__)
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

@app.route('/', methods=['GET', 'POST'])

@app.route("/", methods=["GET", "POST"])
def lambda_handler(event=None, context=None):
logger.info('Lambda function invoked index()')
logger.info("Lambda function invoked index()")

return "Flask says Hello!!"

return 'Flask says Hello!!'

if __name__ == '__main__':
if __name__ == "__main__":
app.run(debug=True)
Loading

0 comments on commit 0adae96

Please sign in to comment.