forked from agntcy/slim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
445 lines (387 loc) · 11.8 KB
/
Copy pathTaskfile.yaml
File metadata and controls
445 lines (387 loc) · 11.8 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
# Copyright AGNTCY Contributors (https://github.com/agntcy)
# SPDX-License-Identifier: Apache-2.0
version: "3"
includes:
tools:
taskfile: ./tasks/tools.yaml
internal: true
docs:
taskfile: docs/Taskfile.yml
excludes: [default]
silent: true
set: [pipefail]
shopt: [globstar]
vars:
GLOBAL_ARGS: '{{.GLOBAL_ARGS | default "--workspace"}}'
CARGO_COMPONENTS: "cargo-sort cargo-audit cargo-llvm-cov cargo-machete cargo-deny typos-cli"
PROFILE: '{{.PROFILE | default "debug"}}'
RELEASE:
sh: '[[ {{.PROFILE}} == "release" ]] && echo "--release" || echo ""'
CURRENT_TARGET:
sh: 'rustc -vV | sed -n "s|host: ||p"'
TARGET: '{{.TARGET | default ""}}'
TARGET_ARGS:
sh: '[[ -z "{{.TARGET}}" ]] && echo '''' || echo ''--target {{.TARGET}}'''
TARGET_DIR:
sh: '[[ -z "{{.TARGET}}" ]] && echo "target" || echo "target/{{.TARGET}}"'
TARGET_ARCH:
sh: '[[ -z "{{.TARGET}}" ]] && echo "" || echo {{.TARGET}} | cut -d"-" -f1'
TARGET_OS:
sh: '[[ -z "{{.TARGET}}" ]] && echo "" || echo {{.TARGET}} | cut -d"-" -f3'
TARGET_ABI:
sh: '[[ -z "{{.TARGET}}" ]] && echo "" || echo {{.TARGET}} | cut -d"-" -f4'
LLVM_VERSION: '{{ .LLVM_VERSION | default "19" }}'
OBJCOPY: 'llvm-objcopy-{{.LLVM_VERSION}}'
GNU_CLIB_VERSION: '{{.GNU_CLIB_VERSION | default "2.28"}}'
TOOLS_INSTALL_DIR: '{{.TOOLS_INSTALL_DIR | default ""}}'
tasks:
default:
cmds:
- task -l
version:
desc: Get version
cmds:
- git describe --tags --match "v*" | cut -c 2-
# ─── Build & run ──────────────────────────────────────────────────────
build:
desc: "Build the project"
deps:
- task: install-target
cmds:
- cargo build {{.RELEASE}} {{.TARGET_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--all-targets --locked"}}'
build:strip:
desc: "Build the project and strip the debug symbols"
cmds:
- task: build
- task: strip
vars:
TARGET_BIN: "{{.TARGET_DIR}}/{{.PROFILE}}/slim"
run:
desc: "Run a binary"
cmds:
- "cargo run {{.RELEASE}} --bin {{.BIN}} {{.ARGS}} -- {{.BIN_ARGS}}"
vars:
BIN: '{{.BIN | default "slim"}}'
ARGS: '{{ .ARGS | default "" }}'
BIN_ARGS: '{{ .BIN_ARGS | default "" }}'
run:server:
desc: "Run the server"
cmds:
- task: build
- task: run
vars:
ARGS: ""
BIN: "slim"
BIN_ARGS: "--config ./config/base/server-config.yaml"
run:server-with-otel:
desc: "Run the server with OpenTelemetry enabled"
cmds:
- task: build
- task: run
vars:
ARGS: ""
BIN: "slim"
BIN_ARGS: "--config ./config/telemetry/server-config.yaml"
slimctl:run:
desc: "Run the Rust slimctl binary"
cmds:
- task: run
vars:
BIN: "slimctl"
ARGS: "--package agntcy-slimctl"
BIN_ARGS: "{{.BIN_ARGS}}"
vars:
BIN_ARGS: '{{.BIN_ARGS | default "--help"}}'
slimctl:build:
desc: "Build Rust slimctl and stage it in .dist/bin"
cmds:
- cargo build --package agntcy-slimctl --profile {{.PROFILE}} {{.TARGET_ARGS}}
- mkdir -p .dist/bin
- cp {{.TARGET_DIR}}/{{.PROFILE}}/slimctl .dist/bin/slimctl
vars:
PROFILE: '{{.PROFILE | default "debug"}}'
control-plane:build:
desc: "Build Rust control-plane binary and stage it in .dist/bin"
cmds:
- cargo build --package agntcy-slim-control-plane
- mkdir -p .dist/bin
- cp target/debug/slim-control-plane .dist/bin/control-plane
crossbuild:
desc: "Cross-compile the project using cargo-zigbuild"
deps:
- task: install-target
- task: install-cargo-components
vars:
COMPONENTS: "cargo-zigbuild"
- task: tools:zig
- task: tools:dlltool-wrapper
cmds:
- |
TARGET_ABI="{{.TARGET_ABI}}"
TARGET_OS="{{.TARGET_OS}}"
ARGS=()
if [[ "$TARGET_OS" == "linux" || "$TARGET_ABI" == "gnu" ]]; then
LIBC_VERSION=""
if [[ "$TARGET_ABI" == "gnu" ]]; then
LIBC_VERSION=".{{.GNU_CLIB_VERSION}}"
fi
ARGS=(
"zigbuild"
"--target"
"{{.TARGET}}$LIBC_VERSION"
{{.RELEASE}}
{{.ARGS}}
)
else
ARGS=(
"build"
"--target"
"{{.TARGET}}"
{{.RELEASE}}
{{.ARGS}}
)
fi
echo cargo ${ARGS[*]}
PATH="{{.TOOLS_INSTALL_DIR}}:$PATH" cargo "${ARGS[@]}"
vars:
ARGS: '{{ .ARGS | default "" }}'
strip:
desc: "Strip the binary"
cmds:
- "{{.OBJCOPY}} --only-keep-debug {{.TARGET_BIN}} {{.TARGET_BIN}}.dbg"
- "{{.OBJCOPY}} --strip-unneeded {{.TARGET_BIN}}"
- "{{.OBJCOPY}} --add-gnu-debuglink={{.TARGET_BIN}} {{.TARGET_BIN}}.dbg"
vars:
TARGET_BIN: '{{.TARGET_BIN | default ""}}'
# ─── Lint & check ─────────────────────────────────────────────────────
fmt:
desc: "Format the code"
cmds:
- cargo fmt {{.ARGS}}
vars:
ARGS: '{{ .ARGS | default "" }}'
fmt:check:
desc: "Check the code formatting"
cmds:
- task: fmt
vars:
ARGS: "-- --check"
check:
desc: "Check the project"
deps:
- task: install-target
cmds:
- cargo check {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--all-targets --locked"}}'
clippy:
desc: "Run clippy"
deps:
- task: check
cmds:
- cargo clippy {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}} -- -D warnings
vars:
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
sort:
desc: "Sort the dependencies"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "cargo-sort"
cmds:
- cargo sort {{.GLOBAL_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default ""}}'
sort:check:
desc: "Check the dependencies are sorted"
cmds:
- task: sort
vars:
ARGS: "--check"
unused:check:
desc: "Check for unused dependencies"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "cargo-machete"
cmds:
- cargo machete {{.ARGS}}
vars:
ARGS: '{{ .ARGS | default "" }}'
licenses:
desc: "Check for licenses"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "cargo-deny"
cmds:
- cargo deny check {{.ARGS}}
vars:
ARGS: '{{ .ARGS | default "" }}'
typos:
desc: "Check for typos"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "typos-cli"
cmds:
- typos
vuln:
desc: "Check for vulnerabilities"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "cargo-audit"
cmds:
- cargo audit {{.ARGS}}
vars:
ARGS: '{{ .ARGS | default "" }}'
lint:
desc: "Run the linter"
cmds:
- task: fmt:check
- task: clippy
- task: vuln
- task: sort:check
- task: unused:check
- task: licenses
- task: typos
# ─── Test & coverage ──────────────────────────────────────────────────
test:
desc: "Run the tests"
cmds:
- ulimit -n 4096 2>/dev/null || true; cargo test {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
- task: core:test
vars:
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
test:build:
desc: "Build the tests"
deps:
- task: install-target
cmds:
- ulimit -n 4096 2>/dev/null || true; cargo test --no-run {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
test:coverage:
desc: "Run tests coverage"
deps:
- task: install-cargo-components
vars:
COMPONENTS: "cargo-llvm-cov"
cmds:
- ulimit -n 4096 2>/dev/null || true; cargo llvm-cov --lcov --output-path lcov.info {{.GLOBAL_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--all-targets --locked --all-features"}}'
coverage-full:
desc: "Run full tests coverage"
cmds:
- task: test:coverage
vars:
ARGS: "--all-targets --locked --all-features"
- task: core:test
core:test:
desc: "Run core end to end tests"
dir: ./crates/testing
cmds:
- |
task test:group-session
task test:point-to-point-session
# ─── Misc ─────────────────────────────────────────────────────────────
clean:
desc: "Clean the project"
cmds:
- cargo clean {{.ARGS}}
vars:
ARGS: '{{ .ARGS | default "" }}'
doc:
desc: "Generate the documentation"
cmds:
- cargo doc {{.RELEASE}} {{.TARGET_ARGS}} {{.GLOBAL_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--no-deps --locked --all-features"}}'
fetch:
desc: "Fetch the dependencies"
deps:
- task: install-target
cmds:
- cargo fetch {{.TARGET_ARGS}} {{.ARGS}}
vars:
ARGS: '{{.ARGS | default "--locked"}}'
run-command:
desc: "Run a command"
dir: '{{.DIR | default ""}}'
deps:
- task: install-target
cmds:
- "{{.COMMAND}}"
vars:
COMMAND: '{{.COMMAND | default ""}}'
print-vars:
desc: "Print the variables"
cmds:
- |
echo "Variables:"
echo " PROFILE: {{.PROFILE}}"
echo " RELEASE: {{.RELEASE}}"
echo " TARGET: {{.TARGET}}"
echo " TARGET_ARGS: {{.TARGET_ARGS}}"
echo " TARGET_ARCH: {{.TARGET_ARCH}}"
echo " LLVM_VERSION: {{.LLVM_VERSION}}"
echo " OBJCOPY: {{.OBJCOPY}}"
echo ""
slim:version:
desc: "Get version from corresponding git tag"
cmds:
- git describe --tags --match "slim-v*" | cut -d 'v' -f 2
generate:grpc-json-schema:
desc: "Generate the gRPC schema"
cmds:
- cargo run --bin generate-schema
telemetry:start:
desc: "Start telemetry stack"
cmds:
- docker compose -f ./config/telemetry/docker-compose.yml up
# ─── Cargo component install ──────────────────────────────────────────
tools:fetch:
desc: "Fetch tool dependencies"
cmds:
- task: install-cargo-components
vars:
COMPONENTS: "{{.CARGO_COMPONENTS}}"
tools:hash:
desc: "Compute the SHA-256 hash of the CARGO_COMPONENTS string"
cmds:
- cmd: sh -c "echo -n '{{.CARGO_COMPONENTS}}' | sha256sum | cut -d ' ' -f1"
install-uniffi-bindgen:
desc: "Install uniffi-bindgen CLI tool"
status:
- which uniffi-bindgen-cli
cmds:
- echo "📦 Installing uniffi-bindgen-cli..."
- cargo install uniffi-bindgen-cli --git https://github.com/mozilla/uniffi-rs.git --tag v0.31.1
- echo "✅ uniffi-bindgen-cli installed"
install-target:
desc: "Install the target"
internal: true
status:
- '[[ -z "{{.TARGET}}" ]]'
cmds:
- rustup target add {{.TARGET}}
install-cargo-components:
desc: "Install cargo components"
internal: true
deps:
- task: install-cargo-binstall
cmds:
- cargo binstall --no-confirm {{.COMPONENTS}}
vars:
COMPONENTS: '{{ .COMPONENTS | default "" }}'
install-cargo-binstall:
desc: "Install cargo-binstall"
internal: true
status:
- cargo binstall --help >/dev/null 2>&1
cmds:
- cargo install cargo-binstall --locked