-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
106 lines (67 loc) · 1.72 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from invoke import task
DOCKER = "docker-compose"
DOCKER_RUN = f"{DOCKER} run --rm django"
DOCKER_EXEC = f"{DOCKER} exec --rm django"
def docker(c, command, **kwargs):
c.run(f"{DOCKER} {command}", **kwargs)
def docker_run(c, command, **kwargs):
c.run(f"{DOCKER_RUN} {command}", **kwargs)
def docker_exec(c, command, **kwargs):
c.run(f"{DOCKER_EXEC} {command}", **kwargs)
@task
def build(c):
docker(c, "build")
@task
def start(c):
docker(c, "up -d")
@task
def stop(c):
docker(c, "stop")
@task
def makemigrations(c, args=""):
docker_run(c, f"python manage.py makemigrations {args}")
@task
def pytest(c, args=""):
docker_run(c, f"pytest . {args}")
@task
def migrate(c):
docker_run(c, "python manage.py migrate")
@task
def collectstatic(c):
docker_run(c, "python manage.py collectstatic --noinput")
@task
def shell(c):
docker_run(c, "sh", pty=True)
@task
def python_shell(c):
docker_run(c, "python manage.py shell", pty=True)
@task
def create_super_user(c):
docker_run(c, "python manage.py createsuperuser", pty=True)
@task
def update_data(c, usernames):
docker_run(c, f"python manage.py scrobbles {usernames}")
@task
def quality(c):
docker_run(c, "black .")
docker_run(c, "flake8 .")
docker_run(c, "mypy")
@task
def quality_check(c):
docker_run(c, "black . --check")
docker_run(c, "flake8 .")
docker_run(c, "mypy")
@task
def bandit(c):
docker_run(c, "bandit -r .")
@task
def install_deps(c):
docker_exec(c, "pip3 install -r requirements.txt")
docker_exec(c, "pip3 install -r requirements-dev.txt")
@task
def initial_setup(c):
c.run("touch .env.local")
build(c)
migrate(c)
collectstatic()
create_super_user(c)