Skip to content

Commit

Permalink
Merge branch 'master' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhanhan authored May 26, 2020
2 parents 401ef31 + a8672e0 commit d821dcc
Show file tree
Hide file tree
Showing 24 changed files with 184 additions and 82 deletions.
11 changes: 0 additions & 11 deletions .github/labeler.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/label.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .pyup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,3 @@ pin: True
# requires private repo permissions, even on public repos
# default: empty
label_prs: update

# Specify requirement files by hand, pyup seems to struggle to
# find the ones in the project_slug folder
requirements:
- "requirements.txt"
- "{{cookiecutter.project_slug}}/requirements/base.txt"
- "{{cookiecutter.project_slug}}/requirements/local.txt"
- "{{cookiecutter.project_slug}}/requirements/production.txt"
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
dist: xenial

services:
- docker

Expand All @@ -19,8 +17,8 @@ matrix:
script: tox -e black-template
- name: Basic Docker
script: sh tests/test_docker.sh
- name: Docker with Celery
script: sh tests/test_docker.sh use_celery=y
- name: Extended Docker
script: sh tests/test_docker.sh use_celery=y use_drf=y
- name: Bare metal
script: sh tests/test_bare.sh use_celery=y use_compressor=y
services:
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Listed in alphabetical order.
Jerome Leclanche `@jleclanche`_ @Adys
Jimmy Gitonga `@afrowave`_ @afrowave
John Cass `@jcass77`_ @cass_john
Jonathan Thompson `@nojanath`_
Jules Cheron `@jules-ch`_
Julien Almarcha `@sladinji`_
Julio Castillo `@juliocc`_
Expand All @@ -161,6 +162,7 @@ Listed in alphabetical order.
Krzysztof Żuraw `@krzysztofzuraw`_
Leo won `@leollon`_
Leo Zhou `@glasslion`_
Leon Kim `@PilhwanKim`_
Leonardo Jimenez `@xpostudio4`_
Lin Xianyi `@iynaix`_
Luis Nell `@originell`_
Expand Down Expand Up @@ -312,6 +314,7 @@ Listed in alphabetical order.
.. _@hackebrot: https://github.com/hackebrot
.. _@hairychris: https://github.com/hairychris
.. _@hanaquadara: https://github.com/hanaquadara
.. _@hanhanhan: https://github.com/hanhanhan
.. _@hendrikschneider: https://github.com/hendrikschneider
.. _@highpost: https://github.com/highpost
.. _@hjwp: https://github.com/hjwp
Expand Down Expand Up @@ -358,12 +361,14 @@ Listed in alphabetical order.
.. _@myilmaz: https://github.com/myilmaz
.. _@nicolas471: https://github.com/nicolas471
.. _@noisy: https://github.com/noisy
.. _@nojanath: https://github.com/nojanath
.. _@originell: https://github.com/originell
.. _@oubiga: https://github.com/oubiga
.. _@parbhat: https://github.com/parbhat
.. _@rjsnh1522: https://github.com/rjsnh1522
.. _@pchiquet: https://github.com/pchiquet
.. _@phiberjenz: https://github.com/phiberjenz
.. _@PilhwanKim: https://github.com/PilhwanKim
.. _@purplediane: https://github.com/purplediane
.. _@raonyguimaraes: https://github.com/raonyguimaraes
.. _@reggieriser: https://github.com/reggieriser
Expand Down
9 changes: 9 additions & 0 deletions docs/developing-locally-docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ django-debug-toolbar
In order for ``django-debug-toolbar`` to work designate your Docker Machine IP with ``INTERNAL_IPS`` in ``local.py``.


docker
""""""

The ``container_name`` from the yml file can be used to check on containers with docker commands, for example: ::

$ docker logs worker
$ docker top worker


Mailhog
~~~~~~~

Expand Down
7 changes: 7 additions & 0 deletions docs/developing-locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Make sure to have the following on your host:
* Python 3.8
* PostgreSQL_.
* Redis_, if using Celery
* Cookiecutter_

First things first.

Expand All @@ -23,9 +24,14 @@ First things first.

$ source <virtual env path>/bin/activate

#. Install cookiecutter-django

$ cookiecutter gh:pydanny/cookiecutter-django ::

#. Install development requirements: ::

$ pip install -r requirements/local.txt
$ git init # A git repo is required for pre-commit to install
$ pre-commit install

.. note::
Expand Down Expand Up @@ -78,6 +84,7 @@ or if you're running asynchronously: ::

.. _PostgreSQL: https://www.postgresql.org/download/
.. _Redis: https://redis.io/download
.. _CookieCutter: https://github.com/cookiecutter/cookiecutter
.. _createdb: https://www.postgresql.org/docs/current/static/app-createdb.html
.. _initial PostgreSQL set up: http://suite.opengeo.org/docs/latest/dataadmin/pgGettingStarted/firstconnect.html
.. _postgres documentation: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
Expand Down
10 changes: 10 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ def remove_aws_dockerfile():
def remove_drf_starter_files():
os.remove(os.path.join("config", "api_router.py"))
shutil.rmtree(os.path.join("{{cookiecutter.project_slug}}", "users", "api"))
os.remove(
os.path.join(
"{{cookiecutter.project_slug}}", "users", "tests", "test_drf_urls.py"
)
)
os.remove(
os.path.join(
"{{cookiecutter.project_slug}}", "users", "tests", "test_drf_views.py"
)
)


def remove_storages_module():
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
cookiecutter==1.7.2
sh==1.12.14
sh==1.13.1
binaryornot==0.4.4

# Code quality
# ------------------------------------------------------------------------------
black==19.10b0
flake8==3.7.9
flake8==3.8.2
flake8-isort==3.0.0

# Testing
# ------------------------------------------------------------------------------
tox==3.14.6
pytest==5.4.1
tox==3.15.1
pytest==5.4.2
pytest-cookies==0.5.1
pytest-instafail==0.4.1.post0
pyyaml==5.3.1
6 changes: 4 additions & 2 deletions tests/test_cookiecutter_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_flake8_passes(cookies, context_override):
result = cookies.bake(extra_context=context_override)

try:
sh.flake8(str(result.project))
sh.flake8(_cwd=str(result.project))
except sh.ErrorReturnCode as e:
pytest.fail(e.stdout.decode())

Expand All @@ -167,7 +167,9 @@ def test_black_passes(cookies, context_override):
result = cookies.bake(extra_context=context_override)

try:
sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/")
sh.black(
"--check", "--diff", "--exclude", "migrations", _cwd=str(result.project)
)
except sh.ErrorReturnCode as e:
pytest.fail(e.stdout.decode())

Expand Down
18 changes: 11 additions & 7 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@ default_stages: [commit]
fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: master
hooks:
- id: trailing-whitespace
files: (^|/).+\.(py|html|sh|css|js)$
- id: end-of-file-fixer
- id: check-yaml

- repo: local
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.1
hooks:
- id: flake8
name: flake8
entry: flake8
language: python
types: [python]
args: ['--config=setup.cfg']
additional_dependencies: [flake8-isort]

2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/compose/local/django/start
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -o nounset

python manage.py migrate
{%- if cookiecutter.use_async == 'y' %}
/usr/local/bin/gunicorn config.asgi --bind 0.0.0.0:8000 --chdir=/app -k uvicorn.workers.UvicornWorker --reload
uvicorn config.asgi:application --host 0.0.0.0 --reload
{%- else %}
python manage.py runserver_plus 0.0.0.0:8000
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ certificatesResolvers:
entryPoint: web

http:
{%- set domain_dots = cookiecutter.domain_name.count('.') %}
routers:
web-router:
{%- if domain_dots == 1 or (domain_dots == 2 and '.co.' in cookiecutter.domain_name) %}
{%- if cookiecutter.domain_name.count('.') == 1 %}
rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)"
{% else %}
rule: "Host(`{{ cookiecutter.domain_name }}`)"
Expand All @@ -42,7 +41,7 @@ http:
service: django

web-secure-router:
{%- if domain_dots == 1 or (domain_dots == 2 and '.co.' in cookiecutter.domain_name) %}
{%- if cookiecutter.domain_name.count('.') == 1 %}
rule: "Host(`{{ cookiecutter.domain_name }}`) || Host(`www.{{ cookiecutter.domain_name }}`)"
{% else %}
rule: "Host(`{{ cookiecutter.domain_name }}`)"
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/config/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

# This allows easy placement of apps within the interior
# {{ cookiecutter.project_slug }} directory.
app_path = Path(__file__).parents[1].resolve()
sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}"))
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent
sys.path.append(str(ROOT_DIR / "{{ cookiecutter.project_slug }}"))

# If DJANGO_SETTINGS_MODULE is unset, default to the local settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import environ

ROOT_DIR = Path(__file__).parents[2]
# {{ cookiecutter.project_slug }}/)
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
# {{ cookiecutter.project_slug }}/
APPS_DIR = ROOT_DIR / "{{ cookiecutter.project_slug }}"
env = environ.Env()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
# Mimicing memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
# http://jazzband.github.io/django-redis/latest/#_memcached_exceptions_behavior
"IGNORE_EXCEPTIONS": True,
},
}
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/config/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

# This allows easy placement of apps within the interior
# {{ cookiecutter.project_slug }} directory.
app_path = Path(__file__).parents[1].resolve()
sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}"))
ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent
sys.path.append(str(ROOT_DIR / "{{ cookiecutter.project_slug }}"))
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
Expand Down
8 changes: 8 additions & 0 deletions {{cookiecutter.project_slug}}/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: {{ cookiecutter.project_slug }}_local_django
container_name: django
depends_on:
- postgres
{%- if cookiecutter.use_mailhog == 'y' %}
Expand All @@ -29,6 +30,7 @@ services:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: {{ cookiecutter.project_slug }}_production_postgres
container_name: postgres
volumes:
- local_postgres_data:/var/lib/postgresql/data
- local_postgres_data_backups:/backups
Expand All @@ -54,6 +56,7 @@ services:

mailhog:
image: mailhog/mailhog:v1.0.0
container_name: mailhog
ports:
- "8025:8025"

Expand All @@ -62,10 +65,12 @@ services:

redis:
image: redis:5.0
container_name: redis

celeryworker:
<<: *django
image: {{ cookiecutter.project_slug }}_local_celeryworker
container_name: celeryworker
depends_on:
- redis
- postgres
Expand All @@ -78,6 +83,7 @@ services:
celerybeat:
<<: *django
image: {{ cookiecutter.project_slug }}_local_celerybeat
container_name: celerybeat
depends_on:
- redis
- postgres
Expand All @@ -90,6 +96,7 @@ services:
flower:
<<: *django
image: {{ cookiecutter.project_slug }}_local_flower
container_name: flower
ports:
- "5555:5555"
command: /start-flower
Expand All @@ -102,6 +109,7 @@ services:
context: .
dockerfile: ./compose/local/node/Dockerfile
image: {{ cookiecutter.project_slug }}_local_node
container_name: node
depends_on:
- django
volumes:
Expand Down
Loading

0 comments on commit d821dcc

Please sign in to comment.