-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
210 lines (179 loc) · 6.4 KB
/
Taskfile.yml
File metadata and controls
210 lines (179 loc) · 6.4 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
# Copyright 2026 Firefly Software Foundation
#
# Developer workflows for flydocs. Run ``task`` with no arguments to
# list every target. Each task is meant to be the shortest path to a
# working environment.
version: "3"
vars:
PORT: '{{.PORT | default "8400"}}'
COMPOSE: docker compose
COMPOSE_TEST: docker compose -f docker-compose.yml -f docker-compose.test.yml
env:
PYTHONPATH: src
tasks:
default:
cmds: [task --list]
silent: true
# ===================================================================
# Setup
# ===================================================================
deps:install:
desc: Create the venv and install runtime + dev dependencies.
cmds:
- uv sync --extra dev
env:init:
desc: Copy env_template to .env if .env is missing.
# Used as a precondition by every docker:* task so the stack boots even
# on a brand-new checkout. Idempotent -- skips silently when .env exists.
status:
- test -f .env
cmds:
- cp env_template .env
- 'echo "[env:init] bootstrapped .env from env_template -- edit credentials before production."'
# ===================================================================
# Code quality
# ===================================================================
lint:check:
desc: Ruff lint + format check.
cmds:
- uv run ruff check .
- uv run ruff format --check .
lint:format:
desc: Auto-format with ruff.
cmds:
- uv run ruff format .
- uv run ruff check --fix .
# ===================================================================
# Tests
# ===================================================================
test:
desc: Run unit tests (skips real-LLM tests).
cmds:
- uv run pytest
test:unit:
desc: Unit tests only.
cmds:
- uv run pytest tests/unit
test:integration:
desc: Integration tests against the docker compose stack.
env:
FLYDOCS_RUN_INTEGRATION: "1"
cmds:
- uv run pytest tests/integration -m integration
test:llm:
desc: Real Claude smoke test. Requires ANTHROPIC_API_KEY + the sample PDF.
cmds:
- uv run pytest tests/llm -m llm -s -v
# ===================================================================
# Local dev -- one terminal each, no Docker for the API
# ===================================================================
dev:db:
desc: |
Bring up Postgres + Redis in docker (leaves the API + worker on the host).
Use this when you want to iterate on Python code with a stable database.
deps: [env:init]
cmds:
- '{{.COMPOSE}} up -d postgres redis'
- 'echo "Postgres on :5435 Redis on :6385 (override with PG_PORT/REDIS_PORT)"'
dev:db:down:
desc: Stop the dev Postgres + Redis containers.
cmds:
- '{{.COMPOSE}} stop postgres redis'
dev:migrate:
desc: alembic upgrade head against the configured DATABASE_URL.
cmds:
- uv run flydocs migrate
dev:serve:
desc: Run the API with hot-reload on :{{.PORT}}.
cmds:
- uv run uvicorn flydocs.main:app --reload --host 0.0.0.0 --port {{.PORT}}
dev:worker:
desc: Run the EDA worker that consumes the job queue.
cmds:
- uv run flydocs worker
dev:up:
desc: |
Local-first dev: start Postgres + Redis in docker, run migrations,
then start the API in hot-reload mode. The worker is NOT started --
run ``task dev:worker`` in another terminal.
cmds:
- task: dev:db
- task: dev:migrate
- task: dev:serve
# ===================================================================
# Docker -- everything inside containers
# ===================================================================
docker:build:
desc: Build the flydocs image with sibling-path BuildKit contexts.
deps: [env:init]
cmds:
- '{{.COMPOSE}} build'
docker:up:
desc: Boot the full stack (api + worker + postgres + redis) in the background.
# env:init auto-creates .env from env_template the first time; the compose
# files declare ``.env`` as ``required: false`` so re-runs without one
# still succeed.
deps: [env:init]
cmds:
- '{{.COMPOSE}} up -d --build'
- 'echo "API -> http://localhost:{{.PORT}}"'
- 'echo "docs -> http://localhost:{{.PORT}}/docs"'
- 'echo "health-> http://localhost:{{.PORT}}/actuator/health"'
docker:logs:
desc: Tail logs from every container.
cmds:
- '{{.COMPOSE}} logs -f --tail=200'
docker:down:
desc: Tear down the stack (keeps the postgres volume).
cmds:
- '{{.COMPOSE}} down'
docker:nuke:
desc: Tear down the stack and delete the postgres volume.
cmds:
- '{{.COMPOSE}} down -v'
docker:up:test:
desc: Boot the integration-test stack (adds mock-llm + webhook-sink).
deps: [env:init]
cmds:
- '{{.COMPOSE_TEST}} up -d --build'
docker:down:test:
desc: Tear down the integration-test stack (deletes the volumes).
cmds:
- '{{.COMPOSE_TEST}} down -v'
# ===================================================================
# Diagnostic shortcuts
# ===================================================================
health:
desc: Curl the /actuator/health endpoint of the running API.
cmds:
- 'curl -fsS http://localhost:{{.PORT}}/actuator/health | jq .'
health:readiness:
desc: Curl /actuator/health/readiness -- shows the database + EDA components.
cmds:
- 'curl -fsS http://localhost:{{.PORT}}/actuator/health/readiness | jq .'
health:liveness:
desc: Curl /actuator/health/liveness -- cheap, no broker pings.
cmds:
- 'curl -fsS http://localhost:{{.PORT}}/actuator/health/liveness | jq .'
eda:outbox:
desc: |
Dump the latest entries in the pyfly_eda_outbox table. Quick way to
see what's been published from the API to the Postgres-backed EDA
bus and what's been consumed by the worker. Reads the live container's
Postgres.
cmds:
- |
docker compose exec -T postgres psql -U idp -d flydocs -c "
SELECT id, destination, event_type, payload, created_at
FROM pyfly_eda_outbox
ORDER BY id DESC
LIMIT 10;
"
version:
desc: Curl the /api/v1/version endpoint of the running API.
cmds:
- 'curl -fsS http://localhost:{{.PORT}}/api/v1/version | jq .'
openapi:
desc: Dump the OpenAPI document.
cmds:
- 'curl -fsS http://localhost:{{.PORT}}/openapi.json | jq .'