-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
210 lines (190 loc) · 5.02 KB
/
Taskfile.yml
File metadata and controls
210 lines (190 loc) · 5.02 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
version: '3'
output: 'prefixed'
tasks:
code-format:
aliases:
- f
cmds:
- >
poetry run autoflake
--exclude '*.local*'
--expand-star-imports
--in-place
--recursive
--remove-all-unused-imports
--remove-duplicate-keys
--remove-unused-variables
--verbose
.
- poetry run black .
- poetry run isort --virtual-env="{{.DIR_VENV}}" .
desc: format code with autoflake, black, isort
dir: "{{.ROOT_DIR}}"
run: once
code-lint:
aliases:
- l
cmds:
- poetry run black --check .
- poetry run isort --check-only --virtual-env="{{.DIR_VENV}}" .
- poetry run mypy --config-file="{{.ROOT_DIR}}/pyproject.toml"
- poetry run flake8 --config="{{.ROOT_DIR}}/.flake8" .
- echo 'all linters passed'
desc: validate code using linters
dir: "{{.ROOT_DIR}}"
env:
WEBAPP_PRIMARY_DATABASE_URL: 'sqlite:///:memory:'
WEBAPP_SECRET_KEY: fake
WEBAPP_TEST_URL: fake
run: once
collect-static:
cmds:
- poetry run python manage.py collectstatic --noinput
desc: collect static
dir: "{{.ROOT_DIR}}"
env:
WEBAPP_PRIMARY_DATABASE_URL: 'sqlite:///:memory:'
WEBAPP_SECRET_KEY: fake
WEBAPP_TEST_URL: fake
run: once
db-migrate:
cmds:
- poetry run python manage.py migrate
desc: migrate db
dir: "{{.ROOT_DIR}}"
run: once
db-migrate-make:
cmds:
- poetry run python manage.py makemigrations
- task: code-format
- task: db-migrate
desc: create migrations and migrate
dir: "{{.ROOT_DIR}}"
run: once
db-reset:
cmds:
- docker compose exec -it postgres psql -U ca -d ca -c 'truncate table books_authors restart identity cascade;'
- docker compose exec -it postgres psql -U ca -d ca -c 'truncate table books restart identity cascade;'
- docker compose exec -it postgres psql -U ca -d ca -c 'truncate table authors restart identity cascade;'
desc: reset DB tables
dir: "{{.ROOT_DIR}}"
preconditions:
- docker info
run: once
docker-down:
cmds:
- docker compose down --remove-orphans
desc: stop all services
dir: "{{.ROOT_DIR}}"
preconditions:
- docker info
run: once
docker-up:
cmds:
- docker compose up --detach --remove-orphans --wait {{.CLI_ARGS}}
desc: start all ( `-- [<service> ...]`) services
dir: "{{.ROOT_DIR}}"
preconditions:
- docker info
run: once
run-docker-standalone:
cmds:
- >
docker run
--entrypoint=/bin/bash
--env-file=.env
--init
--interactive
--name=example-ca.webapp.standalone
--no-healthcheck
--read-only
--rm
--tty
example-ca.webapp
desc: run standalone container
dir: "{{.ROOT_DIR}}"
interactive: yes
preconditions:
- docker info
- docker images | grep example-ca.webapp
run: once
run-server-dev:
cmds:
- >
poetry run
python manage.py
runserver
0.0.0.0:8000
desc: run Django dev server
dir: "{{.ROOT_DIR}}"
dotenv:
- .env
- .env.sample
interactive: true
run: once
run-server-prod:
cmds:
- >
poetry run
gunicorn
--config="{{.ROOT_DIR}}/gunicorn.conf.py"
project.wsgi:application
desc: run Gunicorn on 0.0.0.0:80
dir: "{{.ROOT_DIR}}"
dotenv:
- .env
- .env.sample
platforms:
- darwin
- linux
interactive: true
run: once
run-tests:
aliases:
- t
cmds:
- poetry run pytest
desc: run tests
dir: "{{.ROOT_DIR}}"
run: once
setup-toolchain:
cmds:
- task: setup-toolchain-macos
- pyenv install --skip-existing "{{.PYTHON_VERSION}}"
- pyenv local "{{.PYTHON_VERSION}}"
- pip install --upgrade "pip=={{.PIP_VERSION}}"
- pip install --upgrade "poetry=={{.POETRY_VERSION}}"
- poetry env use "{{.PYTHON_VERSION}}"
- poetry install --with dev
desc: "setup developer's toolchain: Pyenv, Python, Poetry, venv"
dir: "{{.ROOT_DIR}}"
platforms:
- darwin
- linux
preconditions:
- pyenv --version
setup-toolchain-macos:
cmds:
- brew update
- brew install pyenv
desc: "setup MacOS"
dir: "{{.ROOT_DIR}}"
internal: true
platforms:
- darwin
preconditions:
- brew --version
vars:
DIR_LOCAL:
sh: (cd "{{.ROOT_DIR}}"/.local && pwd) || echo '.local'
DIR_VENV:
sh: (cd "$(poetry env info --path)" && pwd) || echo '.venv'
PIP_VERSION:
sh: (cat "{{.ROOT_DIR}}/.env" | grep 'WEBAPP_BUILD_PIP_VERSION' | sed -e 's/^.*=//g' ) || echo '23.3.1'
POETRY_VERSION:
sh: (cat "{{.ROOT_DIR}}/.env" | grep 'WEBAPP_BUILD_POETRY_VERSION' | sed -e 's/^.*=//g' ) || echo '1.7.0'
PYTHON_VERSION:
sh: (cat "{{.ROOT_DIR}}/.env" | grep 'WEBAPP_BUILD_PYTHON_VERSION' | sed -e 's/^.*=//g' ) || echo '3.11.5'
env:
PYTHONPATH: "{{.ROOT_DIR}}"
PYTHONPYCACHEPREFIX: "{{.DIR_LOCAL}}"