Skip to content

Commit

Permalink
Start project
Browse files Browse the repository at this point in the history
  • Loading branch information
jairhenrique committed Oct 9, 2021
0 parents commit 3043202
Show file tree
Hide file tree
Showing 11 changed files with 1,061 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab

[*.{yml,yaml}]
indent_size = 2
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
37 changes: 37 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- "*"

jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install -U pip poetry
poetry config virtualenvs.create false
poetry install
- name: Run lint
run: make lint

- name: Run tests
run: make test
148 changes: 148 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# 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/
share/python-wheels/
*.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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# 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/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.PHONY=help

help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

django-admin: ## Like django-admin.py
python main.py $(args)

test: ## Run tests
pytest

lint: ## Lint code
flake8 --show-source --statistics .
isort --check-only --diff .
black --check --diff .

lint-fix: ## Fix linting errors
flake8 .
black .
isort .

run-local: ## Run django local server
python main.py runserver

run-async: ## Run server async with gunicorn
gunicorn main:asgi_application -b 0.0.0.0:8000 -k uvicorn.workers.UvicornWorker -w 4

run-sync: ## Run server sync with gunicorn
gunicorn main:wsgi_application -b 0.0.0.0:8000 -w 4
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# A minimal async django app
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.conf import settings


def pytest_configure():
settings.configure(
DEBUG=True,
ROOT_URLCONF="main",
SECRET_KEY="fake",
)
32 changes: 32 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import sys
from distutils.util import strtobool

from django.conf import settings
from django.core.asgi import get_asgi_application
from django.core.management import execute_from_command_line
from django.core.wsgi import get_wsgi_application
from django.http import HttpRequest, HttpResponse
from django.urls import path

if not settings.configured:
settings.configure(
DEBUG=strtobool(os.getenv("DEBUG", "true")),
ROOT_URLCONF=sys.modules[__name__],
SECRET_KEY=os.getenv("SECRET_KEY", "fake"),
)


async def index(request: HttpRequest) -> HttpResponse:
return HttpResponse("<h1>A minimal Django async response!</h1>")


urlpatterns = [
path(r"", index),
]

asgi_application = get_asgi_application()
wsgi_application = get_wsgi_application()

if __name__ == "__main__":
execute_from_command_line(sys.argv)
Loading

0 comments on commit 3043202

Please sign in to comment.