-
Notifications
You must be signed in to change notification settings - Fork 42
/
taskfile.yaml
449 lines (409 loc) · 12.7 KB
/
taskfile.yaml
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
version: "3"
env:
TAG: dev
PLATFORM_TAG: latest
KUBECTX: kind-rig
CGO_ENABLED: "0"
run: once
includes:
tools:
taskfile: ./tools/taskfile.yaml
dir: ./tools
tasks:
build:
desc: "🔨 Build all binaries"
deps: [build-rig, build-rig-ops, build-rig-operator, build-rig-proxy]
build-rig:
desc: "🔨 Build rig binary"
deps: [proto]
sources:
- "**/*.go"
generates:
- "bin/rig"
cmds:
- go build -o ./bin/rig ./cmd/rig
build-rig-ops:
desc: "🔨 Build rig-ops binary"
deps: [proto]
sources:
- "**/*.go"
generates:
- "bin/rig-ops"
cmds:
- go build -o ./bin/rig-ops ./cmd/rig-ops
build-rig-operator:
desc: "🔨 Build rig-operator binary"
deps: [proto]
sources:
- "**/*.go"
generates:
- "bin/rig-operator"
cmds:
- go build -o ./bin/rig-operator ./cmd/rig-operator
build-rig-proxy:
desc: "🔨 Build rig-proxy binary"
deps: [proto]
cmds:
- go build -o bin/rig-proxy ./cmd/rig-proxy
build-rig-proto-gen:
desc: "🔨 proto-gen tool"
deps: [proto]
env:
CGO_ENABLED: "0"
sources:
- "**/*.go"
generates:
- "./tools/bin/rig-proto-gen"
cmds:
- go build -o ./tools/bin/rig-proto-gen ./cmd/rig-proto-gen
gen:
desc: "🪄 Run code generation"
deps: [proto, manifests, generate-k8s, docs-gen, mocks, proto-gen]
proto-gen:
desc: "Run proto-gen"
deps:
- build-rig-proto-gen
- proto
sources:
- pkg/api/**/*
generates:
- proto/rig/**/*
cmds:
- ./tools/bin/rig-proto-gen proto/rig
- task: proto
proto:
desc: "🪄 Run protobuf generation"
deps:
- tools:buf
- tools:protoc-gen-go
- tools:protoc-gen-connect-go
- tools:protoc-gen-doc
- tools:protoc-gen-go-grpc
sources:
- proto/rig/**/*
generates:
- gen/go/rig/**/*
- docs/docs/api/platform-api.md
cmds:
- mkdir -p gen/go/rig
- printf "module github.com/rigdev/rig-go-api\n\ngo 1.22\n" > ./gen/go/rig/go.mod
- find . -path './gen/go/rig/*' -type f -name '*.go' -delete
- ./tools/bin/buf generate proto/rig --template proto/buf.gen.yaml
- cd gen/go/rig/; go get -u ./...
- sh -c '! which clang-format > /dev/null || find proto/rig/ -iname *.proto | xargs clang-format -i'
mocks:
desc: "🪄 Run mock generation"
deps: [tools:mockery, proto]
vars:
GOMODCACHE:
sh: go env GOMODCACHE
sources:
- pkg/service/config/config.go
- "{{ .GOMODCACHE }}/sigs.k8s.io/controller-runtime*/pkg/client/*.go"
- "{{ .GOMODCACHE }}/k8s.io/client-go*/discovery/*.go"
generates:
- gen/mocks/**/*.go
- gen/uncommitedmocks/**/*.go
cmds:
- cmd: rm -fr gen/mocks
- cmd: rm -fr gen/mocks_not_commited
- GODEBUG=gotypesalias=0 ./tools/bin/mockery
- GODEBUG=gotypesalias=0 ./tools/bin/mockery --config .mockery_uncommitted.yaml
manifests:
desc: "🪄 Run k8s manifests generation"
deps: [tools:controller-gen, proto]
sources:
- pkg/api/v1alpha1/*.go
- pkg/api/v1alpha2/*.go
- pkg/controller/*.go
generates:
- deploy/kustomize/rbac/**/*.yaml
- deploy/kustomize/webhook/**/*.yaml
- deploy/kustomize/crd/**/*.yaml
cmds:
- |
./tools/bin/controller-gen rbac:roleName=rig crd webhook \
paths="./pkg/api/v1alpha1;./pkg/api/v1alpha2;./pkg/controller" \
output:rbac:dir=deploy/kustomize/rbac \
output:webhook:dir=deploy/kustomize/webhook \
output:crd:dir=deploy/kustomize/crd/bases
- python3 ./scripts/crdcopy.py
generate-k8s:
desc: "🪄 Run runtime.Object implementaion generation"
deps: [tools:controller-gen, proto]
sources:
- pkg/api/**/*.go
generates:
- pkg/api/**/zz_generated.deepcopy.go
cmds:
- ./tools/bin/controller-gen object paths="./pkg/api/..."
docs:
desc: "📝 Run documentation site"
dir: docs
cmds:
- npm i
- npm run start
docs-gen:
desc: "📚 Generate api references"
deps:
[
tools:crd-ref-docs,
proto,
docs-gen-builtin-plugins,
docs-gen-capsule-step-plugins,
]
sources:
- docs/crd-ref-docs/**/*
- pkg/api/config/v1alpha1/**/*
- pkg/api/v1alpha1/**/*
- pkg/api/v1alpha2/**/*
- pkg/api/platform/v1/**/*
generates:
- docs/docs/api/config/v1alpha1.md
- docs/docs/api/v1alpha1.md
- docs/docs/api/v1alpha2.md
- docs/docs/api/platform/v1.md
cmds:
- |
./tools/bin/crd-ref-docs --renderer markdown \
--config ./docs/crd-ref-docs/config.yaml \
--templates-dir ./docs/crd-ref-docs/templates \
--source-path ./pkg/api/config/v1alpha1 \
--output-path ./docs/docs/api/config/v1alpha1.md
- |
./tools/bin/crd-ref-docs --renderer markdown \
--config ./docs/crd-ref-docs/config.yaml \
--templates-dir ./docs/crd-ref-docs/templates \
--source-path ./pkg/api/v1alpha1 \
--output-path ./docs/docs/api/v1alpha1.md
- |
./tools/bin/crd-ref-docs --renderer markdown \
--config ./docs/crd-ref-docs/v1alpha2-config.yaml \
--templates-dir ./docs/crd-ref-docs/templates \
--source-path ./pkg/api/v1alpha2 \
--output-path ./docs/docs/api/v1alpha2.md
- |
./tools/bin/crd-ref-docs --renderer markdown \
--config ./docs/crd-ref-docs/platform.yaml \
--templates-dir ./docs/crd-ref-docs/templates \
--source-path ./pkg/api/platform/v1 \
--output-path ./docs/docs/api/platformv1.md
docs-gen-builtin-plugins:
desc: "📚 Generate builtin plugin docs"
sources:
- "plugins/builtin/**/*"
vars:
PLUGINS:
sh: find ./plugins/builtin -mindepth 1 -maxdepth 1 -type d | xargs -I{} basename {}
cmds:
- for: { var: PLUGINS }
task: docs-gen-plugin
vars:
PLUGIN: "{{ .ITEM }}"
DIR: "builtin"
docs-gen-capsule-step-plugins:
desc: "📚 Generate capsule step plugin docs"
sources:
- "plugins/capsulesteps/**/*"
vars:
PLUGINS:
sh: find ./plugins/capsulesteps -mindepth 1 -maxdepth 1 -type d | xargs -I{} basename {}
cmds:
- for: { var: PLUGINS }
task: docs-gen-plugin
vars:
PLUGIN: "{{ .ITEM }}"
DIR: "capsulesteps"
docs-gen-plugin:
run: when_changed
deps: [tools:crd-ref-docs, proto]
sources:
- docs/crd-ref-docs/**/*
- plugins/{{ .DIR }}/{{ .PLUGIN }}/*
generates:
- docs/docs/plugins/{{ .DIR }}/{{ .PLUGIN }}.md
cmds:
- |
./tools/bin/crd-ref-docs --renderer markdown \
--config ./docs/plugin-ref-docs/config.yaml \
--templates-dir ./docs/plugin-ref-docs/templates \
--source-path ./plugins/{{ .DIR }}/{{ .PLUGIN }} \
--output-path ./plugins/{{ .DIR }}/{{ .PLUGIN }}/temp.md
- python3 ./tools/readme_truncate.py plugins/{{ .DIR }}/{{ .PLUGIN }}/README.md
- cat ./plugins/{{ .DIR }}/{{ .PLUGIN }}/temp.md >> ./plugins/{{ .DIR }}/{{ .PLUGIN }}/README.md
- rm ./plugins/{{ .DIR }}/{{ .PLUGIN }}/temp.md
- cp plugins/{{ .DIR }}/{{ .PLUGIN }}/README.md docs/docs/operator-manual/plugins/{{ .DIR }}/{{ .PLUGIN }}.mdx
lint:
desc: "🚨 Run linting"
deps: [tools:golangci-lint, proto, mocks]
cmds:
- ./tools/bin/golangci-lint run -v --timeout 10m
test:
desc: "✅ Run unit tests"
deps: [tools:gotestsum, proto, mocks]
env:
CGO_ENABLED: "1"
cmds:
- |
./tools/bin/gotestsum \
--format-hide-empty-pkg \
--hide-summary skipped -- \
-race \
-short \
./...
test-all:
desc: "✅ Run all tests"
deps:
[
tools:gotestsum,
tools:setup-envtest,
proto,
mocks,
manifests,
build-rig-operator,
]
env:
RIG_PLUGIN_DIR: "{{ .ROOT_DIR }}/bin/plugin"
GOEXPERIMENT: nocoverageredesign
CGO_ENABLED: "1"
cmds:
- |
export KUBEBUILDER_ASSETS="`./tools/bin/setup-envtest use 1.28.0 --bin-dir "{{ .ROOT_DIR }}/tools/bin" -p path`"
./tools/bin/gotestsum \
--format-hide-empty-pkg \
--junitfile test-result.xml -- \
-race \
-coverprofile cover.out \
-coverpkg $(go list ./... | grep rigdev/rig/pkg | tr "\n" ",") \
-covermode atomic \
./...
test-integration:
desc: "✅ Run integration tests"
deps:
[
tools:gotestsum,
tools:setup-envtest,
proto,
manifests,
build-rig-operator,
]
env:
RIG_PLUGIN_DIR: "{{ .ROOT_DIR }}/bin/plugin"
CGO_ENABLED: "1"
cmds:
- mkdir -p output/test-integration
- |
export KUBEBUILDER_ASSETS="`./tools/bin/setup-envtest use 1.28.0 --bin-dir "{{ .ROOT_DIR }}/tools/bin" -p path`"
./tools/bin/gotestsum \
--format-hide-empty-pkg -- \
-race \
-run "^TestIntegration" \
./...
docker:
desc: "🐳 Build docker image"
deps: [gen]
cmds:
- docker build -t ghcr.io/rigdev/rig-operator:${TAG} -f ./build/package/Dockerfile .
docker-local:
desc: "🐳 Build local docker image"
deps: [build-rig-operator]
cmds:
- docker build -t ghcr.io/rigdev/rig-operator:${TAG} -f ./build/package/Dockerfile.local .
docker-proxy:
desc: "🐳 Build docker proxy image"
cmds:
- docker build -t ghcr.io/rigdev/rig-proxy:${TAG} -f ./build/package/proxy/Dockerfile .
docker-proxy-local:
desc: "🐳 Build docker proxy local image"
deps: [build-rig-proxy]
cmds:
- docker build -t ghcr.io/rigdev/rig-proxy:${TAG} -f ./build/package/proxy/Dockerfile.local .
docker-rig:
desc: "🐳 Build docker rig image"
cmds:
- docker build -t ghcr.io/rigdev/rig:${TAG} -f ./build/package/rig/Dockerfile .
docker-docs:
desc: "🐳 Build docker docs image"
cmds:
- docker build -t ghcr.io/rigdev/docs:${TAG} -f ./build/package/docs/Dockerfile .
deploy-operator:
desc: "🚀 Deploy operator to k8s context defined by $KUBECTX (default: kind-rig)"
cmds:
- |
helm --kube-context ${KUBECTX} \
upgrade --install rig-operator ./deploy/charts/rig-operator \
--namespace rig-system \
--create-namespace \
--set image.tag=${TAG} \
--set config.devModeEnabled=true
deploy-platform:
desc: "🚀 Deploy platform to k8s context defined by $KUBECTX (default: kind-rig)"
cmds:
- |
helm --kube-context ${KUBECTX} \
upgrade --install rig-platform ./deploy/charts/rig-platform \
--namespace rig-system \
--create-namespace \
--set postgres.enabled=true \
--set image.tag=${PLATFORM_TAG} \
--set rig.cluster.dev_registry.enabled=true \
--set rig.cluster.dev_registry.host=localhost:30000 \
--set rig.cluster.dev_registry.cluster_host=registry:5000
kind-create:
desc: "🐋 Create kind cluster with rig dependencies"
deps: [tools:kind]
env:
KIND: /tools/bin/kind
cmds:
- ./deploy/kind/create.sh
kind-load:
desc: "🐋 Load docker image into kind cluster"
deps: [tools:kind, docker]
cmds:
- ./tools/bin/kind load docker-image ghcr.io/rigdev/rig-operator:${TAG} -n rig
kind-load-platform:
desc: "🐋 Load platform docker image into kind cluster"
deps: [tools:kind]
cmds:
- ./tools/bin/kind load docker-image ghcr.io/rigdev/rig-platform:${PLATFORM_TAG} -n rig
kind-deploy:
desc: "🐋 Deploy rig to kind cluster"
deps: [tools:kind, kind-load, deploy-operator]
cmds:
- |
kubectl --context ${KUBECTX} \
rollout restart deployment -n rig-system rig-operator
clean:
desc: "🧹 Clean everything"
deps: [clean-kind, clean-gen]
clean-kind:
desc: "🧹 Clean kind cluster"
deps: [tools:kind]
cmds:
- cmd: kind delete clusters rig
ignore_error: true
clean-gen:
desc: "🧹 Clean generated files"
cmds:
- cmd: rm -r gen
ignore_error: true
release:
desc: "🔖 Release project"
deps: [tools:goreleaser, proto]
cmds:
- |
./tools/bin/goreleaser release -p 2 \
-f ./build/package/goreleaser/goreleaser.yml
release-build:
desc: "📸 Build release snapshot"
deps: [tools:goreleaser, proto]
cmds:
- |
./tools/bin/goreleaser release -p 2 \
-f ./build/package/goreleaser/goreleaser.yml \
--snapshot \
--clean
crd-proto:
desc: "crd proto"
cmds:
- python3 ./tools/crdproto.py