Skip to content

Commit fb11598

Browse files
committed
Add Makefile and required dependencies
Plus few config upgrades
1 parent 614b592 commit fb11598

File tree

4 files changed

+185
-7
lines changed

4 files changed

+185
-7
lines changed

Makefile

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
################
2+
# build commands
3+
################
4+
5+
django-build:
6+
docker-compose -f local.yml build django
7+
8+
django-run:
9+
docker-compose -f local.yml up --remove-orphans
10+
11+
backend-build:
12+
docker-compose -f local.yml build --pull
13+
14+
build: backend-build stop
15+
16+
run: django-run
17+
18+
stop:
19+
docker-compose -f local.yml stop
20+
21+
destroy:
22+
docker-compose -f local.yml rm -svf postgres
23+
docker-compose -f local.yml rm -svf django
24+
docker-compose -f local.yml rm -svf celeryworker
25+
docker-compose -f local.yml rm -svf celerybeat
26+
docker volume prune -f
27+
rm -f localstack/data/recorded_api_calls.json localstack/data/startup_info.json
28+
29+
destroy-save-data:
30+
docker-compose -f local.yml rm -svf django
31+
docker-compose -f local.yml rm -svf celeryworker
32+
docker-compose -f local.yml rm -svf celerybeat
33+
docker volume prune -f
34+
35+
rebuild-save-data: destroy-save-data build
36+
37+
destroy-hard: stop destroy
38+
docker-compose -f local.yml down -v --rmi all
39+
40+
rebuild: destroy build
41+
r: rebuild
42+
43+
rebuild-with-init-data: destroy build m core-data
44+
rbwid: rebuild-with-init-data
45+
46+
armageddon:
47+
docker-compose -f local.yml stop
48+
docker-compose -f local.yml down -v --rmi all
49+
docker volume prune -f
50+
rm -f localstack/data/recorded_api_calls.json localstack/data/startup_info.json
51+
52+
clean: destroy stop
53+
docker system prune -f
54+
55+
cbr: clean build run
56+
57+
destroy-postgres:
58+
docker-compose -f local.yml rm -svf postgres
59+
60+
61+
####################
62+
# migration commands
63+
####################
64+
python-makemigrations:
65+
docker-compose -f local.yml run --rm django python manage.py makemigrations
66+
mm: python-makemigrations
67+
68+
python-makemigrations-empty:
69+
docker-compose -f local.yml run --rm django python manage.py makemigrations ${app_label} --empty --name data_migration_${migration_name}
70+
mme: python-makemigrations-empty
71+
72+
python-makemigrations-merge:
73+
docker-compose -f local.yml run --rm django python manage.py makemigrations --merge
74+
merge: python-makemigrations-merge
75+
76+
python-migrate:
77+
docker-compose -f local.yml run --rm django python manage.py migrate_schemas --executor=standard_soft_delete
78+
m: python-migrate
79+
80+
81+
###########################
82+
# bash, shell, cli commands
83+
###########################
84+
python-bash:
85+
docker-compose -f local.yml run --rm django bash
86+
b: python-bash
87+
bash: python-bash
88+
89+
python-bash-root:
90+
docker-compose -f local.yml run --rm --user root django bash
91+
b-root: python-bash-root
92+
93+
python-shell-plus:
94+
docker-compose -f local.yml run --rm django python manage.py shell_plus
95+
sp: python-shell-plus
96+
97+
python-tenant-shell-plus:
98+
docker-compose -f local.yml run --rm django python manage.py tenant_command shell_plus
99+
tsp: python-tenant-shell-plus
100+
101+
python-db-shell:
102+
docker-compose -f local.yml run --rm django python manage.py dbshell
103+
db: python-db-shell
104+
105+
redis-cli:
106+
docker-compose -f local.yml run --rm redis redis-cli -h redis -p 6379
107+
108+
redis-cli-cacheops:
109+
docker-compose -f local.yml run --rm redis redis-cli -n 1 -h redis -p 6379
110+
cacheops: redis-cli-cacheops
111+
112+
#################################
113+
# scripts and management commands
114+
#################################
115+
python-pip-install:
116+
docker-compose -f local.yml run --rm --user root django pip install -r requirements/base.txt -r requirements/local.txt
117+
docker-compose -f local.yml run --rm --user root celeryworker pip install -r requirements/base.txt -r requirements/local.txt
118+
docker-compose -f local.yml run --rm --user root celerybeat pip install -r requirements/base.txt -r requirements/local.txt
119+
pip: python-pip-install
120+
121+
postman-push:
122+
docker-compose -f local.yml run --rm django /bin/bash -c "cd scripts && chmod 755 postman-push.sh && ./postman-push.sh"
123+
pp: postman-push
124+
125+
build-openapi-schema:
126+
docker-compose -f local.yml run --rm django python manage.py tenant_command spectacular --file openapi-schema.yml --urlconf config.urls
127+
bos: build-openapi-schema
128+
129+
rules-engine-ecr:
130+
echo "Downloading Rules Engine from ECR. Make sure your AWS profile is called 'los'."
131+
aws ecr get-login-password --profile los | docker login --username AWS --password-stdin 813755454003.dkr.ecr.us-east-2.amazonaws.com
132+
re-ecr: rules-engine-ecr
133+
134+
python-makemessages:
135+
docker-compose -f local.yml run --rm django python manage.py makemessages -a
136+
messages: python-makemessages
137+
138+
python-compilemessages:
139+
docker-compose -f local.yml run --rm django python manage.py compilemessages
140+
cm: python-compilemessages
141+
142+
143+
###############
144+
# test commands
145+
###############
146+
DIR ?= tests/
147+
python-test:
148+
docker-compose -f local.yml run --rm django python -m pytest ${DIR}
149+
t: python-test
150+
test: python-test
151+
152+
####################
153+
# reporting commands
154+
####################
155+
pylint:
156+
docker-compose -f local.yml run --rm django bash ./run_pylint.sh
157+
158+
coverage:
159+
docker-compose -f local.yml run --rm django bash -c "pytest --cov tests/"
160+
# docker-compose -f local.yml run --rm django bash -c "coverage run -m pytest && coverage report"
161+
162+
# config in pyproject.toml
163+
vulture:
164+
docker-compose -f local.yml run --rm django vulture
165+
166+
qc: pylint coverage vulture

pyproject.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ plugins = ["django_coverage_plugin"]
1616

1717
# ==== black ====
1818
[tool.black]
19-
line-length = 119
19+
line-length = 120
2020
target-version = ['py311']
21-
21+
exclude = """
22+
/(
23+
| migrations
24+
| venv
25+
)/
26+
"""
2227

2328
# ==== isort ====
2429
[tool.isort]
2530
profile = "black"
26-
line_length = 119
31+
atomic = true
32+
line_length = 120
2733
known_first_party = [
2834
"pi23_gswdt",
2935
"config",
@@ -63,7 +69,7 @@ load-plugins = [
6369
django-settings-module = "config.settings.local"
6470

6571
[tool.pylint.FORMAT]
66-
max-line-length = 119
72+
max-line-length = 120
6773

6874
[tool.pylint."MESSAGES CONTROL"]
6975
disable = [
@@ -95,7 +101,7 @@ format_js = true
95101
ignore = "H006,H030,H031,T002"
96102
include = "H017,H035"
97103
indent = 2
98-
max_line_length = 119
104+
max_line_length = 120
99105
profile = "django"
100106

101107
[tool.djlint.css]

requirements/base.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ djangorestframework==3.14.0 # https://github.com/encode/django-rest-framework
2323
django-cors-headers==4.2.0 # https://github.com/adamchainz/django-cors-headers
2424
# DRF-spectacular for api documentation
2525
drf-spectacular==0.26.5 # https://github.com/tfranzel/drf-spectacular
26+
27+
django-constance==2.9.1 # https://github.com/jazzband/django-constance
28+
django-constance[database]
29+
django-tenants==3.5.0 # https://github.com/django-tenants/django-tenants
30+
tenant-schemas-celery==2.0.0 # https://github.com/maciej-gol/tenant-schemas-celery
31+
djangoql==0.17.1 # https://github.com/ivelum/djangoql

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# https://github.com/PyCQA/flake8/issues/234
33
# https://github.com/PyCQA/pycodestyle/issues/813
44
[flake8]
5-
max-line-length = 119
5+
max-line-length = 120
66
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv
77
extend-ignore = E203
88

99
[pycodestyle]
10-
max-line-length = 119
10+
max-line-length = 120
1111
exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,.venv

0 commit comments

Comments
 (0)