Skip to content

Commit e315e25

Browse files
committed
first commit
0 parents  commit e315e25

38 files changed

+1231
-0
lines changed

.env.example

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# shellcheck disable=SC2034
3+
4+
####################
5+
# deployment
6+
# needed for bin scripts to work
7+
####################
8+
# Update these
9+
ACCOUNT_ID_AWS=123456789
10+
REGION=eu-west-2
11+
ENVIRONMENT=prod
12+
13+
# needed for bin scripts but can be left as defaults
14+
export SKIP_BUNDLE=0
15+
# export SKIP_BUNDLE=1
16+
LAMBDA_FUNCTION_NAME="HttpServer"
17+
LAMBDA_ZIP_PATH="dist/$(basename "$PWD").zip"
18+
LAMBDA_ZIP=terraform/$LAMBDA_ZIP_PATH
19+
TRUSTED_CIDRS='["0.0.0.0/0"]'
20+
21+
22+
####################
23+
# local development
24+
####################
25+
export APP_CONFIG_FILE=$PWD/config/development.py

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
*.sublime-*
2+
3+
.pytest_cache
4+
5+
# Byte-compiled / optimized / DLL files
6+
__pycache__/
7+
*.py[cod]
8+
*$py.class
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
env/
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
# lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*,cover
50+
.hypothesis/
51+
junit.xml
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
61+
# Flask stuff:
62+
instance/
63+
.webassets-cache
64+
65+
# Scrapy stuff:
66+
.scrapy
67+
68+
# Sphinx documentation
69+
docs/_build/
70+
71+
# PyBuilder
72+
target/
73+
74+
# IPython Notebook
75+
.ipynb_checkpoints
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# dotenv
84+
.env
85+
.env.deploy
86+
87+
# virtualenv
88+
venv/
89+
ENV/
90+
91+
# Spyder project settings
92+
.spyderproject
93+
94+
# Rope project settings
95+
.ropeproject
96+
97+
# Jetbrains IDE
98+
.idea
99+
100+
# ZSH env
101+
.autoenv.zsh
102+
103+
# Created by https://www.gitignore.io/api/terraform
104+
105+
### Terraform ###
106+
# Terraform - https://terraform.io/
107+
.terraform
108+
terraform.tfstate
109+
terraform.tfstate.backup
110+
*.tfvars
111+
112+
### Terraform Patch ###
113+
# End of https://www.gitignore.io/api/terraform

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
- repo: https://github.com/kintoandar/pre-commit.git
2+
sha: v2.1.0
3+
hooks:
4+
- id: terraform_validate
5+
6+
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
7+
sha: v1.5.0
8+
hooks:
9+
- id: terraform_fmt
10+
11+
- repo: git://github.com/pre-commit/pre-commit-hooks
12+
sha: 46251c9523506b68419aefdf5ff6ff2fbc4506a4
13+
hooks:
14+
- id: autopep8-wrapper
15+
- id: check-added-large-files
16+
- id: check-case-conflict
17+
- id: check-json
18+
- id: check-merge-conflict
19+
- id: check-yaml
20+
- id: debug-statements
21+
- id: detect-private-key
22+
- id: double-quote-string-fixer
23+
- id: end-of-file-fixer
24+
- id: flake8
25+
args: ['--exclude=migrations/*']
26+
- id: forbid-new-submodules
27+
- id: requirements-txt-fixer
28+
- id: trailing-whitespace
29+
30+
- repo: https://github.com/detailyang/pre-commit-shell.git
31+
sha: 1.0.2
32+
hooks:
33+
- id: shell-lint
34+
files: bin\/(?!waitforit)

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
sudo: required
2+
language: python
3+
env:
4+
global:
5+
- TERRAFORM_VERSION=0.11.6
6+
7+
python:
8+
- "3.6"
9+
10+
addons:
11+
apt:
12+
sources:
13+
- debian-sid
14+
packages:
15+
- shellcheck
16+
17+
before_script:
18+
- >
19+
travis_retry curl
20+
"https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
21+
> /tmp/terraform.zip
22+
- sudo unzip /tmp/terraform.zip -d /usr/bin
23+
- sudo chmod +x /usr/bin/terraform
24+
25+
before_install:
26+
- sudo apt-get update -yqq
27+
28+
install:
29+
- make deps
30+
31+
script:
32+
- make lint
33+
- make test

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM python:3.6
2+
3+
RUN apt-get update && \
4+
apt-get -y install dbus python-dbus-dev python3-dbus zip
5+
6+
COPY requirements.txt /requirements.txt
7+
RUN pip install -r /requirements.txt

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Andrew Griffiths
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
COVERAGE_MIN = 50
2+
3+
env:
4+
@python3 -m venv env
5+
6+
####################
7+
# run local server
8+
####################
9+
server:
10+
@FLASK_APP=run.py flask run
11+
12+
server-debug:
13+
@$(shell FLASK_DEBUG=1 make server)
14+
15+
server-docker:
16+
@FLASK_APP=run.py flask run --host 0.0.0.0
17+
18+
19+
####################
20+
# dependencies
21+
####################
22+
deps:
23+
@pip install -r requirements.txt
24+
@pre-commit install
25+
26+
deps-update:
27+
@pip install -r requirements-to-freeze.txt --upgrade
28+
@pip freeze > requirements.txt
29+
30+
deps-uninstall:
31+
@pip uninstall -yr requirements.txt
32+
@pip freeze > requirements.txt
33+
34+
####################
35+
# lint
36+
####################
37+
lint:
38+
@pre-commit run \
39+
--allow-unstaged-config \
40+
--all-files \
41+
--verbose
42+
43+
autopep8:
44+
@autopep8 . --recursive --in-place --pep8-passes 2000 --verbose
45+
46+
autopep8-stats:
47+
@pep8 --quiet --statistics .
48+
49+
####################
50+
# tests
51+
####################
52+
test: config/testing.py
53+
@pytest --cov-fail-under $(COVERAGE_MIN) --cov=app --cov-report html:htmlcov
54+
55+
test-debug:
56+
@pytest --pdb
57+
58+
test-deploy:
59+
@http-prompt $(shell cd terraform && terraform output api_url)
60+
61+
clean:
62+
@find . -name '__pycache__' | xargs rm -rf
63+
64+
.PHONY: deps* lint test* clean autopep8* migrate server*

0 commit comments

Comments
 (0)