-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
203 lines (185 loc) · 5 KB
/
Taskfile.yml
File metadata and controls
203 lines (185 loc) · 5 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
version: '3'
output: 'prefixed'
tasks:
code-format:
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}}"
code-lint:
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_MSSQL_DATABASE_HOST: fake
WEBAPP_MSSQL_DATABASE_NAME: fake
WEBAPP_MSSQL_DATABASE_PASSWORD: fake
WEBAPP_MSSQL_DATABASE_PORT: 1433
WEBAPP_MSSQL_DATABASE_USERNAME: fake
WEBAPP_PRIMARY_DATABASE_URL: 'postgresql://fake:fake@fake:5432/fake'
WEBAPP_SECRET_KEY: fake
collect-static:
cmds:
- poetry run python manage.py collectstatic --noinput
desc: collect static
dir: "{{.ROOT_DIR}}"
env:
WEBAPP_MSSQL_DATABASE_HOST: fake
WEBAPP_MSSQL_DATABASE_NAME: fake
WEBAPP_MSSQL_DATABASE_PASSWORD: fake
WEBAPP_MSSQL_DATABASE_PORT: 1433
WEBAPP_MSSQL_DATABASE_USERNAME: fake
WEBAPP_PRIMARY_DATABASE_URL: 'postgresql://fake:fake@fake:5432/fake'
WEBAPP_SECRET_KEY: fake
run: once
db-migrate:
cmds:
- poetry run python manage.py migrate
desc: migrate db
dir: "{{.ROOT_DIR}}"
run: once
db-migrate-dev:
cmds:
- poetry run python manage.py makemigrations
- task: code-format
- task: db-migrate
desc: create migrations and migrate
dir: "{{.ROOT_DIR}}"
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-django-mssql-docker-webapp-standalone
--no-healthcheck
--read-only
--rm
--tty
example-django-mssql-docker-webapp
desc: run standalone container
dir: "{{.ROOT_DIR}}"
interactive: yes
preconditions:
- docker info
- docker images | grep example-django-mssql-docker-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
run: once
run-server-prod:
cmds:
- >
poetry run
gunicorn
--config="{{.ROOT_DIR}}/domains/config/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
run: once
run-tests:
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}}"
- 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 tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
- brew update
- >
brew install
msodbcsql18
mssql-tools18
pyenv
unixodbc
- odbcinst -j
desc: "setup MacOS"
dir: "{{.ROOT_DIR}}"
env:
HOMEBREW_ACCEPT_EULA: Y
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.2.1'
POETRY_VERSION:
sh: (cat "{{.ROOT_DIR}}/.env" | grep 'WEBAPP_BUILD_POETRY_VERSION' | sed -e 's/^.*=//g' ) || echo '1.5.1'
PYTHON_VERSION:
sh: (cat "{{.ROOT_DIR}}/.env" | grep 'WEBAPP_BUILD_PYTHON_VERSION' | sed -e 's/^.*=//g' ) || echo '3.11.3'
env:
PYTHONPATH: "{{.ROOT_DIR}}"