mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 09:36:52 +03:00
Setup pre-commit for the template files (#3433)
This commit is contained in:
parent
15f403c02c
commit
407a7d8bbc
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
|
@ -5,16 +5,20 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "3.9"
|
||||||
|
cache: pip
|
||||||
|
- name: Run pre-commit
|
||||||
|
uses: pre-commit/action@v2.0.3
|
||||||
|
|
||||||
tox:
|
tox:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
name: "Test with tox"
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
tox-env:
|
|
||||||
- py39
|
|
||||||
- black-template
|
|
||||||
|
|
||||||
name: "tox env ${{ matrix.tox-env }}"
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
|
@ -25,8 +29,8 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
python -m pip install -U pip
|
python -m pip install -U pip
|
||||||
python -m pip install -U tox
|
python -m pip install -U tox
|
||||||
- name: Tox ${{ matrix.tox-env }}
|
- name: Run tox
|
||||||
run: tox -e ${{ matrix.tox-env }}
|
run: tox -e py39
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
29
.pre-commit-config.yaml
Normal file
29
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
exclude: "{{cookiecutter.project_slug}}"
|
||||||
|
default_stages: [commit]
|
||||||
|
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.0.1
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: check-yaml
|
||||||
|
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 21.11b1
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/isort
|
||||||
|
rev: 5.10.1
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 4.0.1
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
|
||||||
|
ci:
|
||||||
|
autoupdate_schedule: weekly
|
||||||
|
skip: []
|
||||||
|
submodules: false
|
|
@ -7,10 +7,7 @@
|
||||||
#
|
#
|
||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
|
@ -242,7 +239,8 @@ texinfo_documents = [
|
||||||
"Cookiecutter Django documentation",
|
"Cookiecutter Django documentation",
|
||||||
"Daniel Roy Greenfeld",
|
"Daniel Roy Greenfeld",
|
||||||
"Cookiecutter Django",
|
"Cookiecutter Django",
|
||||||
"A Cookiecutter template for creating production-ready Django projects quickly.",
|
"A Cookiecutter template for creating production-ready "
|
||||||
|
"Django projects quickly.",
|
||||||
"Miscellaneous",
|
"Miscellaneous",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,7 +5,8 @@ NOTE:
|
||||||
can potentially be run in Python 2.x environment
|
can potentially be run in Python 2.x environment
|
||||||
(at least so we presume in `pre_gen_project.py`).
|
(at least so we presume in `pre_gen_project.py`).
|
||||||
|
|
||||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
TODO: restrict Cookiecutter Django project initialization to
|
||||||
|
Python 3.x environments only
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -164,8 +165,8 @@ def set_flag(file_path, flag, value=None, formatted=None, *args, **kwargs):
|
||||||
random_string = generate_random_string(*args, **kwargs)
|
random_string = generate_random_string(*args, **kwargs)
|
||||||
if random_string is None:
|
if random_string is None:
|
||||||
print(
|
print(
|
||||||
"We couldn't find a secure pseudo-random number generator on your system. "
|
"We couldn't find a secure pseudo-random number generator on your "
|
||||||
"Please, make sure to manually {} later.".format(flag)
|
"system. Please, make sure to manually {} later.".format(flag)
|
||||||
)
|
)
|
||||||
random_string = flag
|
random_string = flag
|
||||||
if formatted is not None:
|
if formatted is not None:
|
||||||
|
|
|
@ -4,7 +4,8 @@ NOTE:
|
||||||
as the whole Cookiecutter Django project initialization
|
as the whole Cookiecutter Django project initialization
|
||||||
can potentially be run in Python 2.x environment.
|
can potentially be run in Python 2.x environment.
|
||||||
|
|
||||||
TODO: ? restrict Cookiecutter Django project initialization to Python 3.x environments only
|
TODO: restrict Cookiecutter Django project initialization
|
||||||
|
to Python 3.x environments only
|
||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ if "{{ cookiecutter.use_docker }}".lower() == "n":
|
||||||
)
|
)
|
||||||
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
|
yes_options, no_options = frozenset(["y"]), frozenset(["n"])
|
||||||
while True:
|
while True:
|
||||||
choice = raw_input().lower()
|
choice = raw_input().lower() # noqa: F821
|
||||||
if choice in yes_options:
|
if choice in yes_options:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -65,7 +66,8 @@ if (
|
||||||
and "{{ cookiecutter.cloud_provider }}" == "None"
|
and "{{ cookiecutter.cloud_provider }}" == "None"
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
"You should either use Whitenoise or select a Cloud Provider to serve static files"
|
"You should either use Whitenoise or select a "
|
||||||
|
"Cloud Provider to serve static files"
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -77,6 +79,7 @@ if (
|
||||||
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
|
and "{{ cookiecutter.mail_service }}" == "Amazon SES"
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
"You should either use AWS or select a different Mail Service for sending emails."
|
"You should either use AWS or select a different "
|
||||||
|
"Mail Service for sending emails."
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
|
@ -85,7 +85,7 @@ def group_pulls_by_change_type(
|
||||||
"Updated": [],
|
"Updated": [],
|
||||||
}
|
}
|
||||||
for pull in pull_requests_list:
|
for pull in pull_requests_list:
|
||||||
label_names = {l.name for l in pull.labels}
|
label_names = {label.name for label in pull.labels}
|
||||||
if "update" in label_names:
|
if "update" in label_names:
|
||||||
group_name = "Updated"
|
group_name = "Updated"
|
||||||
elif "bug" in label_names:
|
elif "bug" in label_names:
|
||||||
|
|
7
setup.cfg
Normal file
7
setup.cfg
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[flake8]
|
||||||
|
exclude = docs
|
||||||
|
max-line-length = 88
|
||||||
|
|
||||||
|
[isort]
|
||||||
|
profile = black
|
||||||
|
known_first_party = tests,scripts,hooks
|
5
setup.py
5
setup.py
|
@ -13,7 +13,10 @@ with open("README.rst") as readme_file:
|
||||||
setup(
|
setup(
|
||||||
name="cookiecutter-django",
|
name="cookiecutter-django",
|
||||||
version=version,
|
version=version,
|
||||||
description="A Cookiecutter template for creating production-ready Django projects quickly.",
|
description=(
|
||||||
|
"A Cookiecutter template for creating production-ready "
|
||||||
|
"Django projects quickly."
|
||||||
|
),
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
author="Daniel Roy Greenfeld",
|
author="Daniel Roy Greenfeld",
|
||||||
author_email="pydanny@gmail.com",
|
author_email="pydanny@gmail.com",
|
||||||
|
|
|
@ -2,10 +2,10 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from cookiecutter.exceptions import FailedHookException
|
|
||||||
import sh
|
import sh
|
||||||
import yaml
|
import yaml
|
||||||
from binaryornot.check import is_binary
|
from binaryornot.check import is_binary
|
||||||
|
from cookiecutter.exceptions import FailedHookException
|
||||||
|
|
||||||
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
PATTERN = r"{{(\s?cookiecutter)[.](.*?)}}"
|
||||||
RE_OBJ = re.compile(PATTERN)
|
RE_OBJ = re.compile(PATTERN)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user