-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
557 lines (497 loc) · 16.6 KB
/
Taskfile.yml
File metadata and controls
557 lines (497 loc) · 16.6 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# https://taskfile.dev
version: "3"
vars:
PROJECT_NAME: edge
BUILD_DIR: zig-out
HELM_CHART_DIR: charts/tero-edge
HELM_CHART_NAME: tero-edge
HELM_NAMESPACE: tero-system
HELM_RELEASE: tero-edge
tasks:
default:
desc: "Build the project in debug mode"
aliases: [b]
cmds:
- zig build
build:
desc: "Build the project with specified optimization"
aliases: [build-opt]
cmds:
- zig build -Doptimize={{.OPTIMIZE | default "Debug"}}
build:release:
desc: "Build the project in release mode (ReleaseFast)"
aliases: [br, release]
cmds:
- zig build -Doptimize=ReleaseFast
build:safe:
desc: "Build the project in ReleaseSafe mode"
aliases: [bs]
cmds:
- zig build -Doptimize=ReleaseSafe
- echo "✅ Built safe"
build:small:
desc: "Build the project in ReleaseSmall mode"
aliases: [bsm]
cmds:
- zig build -Doptimize=ReleaseSmall
run:
desc: "Build and run the project"
aliases: [r]
cmds:
- zig build run
run:release:
desc: "Build and run the project in release mode"
aliases: [rr]
cmds:
- zig build run -Doptimize=ReleaseFast
test:
desc: "Run all tests"
aliases: [t]
cmds:
- zig build test -Doptimize=ReleaseSafe
test:file:
desc: "Run tests for a specific file"
aliases: [tf]
cmds:
- |
if [ -z "{{.FILE}}" ]; then
echo "Usage: task test:file FILE=<path>"
echo "Example: task test:file FILE=src/json/pretty_print.zig"
exit 1
fi
zig test {{.FILE}}
test:summary:
desc: "Run tests with summary output"
aliases: [ts]
cmds:
- zig build test --summary all
format:
desc: "Format all Zig source files"
aliases: [fmt, f]
dir: "{{.TASKFILE_DIR}}"
cmds:
- zig fmt src/
- zig fmt build.zig
format:check:
desc: "Check if code is formatted correctly"
aliases: [fmt-check, fc]
dir: "{{.TASKFILE_DIR}}"
cmds:
- zig fmt --check src/
- zig fmt --check build.zig
lint:
desc: "Run linting checks"
aliases: [l]
cmds:
- task: format:check
- echo "✅ Linting complete"
clean:
desc: "Clean build artifacts"
aliases: [c]
cmds:
- rm -rf zig-out/
- rm -rf zig-cache/
- rm -rf .zig-cache/
- echo "✅ Cleaned build artifacts"
check:
desc: "Check the project (build without running)"
cmds:
- zig build --summary failures
docs:
desc: "Generate documentation"
cmds:
- echo "Generating documentation..."
- zig build-lib src/root.zig -femit-docs -fno-emit-bin
- echo "✅ Documentation generated in zig-out/doc/"
deps:
desc: "Check dependencies and Zig installation"
cmds:
- zig version
- zig env
benchmark:
desc: "Run full benchmark suite with oha and hyperfine"
aliases: [bench, bm]
cmds:
- ./bench/run.sh
benchmark:quick:
desc: "Run quick benchmark (1000 requests)"
aliases: [bench-quick, bmq]
cmds:
- ./bench/run.sh -n 1000 -c 10
benchmark:heavy:
desc: "Run heavy benchmark (100000 requests, 100 connections)"
aliases: [bench-heavy, bmh]
cmds:
- ./bench/run.sh -n 100000 -c 100
benchmark:ci:
desc: "Run benchmark in CI mode (skip build, use existing binaries)"
cmds:
- ./bench/run.sh --skip-build
benchmark:logging:
desc: "Run edge-tail logging integration tests"
aliases: [bench-logging, bml]
cmds:
- ./bench/logging/run.sh
benchmark:logging:metrics:
desc: "Run edge-tail logging benchmark metric profiles (logs/sec, CPU, RSS)"
aliases: [bench-logging-metrics, bmlm]
vars:
BENCH_LINES: 50000000
cmds:
- EDGE_TAIL_STDIN_LINES={{.BENCH_LINES}} ./bench/logging/run.sh -s tests/test_benchmark_metrics.py
benchmark:logging:persistent:
desc: "Run persistent edge-tail logging workload for Instruments profiling"
aliases: [bench-logging-persistent, bmlp]
vars:
FILES: '{{.FILES | default "12"}}'
TARGET_LPS: '{{.TARGET_LPS | default "18000"}}'
FORMAT: '{{.FORMAT | default "raw"}}'
IO_ENGINE: '{{.IO_ENGINE | default "auto"}}'
DROP_50PCT: '{{.DROP_50PCT | default "0"}}'
DURATION_S: '{{.DURATION_S | default "0"}}'
cmds:
- zig build tail -Doptimize=Debug
- |
ARGS=""
if [ "{{.DROP_50PCT}}" = "1" ]; then
ARGS="$ARGS --drop-50pct"
fi
if [ "{{.DURATION_S}}" != "0" ]; then
ARGS="$ARGS --duration-s {{.DURATION_S}}"
fi
uv run --project bench/logging python bench/logging/persistent_benchmark.py \
--edge-tail-bin zig-out/bin/edge-tail \
--files {{.FILES}} \
--target-lps {{.TARGET_LPS}} \
--format {{.FORMAT}} \
--io-engine {{.IO_ENGINE}} \
$ARGS
benchmark:history:
desc: "Run benchmarks and save to dated history folder"
aliases: [bench-history, bmh]
vars:
DATE:
sh: date -u +"%Y-%m-%d"
REQUESTS: '{{.REQUESTS | default (env "REQUESTS") | default "10000"}}'
CONNECTIONS: '{{.CONNECTIONS | default (env "CONNECTIONS") | default "50"}}'
cmds:
- mkdir -p bench/history/{{.DATE}}
- ./bench/run.sh --requests {{.REQUESTS}} --connections {{.CONNECTIONS}} --output bench/history/{{.DATE}}
echo-server:
desc: "Build and run the echo server for manual testing"
cmds:
- zig build echo-server -Doptimize=ReleaseFast
- ./zig-out/bin/echo-server {{.PORT | default "9999"}}
benchmark:setup:
desc: "Install benchmark dependencies (oha, jq)"
cmds:
- |
echo "Installing benchmark dependencies..."
if [ "$(uname)" = "Darwin" ]; then
brew install oha jq
elif command -v cargo >/dev/null 2>&1; then
cargo install oha
echo "Please also install jq via your package manager"
else
echo "Please install oha and jq manually:"
echo " https://github.com/hatoo/oha"
exit 1
fi
echo "Benchmark dependencies installed"
watch:
desc: "Watch for changes and rebuild"
aliases: [w]
cmds:
- |
echo "Watching for changes... (Ctrl+C to stop)"
while true; do
zig build 2>&1 | grep -v "Build succeeded"
inotifywait -e modify -r src/ build.zig 2>/dev/null || \
fswatch -1 -r src/ build.zig 2>/dev/null || \
sleep 2
done
watch:test:
desc: "Watch for changes and run tests"
aliases: [wt]
cmds:
- |
echo "Watching for changes and running tests... (Ctrl+C to stop)"
while true; do
zig build test
inotifywait -e modify -r src/ 2>/dev/null || \
fswatch -1 -r src/ 2>/dev/null || \
sleep 2
done
coverage:
desc: "Generate test coverage report"
cmds:
- echo "Coverage reporting is not yet standardized in Zig"
- echo "Consider using kcov or similar tools manually"
analyze:
desc: "Run static analysis"
cmds:
- zig build --verbose
do:
desc: "Run all pre-commit checks"
cmds:
- task: format
- task: lint
- task: test
- echo "✅ All checks passed"
signoff:
desc: "Sign off the codebase"
aliases: ["sign", "s"]
cmds:
- task: do
- task: build:safe
- gh signoff
install:
desc: "Install the binary"
cmds:
- zig build -Doptimize=ReleaseFast
- echo "Binary installed to {{.BUILD_DIR}}/bin/{{.PROJECT_NAME}}"
uninstall:
desc: "Remove installed binary"
cmds:
- rm -f {{.BUILD_DIR}}/bin/{{.PROJECT_NAME}}
- echo "✅ Binary removed"
info:
desc: "Show project information"
cmds:
- echo "Project {{.PROJECT_NAME}}"
- echo "Build directory {{.BUILD_DIR}}"
- zig version
- echo ""
- echo "Available build modes:"
- echo " - Debug (default)"
- echo " - ReleaseFast (task build:release)"
- echo " - ReleaseSafe (task build:safe)"
- echo " - ReleaseSmall (task build:small)"
repl:
desc: "Start Zig REPL (if available)"
cmds:
- |
if command -v ziggy >/dev/null 2>&1; then
ziggy
else
echo "No Zig REPL found. Install ziggy: https://github.com/zigtools/ziggy"
fi
# =============================================================================
# Build & Release
# =============================================================================
build:container:
desc: "🐳 Build container for a distribution (DIST=edge|datadog|otlp|prometheus|tail)"
dir: "{{.TASKFILE_DIR}}"
vars:
DIST: '{{.DIST | default "datadog"}}'
GIT_SHA:
sh: git rev-parse --short HEAD
GIT_SHA_FULL:
sh: git rev-parse HEAD
VERSION:
sh: |
if git describe --tags --always --dirty >/dev/null 2>&1; then
git describe --tags --always --dirty
else
echo dev
fi
cmds:
- |
echo "🐳 Building edge-{{.DIST}} container..."
if [ -n "$CI" ]; then
# CI: Use buildx with GitHub Actions cache
docker buildx build \
--build-arg DISTRIBUTION={{.DIST}} \
--build-arg VERSION={{.VERSION}} \
--build-arg COMMIT={{.GIT_SHA_FULL}} \
--cache-from type=gha,scope=edge-{{.DIST}} \
--cache-to type=gha,mode=max,scope=edge-{{.DIST}} \
-t edge-{{.DIST}}:sha-{{.GIT_SHA}} \
-t edge-{{.DIST}}:local \
--load \
.
else
# Local: Standard build
DOCKER_BUILDKIT=1 docker build \
--build-arg DISTRIBUTION={{.DIST}} \
--build-arg VERSION={{.VERSION}} \
--build-arg COMMIT={{.GIT_SHA_FULL}} \
-t edge-{{.DIST}}:sha-{{.GIT_SHA}} \
-t edge-{{.DIST}}:local \
.
fi
echo "✅ Built edge-{{.DIST}}:sha-{{.GIT_SHA}} (also tagged as edge-{{.DIST}}:local)"
build:containers:
desc: "🐳 Build all distribution containers"
cmds:
- task: build:container
vars: { DIST: "edge" }
- task: build:container
vars: { DIST: "datadog" }
- task: build:container
vars: { DIST: "otlp" }
- task: build:container
vars: { DIST: "prometheus" }
- task: build:container
vars: { DIST: "tail" }
push:container:
desc: "🚀 Push container to GCP Artifact Registry (DIST=edge|datadog|otlp|prometheus|tail)"
dir: "{{.TASKFILE_DIR}}"
vars:
DIST: '{{.DIST | default "datadog"}}'
GIT_SHA:
sh: git rev-parse --short HEAD
GCP_PROJECT_ID:
sh: echo "${GCP_PROJECT_ID:-usetero-dev}"
GCP_REGION:
sh: echo "${GCP_REGION:-us-central1}"
GCP_REGISTRY:
sh: echo "{{.GCP_REGION}}-docker.pkg.dev/{{.GCP_PROJECT_ID}}/edge"
preconditions:
- sh: docker image inspect edge-{{.DIST}}:sha-{{.GIT_SHA}} >/dev/null 2>&1
msg: "Container edge-{{.DIST}}:sha-{{.GIT_SHA}} not found. Run 'task build:container DIST={{.DIST}}' first"
cmds:
- |
echo "🚀 Pushing edge-{{.DIST}} to GCP Artifact Registry..."
# Tag for GCP registry
docker tag edge-{{.DIST}}:sha-{{.GIT_SHA}} {{.GCP_REGISTRY}}/edge-{{.DIST}}:{{.GIT_SHA}}
docker tag edge-{{.DIST}}:sha-{{.GIT_SHA}} {{.GCP_REGISTRY}}/edge-{{.DIST}}:latest
# Push both tags
docker push {{.GCP_REGISTRY}}/edge-{{.DIST}}:{{.GIT_SHA}}
docker push {{.GCP_REGISTRY}}/edge-{{.DIST}}:latest
echo "✅ Pushed edge-{{.DIST}}:{{.GIT_SHA}} and edge-{{.DIST}}:latest"
push:containers:
desc: "🚀 Push all distribution containers to GCP"
cmds:
- task: push:container
vars: { DIST: "edge" }
- task: push:container
vars: { DIST: "datadog" }
- task: push:container
vars: { DIST: "otlp" }
- task: push:container
vars: { DIST: "prometheus" }
- task: push:container
vars: { DIST: "tail" }
release:
desc: "🎯 Build and push all containers (for CI)"
cmds:
- task: build:containers
- task: push:containers
release:container:
desc: "🎯 Build and push a specific distribution (DIST=edge|datadog|otlp|prometheus|tail)"
vars:
DIST: '{{.DIST | default "datadog"}}'
cmds:
- task: build:container
vars: { DIST: "{{.DIST}}" }
- task: push:container
vars: { DIST: "{{.DIST}}" }
# =============================================================================
# CI Setup
# =============================================================================
ci:setup:
desc: "🔧 Install CI/development dependencies (idempotent, safe to run locally)"
dir: "{{.TASKFILE_DIR}}"
cmds:
- |
echo "🔧 Setting up CI environment..."
# Clean up Docker resources to free disk space (important for CI with testcontainers)
if [ -n "$CI" ]; then
echo "🧹 Cleaning Docker resources in CI..."
docker system prune -af --volumes 2>/dev/null || true
fi
echo "🔧 Checking for required dependencies..."
# Check for hyperscan/vectorscan (needed for catalog service)
if ! pkg-config --exists libhs 2>/dev/null; then
echo "📦 Installing hyperscan..."
if [ "$(uname)" = "Darwin" ]; then
# macOS: use vectorscan (hyperscan replacement)
if command -v brew >/dev/null 2>&1; then
brew install vectorscan pkg-config
else
echo "⚠️ Homebrew not found. Install vectorscan manually or use Hermit."
fi
elif [ "$(uname)" = "Linux" ]; then
# Linux: use hyperscan
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y libhyperscan-dev pkg-config
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y hyperscan-devel pkg-config
else
echo "⚠️ Unknown package manager. Install hyperscan manually."
fi
else
echo "⚠️ Unknown platform: $(uname)"
fi
else
echo "✅ Hyperscan already installed"
fi
echo "✅ CI setup complete"
# =============================================================================
# Helm Chart
# =============================================================================
helm:lint:
desc: "⛵ Lint the tero-edge Helm chart"
cmds:
- helm lint {{.HELM_CHART_DIR}}
helm:template:
desc: "⛵ Render Helm templates locally (VALUES=<file>)"
cmds:
- |
if [ -n "{{.VALUES}}" ]; then
helm template {{.HELM_RELEASE}} {{.HELM_CHART_DIR}} -f {{.VALUES}}
else
helm template {{.HELM_RELEASE}} {{.HELM_CHART_DIR}}
fi
helm:package:
desc: "⛵ Package chart into dist/ (VERSION=<semver> optional)"
cmds:
- mkdir -p dist
- |
if [ -n "{{.VERSION}}" ]; then
helm package {{.HELM_CHART_DIR}} --version {{.VERSION}} --destination dist
else
helm package {{.HELM_CHART_DIR}} --destination dist
fi
helm:install:
desc: "⛵ Install/upgrade chart in cluster (VALUES=<file> optional)"
cmds:
- |
if [ -n "{{.VALUES}}" ]; then
helm upgrade --install {{.HELM_RELEASE}} {{.HELM_CHART_DIR}} -n {{.HELM_NAMESPACE}} --create-namespace -f {{.VALUES}}
else
helm upgrade --install {{.HELM_RELEASE}} {{.HELM_CHART_DIR}} -n {{.HELM_NAMESPACE}} --create-namespace
fi
helm:uninstall:
desc: "⛵ Uninstall chart from cluster"
cmds:
- helm uninstall {{.HELM_RELEASE}} -n {{.HELM_NAMESPACE}}
helm:publish:oci:
desc: "⛵ Publish packaged chart to OCI (REGISTRY=oci://... VERSION=<semver>)"
cmds:
- |
if [ -z "{{.REGISTRY}}" ]; then
echo "Usage: task helm:publish:oci REGISTRY=oci://ghcr.io/<owner>/charts VERSION=<semver>"
exit 1
fi
if [ -z "{{.VERSION}}" ]; then
echo "Usage: task helm:publish:oci REGISTRY=oci://ghcr.io/<owner>/charts VERSION=<semver>"
exit 1
fi
task helm:package VERSION={{.VERSION}}
helm push dist/{{.HELM_CHART_NAME}}-{{.VERSION}}.tgz {{.REGISTRY}}
helm:repo:index:
desc: "⛵ Generate/merge Helm repo index in dist/ (REPO_URL required)"
cmds:
- |
if [ -z "{{.REPO_URL}}" ]; then
echo "Usage: task helm:repo:index REPO_URL=https://<org>.github.io/<repo>/"
exit 1
fi
mkdir -p dist
if [ -f dist/index.yaml ]; then
helm repo index dist --url {{.REPO_URL}} --merge dist/index.yaml
else
helm repo index dist --url {{.REPO_URL}}
fi