-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
175 lines (151 loc) · 4.92 KB
/
Taskfile.yml
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
# https://taskfile.dev
version: "3"
tasks:
default:
desc: Print this very list of available tasks
vars:
TEKST_VERSION:
sh: task version
cmds:
- echo "This is Tekst server {{.TEKST_VERSION}}"
- task --list
silent: true
version:
desc: Print project version
cmds:
- poetry run python3 -c "from tekst import __version__ as v; print(v, end='')"
silent: true
install:
desc: Install dependencies
cmds:
- poetry install
update:
desc: Update dependencies
cmds:
- poetry update
fix:
desc: Run ruff to format code base and attempt to fix linting errors
cmds:
- poetry run ruff format .
- poetry run ruff check . --fix
check:
desc: Check code using ruff
cmds:
- poetry run ruff format . --check
- poetry run ruff check . --extend-select N
tests:
desc: Run tests, start and stop services stack
dotenv: [".env.test"]
cmds:
- defer: { task: test-stack-down }
- task: install
- task: test-stack-up
- task: wait-for-mongodb
- poetry run coverage run -m pytest {{.CLI_ARGS}}
- poetry run coverage report -m
run-dev:
desc: Run the application dev server (only for development!)
env:
TEKST_DEV_MODE: true
cmds:
- poetry run python3 -m tekst setup
- task: print-dev-uris
- poetry run python3 -m tekst dev --reload
dev:
desc: Run dev services stack and dev server, clean up afterwards
cmds:
- defer: { task: dev-stack-down }
- task: dev-stack-up
- task: wait-for-mongodb
- task: wait-for-elasticsearch
- task: run-dev
schema:
desc: Export (development) OpenAPI schema to file openapi.json
env:
TEKST_DEV_MODE: true
TEKST_DEV__USE_DB: false
TEKST_DEV__USE_ES: false
TEKST_LOG_LEVEL: ERROR
cmds:
- poetry run python3 -m tekst schema -f
pre-commit:
desc: Run full pre-commit toolchain (fix code, test, code checks, export schema)
cmds:
- task: fix
- task: tests
- task: check
- task: schema
clean:
desc: Cleanup of generated files (won't work on Windows)
cmds:
- cmd: poetry run ruff clean
- cmd: shopt -s globstar
- cmd: |
rm -rf \
*/**/__pycache__ \
.pytest_cache \
.ruff_cache \
.coverage \
.venv/ \
.env/ \
dist \
htmlcov \
dev-stack-up:
desc: Run dev services stack
cmds:
- task: gen-smtp-ssl-cert
- docker compose -f dev/compose.yml --profile dev -p tekst-dev up --detach
dev-stack-down:
desc: Stop dev stack and clean up all resources
cmds:
- docker compose -f dev/compose.yml --profile dev -p tekst-dev down --volumes
dev-stack-build:
desc: Build updated container images in the app stack
cmds:
- docker compose -f dev/compose.yml --profile dev --profile test build
test-stack-up:
desc: Run test services stack
cmds:
- task: gen-smtp-ssl-cert
- docker compose -f dev/compose.yml --profile test -p tekst-testing up --detach
test-stack-down:
desc: Stop test stack and clean up all resources
cmds:
- docker compose -f dev/compose.yml --profile test -p tekst-testing down --volumes
print-dev-uris:
internal: true
silent: true
cmd: |
printf "
╭───────────────────────────────────────────────────────╮
│ 🌐 Tekst-Web Dev Server ... http://127.0.0.1 │
│ 🐍 Tekst-API .............. http://127.0.0.1/api │
│ 📖 API Docs ............... http://127.0.0.1/api/docs │
│ 📬 MailPit ................ http://127.0.0.1:8025 │
│ 📂 MongoExpress ........... http://127.0.0.1:8081 │
│ 🔍 Elasticvue ............. http://127.0.0.1:9280 │
╰───────────────────────────────────────────────────────╯
"
docker-build:
desc: Build and tag production Docker image for app
vars:
TEKST_VERSION:
sh: task version
cmds:
- cmd: |
docker build \
--tag "tekst-api:latest" \
--tag "tekst-api:{{.TEKST_VERSION}}" \
--target prod .
wait-for-mongodb:
internal: true
silent: true
cmd: printf "Waiting for MongoDB service"; while ! $(curl -f http://127.0.0.1:27017 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
wait-for-elasticsearch:
internal: true
silent: true
cmd: printf "Waiting for Elasticsearch service"; while ! $(curl -f http://127.0.0.1:9200 > /dev/null 2>&1); do sleep 1; printf "."; done; printf "\n"
gen-smtp-ssl-cert:
internal: true
silent: true
cmd: cd dev/smtp-ssl && ./generate.sh