Skip to content

Commit

Permalink
Initial public release 0.8.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
ajhodges committed Sep 4, 2018
0 parents commit 885a0d2
Show file tree
Hide file tree
Showing 100 changed files with 6,374 additions and 0 deletions.
216 changes: 216 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
build:
docker:
- image: docker/compose:1.19.0

working_directory: ~/repo

steps:
- checkout

- setup_remote_docker:
docker_layer_caching: true

- run:
name: Build application Docker image
command: |
docker-compose -f compose/circleci.yml up -d
- run:
name: PEP8 Lint check
command: |
docker-compose -f compose/circleci.yml exec -T runserver prospector -o pylint
- run:
name: Run unit tests
command: |
docker-compose -f compose/circleci.yml exec -T runserver coverage run manage.py test --noinput tests --settings conf.test_settings
- run:
name: Unit test coverage report
command: |
docker-compose -f compose/circleci.yml exec -T runserver coverage xml -o test-results/coverage/results.xml
- run:
name: Copy artifacts from Docker
command: |
docker cp $(docker-compose -f compose/circleci.yml ps -q runserver):/app/test-results test-results
- store_test_results:
path: test-results

- run:
name: Save docker image
command: |
mkdir -p docker-cache
docker save -o docker-cache/built-image.tar transmission-django
- save_cache:
key: docker-cache-{{ .Branch }}-{{ .Revision }}
paths:
- docker-cache

push-to-ecr:
docker:
- image: docker:stable-git

steps:
- restore_cache:
keys:
- docker-cache-{{ .Branch }}-{{ .Revision }}

- setup_remote_docker:
docker_layer_caching: true

- run:
name: Set dynamic ENV variables
command: |
echo 'export SHORT_GIT_HASH=$(echo $CIRCLE_SHA1 | cut -c -7)' >> $BASH_ENV
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip
pip install awscli
- run:
name: Load docker image
command: |
docker load < /root/repo/docker-cache/built-image.tar
- run:
name: Push image to ECR
command: |
source $BASH_ENV
docker tag transmission-django $ECR_ENDPOINT/transmission-django:$SHORT_GIT_HASH
docker tag transmission-django $ECR_ENDPOINT/transmission-django:latest
$(aws ecr get-login --no-include-email)
docker push $ECR_ENDPOINT/transmission-django:$SHORT_GIT_HASH
docker push $ECR_ENDPOINT/transmission-django:latest
deploy-to-dev:
docker:
- image: docker:stable-git

steps:
- run:
name: Set dynamic ENV variables
command: |
echo 'export SHORT_GIT_HASH=$(echo $CIRCLE_SHA1 | cut -c -7)' >> $BASH_ENV
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip
pip install awscli
- run:
name: Deploy new Task Revision to ECS
command: |
source $BASH_ENV
aws lambda invoke --function-name DeployImageToECS --payload "{
\"app\": \"transmission\",
\"env\": \"DEV\",
\"image\": \"$ECR_ENDPOINT/transmission-django:$SHORT_GIT_HASH\"
}" outputfile.txt && cat outputfile.txt
deploy-to-stage:
docker:
- image: docker:stable-git

steps:
- run:
name: Set dynamic ENV variables
command: |
echo 'export SHORT_GIT_HASH=$(echo $CIRCLE_SHA1 | cut -c -7)' >> $BASH_ENV
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip
pip install awscli
- run:
name: Deploy new Task Revision to ECS
command: |
source $BASH_ENV
aws lambda invoke --function-name DeployImageToECS --payload "{
\"app\": \"transmission\",
\"env\": \"STAGE\",
\"image\": \"$ECR_ENDPOINT/transmission-django:$SHORT_GIT_HASH\"
}" outputfile.txt && cat outputfile.txt
deploy-to-prod:
docker:
- image: docker:stable-git

steps:
- run:
name: Set dynamic ENV variables
command: |
echo 'export SHORT_GIT_HASH=$(echo $CIRCLE_SHA1 | cut -c -7)' >> $BASH_ENV
- run:
name: Install dependencies
command: |
apk add --no-cache py-pip
pip install awscli
- run:
name: Deploy new Task Revision to ECS
command: |
source $BASH_ENV
aws lambda invoke --function-name DeployImageToECS --payload "{
\"app\": \"transmission\",
\"env\": \"PROD\",
\"image\": \"$ECR_ENDPOINT/transmission-django:$SHORT_GIT_HASH\"
}" outputfile.txt && cat outputfile.txt
workflows:
version: 2
build-and-deploy:
jobs:
- build
- push-to-ecr:
filters:
branches:
only: master
requires:
- build
- deploy-to-dev:
filters:
branches:
only: master
requires:
- push-to-ecr
- hold-deploy-stage:
filters:
branches:
only: master
type: approval
requires:
- push-to-ecr
- deploy-to-stage:
filters:
branches:
only: master
requires:
- hold-deploy-stage
- hold-deploy-prod:
filters:
branches:
only: master
type: approval
requires:
- deploy-to-stage
- deploy-to-prod:
filters:
branches:
only: master
requires:
- hold-deploy-prod
25 changes: 25 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[run]
include = apps/*
omit =
apps/*/migrations/*
apps/wsgi.py
apps/celery.py

[report]
exclude_lines =
pragma: no cover

# Don't complain about missing debug-only code:
def __unicode__
def __repr__
if self\.debug

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

show_missing = True
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Export all variables from .env if it exists

if [[ -e ".env" ]] ; then
set -a
source .env
set +a
fi
114 changes: 114 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.idea
bin/dev-tools/node_modules
test-results

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
compose/*/pip.cache/*.whl
compose/*/pip.cache/*.zip
compose/*/pip.cache/*.tar.gz
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.static_storage/
.media/
staticfiles/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
docker-compose.yml
32 changes: 32 additions & 0 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
output-format: text

strictness: high

uses:
- django

pylint:
disable:
- unused-argument
- redefined-builtin
- no-self-use
- function-redefined
- abstract-method
- wildcard-import
- unused-wildcard-import
- too-many-ancestors
options:
good-names:
- pk
max-line-length: 120

pep8:
full: true
options:
max-line-length: 120

pyflakes:
disable:
- F811
- F401
- F403
Loading

0 comments on commit 885a0d2

Please sign in to comment.