-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
177 lines (156 loc) · 4.31 KB
/
Taskfile.yaml
File metadata and controls
177 lines (156 loc) · 4.31 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
# https://taskfile.dev
version: "3"
vars:
CERTS_DIR: "{{.ROOT_DIR}}/.certs"
HTTPBUN_HOST: httpbun.local
HTTPBUN_PORT: "443"
HTTPBUN_URL: "https://{{.HTTPBUN_HOST}}:{{.HTTPBUN_PORT}}"
tasks:
# Certificate generation using trustme
certs:
desc: Generate SSL certificates for e2e testing
cmds:
- uv run python scripts/generate_certs.py
sources:
- scripts/generate_certs.py
generates:
- .certs/ca.pem
- .certs/server.pem
- .certs/server.key
# Docker container management
httpbun:start:
desc: Start httpbun container with SSL
deps: [certs]
cmds:
- |
# Check if hosts entry exists
if ! grep -q "{{.HTTPBUN_HOST}}" /etc/hosts; then
echo "ERROR: Add '127.0.0.1 {{.HTTPBUN_HOST}}' to /etc/hosts"
echo "Run: echo '127.0.0.1 {{.HTTPBUN_HOST}}' | sudo tee -a /etc/hosts"
exit 1
fi
- |
# Stop existing container if running
docker rm -f httpbun 2>/dev/null || true
- |
docker run \
--name httpbun \
--detach \
--publish {{.HTTPBUN_PORT}}:443 \
--volume {{.CERTS_DIR}}:/certs:ro \
--env HTTPBUN_TLS_CERT=/certs/server.pem \
--env HTTPBUN_TLS_KEY=/certs/server.key \
--pull always \
sharat87/httpbun
- |
# Wait for container to be ready
echo "Waiting for httpbun to start..."
sleep 2
for i in $(seq 1 10); do
if curl -sf --cacert {{.CERTS_DIR}}/ca.pem {{.HTTPBUN_URL}}/get > /dev/null 2>&1; then
echo "httpbun is ready!"
exit 0
fi
sleep 1
done
echo "ERROR: httpbun failed to start"
docker logs httpbun
exit 1
httpbun:stop:
desc: Stop and remove httpbun container
cmds:
- docker rm -f httpbun 2>/dev/null || true
httpbun:logs:
desc: Show httpbun container logs
cmds:
- docker logs httpbun
# Test tasks
test:unit:
desc: Run unit tests only
cmds:
- uv run pytest tests/unit/ {{.CLI_ARGS}}
test:e2e:
desc: Run e2e tests (requires httpbun running)
env:
HTTPR_E2E_URL: "{{.HTTPBUN_URL}}"
HTTPR_E2E_CA: "{{.CERTS_DIR}}/ca.pem"
cmds:
- uv run pytest tests/e2e/ -v {{.CLI_ARGS}}
test:benchmark:
desc: Run performance benchmarks
cmds:
- uv run pytest tests/benchmark/ --benchmark-only -v {{.CLI_ARGS}}
test:benchmark:json:
desc: Run benchmarks and output JSON (for CI)
cmds:
- uv run pytest tests/benchmark/ --benchmark-only --benchmark-json=benchmark-results.json {{.CLI_ARGS}}
test:
desc: Run all tests (unit + e2e)
cmds:
- task: test:unit
- task: e2e
# Composite e2e workflow
e2e:
desc: Run full e2e test workflow (start httpbun, test, stop)
cmds:
- task: httpbun:start
- defer: { task: httpbun:stop }
- task: test:e2e
e2e:local:
desc: Start httpbun and run e2e tests (keep container running)
cmds:
- task: httpbun:start
- task: test:e2e
# Setup helpers
setup:hosts:
desc: Show command to add hosts entry (requires sudo)
cmds:
- |
if grep -q "{{.HTTPBUN_HOST}}" /etc/hosts; then
echo "✓ hosts entry already exists"
else
echo "Run the following command to add hosts entry:"
echo ""
echo " echo '127.0.0.1 {{.HTTPBUN_HOST}}' | sudo tee -a /etc/hosts"
echo ""
fi
# Development helpers
dev:
desc: Build Rust extension for development
cmds:
- uv run maturin develop
lint:
desc: Run Python linters (ruff + mypy)
cmds:
- uv run ruff check .
- uv run mypy httpr/
lint:rust:
desc: Run Rust linters (fmt + clippy)
cmds:
- cargo fmt --check
- cargo clippy -- -D warnings
lint:all:
desc: Run all linters (Python + Rust)
cmds:
- task: lint
- task: lint:rust
fmt:
desc: Format Python code (ruff)
cmds:
- uv run ruff format .
- uv run ruff check --fix .
fmt:rust:
desc: Format Rust code
cmds:
- cargo fmt
fmt:all:
desc: Format all code (Python + Rust)
cmds:
- task: fmt
- task: fmt:rust
check:
desc: Run all checks (lint + test) - use before committing
cmds:
- task: lint:all
- task: dev
- task: test:unit