-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
229 lines (194 loc) · 6.2 KB
/
Copy pathTaskfile.yml
File metadata and controls
229 lines (194 loc) · 6.2 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
version: "3"
vars:
GOARCH:
sh: go env GOARCH
# Pinned tools installed by `task tools` into ./bin/.
KO: ./bin/ko
LINT: ./bin/golangci-lint
HELM: ./bin/helm
KIND_CLUSTER: orchestrator-dev
KIND_CONTEXT: kind-orchestrator-dev
tasks:
default:
cmds:
- go run github.com/go-task/task/v3/cmd/task@v3.48.0 --list-all
silent: true
# === Tools ===
tools:
desc: Install pinned ko, golangci-lint, and helm into ./bin/
cmds:
- bash hack/install-tools.sh
status:
- test -x ./bin/ko
- test -x ./bin/golangci-lint
- test -x ./bin/helm
# === Development ===
dev:
desc: Run jobs-service locally with hot reload (Docker backend)
deps: [build-sidecar]
env:
JOB_SIDECAR_IMAGE: ko.local/job-sidecar:latest
SHUTDOWN_DRAIN_WAIT: "0s"
EXTRA_HOSTS: "appwrite.test:host-gateway"
cmds:
- go run github.com/air-verse/air@latest
run:
desc: Run jobs-service locally without reload (Docker backend)
deps: [build-sidecar]
env:
JOB_SIDECAR_IMAGE: ko.local/job-sidecar:latest
EXTRA_HOSTS: "appwrite.test:host-gateway"
cmds:
- go run ./cmd/jobs-service
# === Build ===
build:
desc: Build all images
cmds:
- task: build-service
- task: build-sidecar
- task: build-deployments
- task: build-deployments-sidecar
- task: build-deployments-activator
- task: build-pool-shim
silent: true
build-pool-shim:
desc: Build pool-shim image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/pool-shim {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/pool-shim
sources:
- cmd/pool-shim/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
build-deployments-activator:
desc: Build deployments-activator image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/deployments-activator {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/deployments-activator
sources:
- cmd/deployments-activator/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
build-deployments:
desc: Build deployments-service image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/deployments-service {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/deployments-service
sources:
- cmd/deployments-service/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
build-deployments-sidecar:
desc: Build deployments-sidecar image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/deployments-sidecar {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/deployments-sidecar
sources:
- cmd/deployments-sidecar/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
build-service:
desc: Build service image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/jobs-service {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/jobs-service
sources:
- cmd/jobs-service/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
build-sidecar:
desc: Build sidecar image
deps: [tools]
cmds:
- KO_DOCKER_REPO=ko.local/job-sidecar {{.KO}} build --bare --platform=linux/{{.GOARCH}} ./cmd/job-sidecar
sources:
- cmd/job-sidecar/**/*.go
- internal/**/*.go
- pkg/**/*.go
- go.mod
# === Test ===
test:
desc: Run unit tests
cmds:
- go test -race ./...
test-integration:
desc: Run integration tests (adapter tests)
cmds:
- go test -race -tags=integration -timeout=10m ./...
test-k8s-integration:
desc: Run real-cluster K8s integration tests (requires kind + built images)
deps: [build, kind:up]
cmds:
- kind load docker-image ko.local/jobs-service:latest ko.local/job-sidecar:latest ko.local/deployments-service:latest ko.local/deployments-sidecar:latest ko.local/deployments-activator:latest ko.local/pool-shim:latest --name {{.KIND_CLUSTER}}
- bash hack/install-gateway.sh
- go test -race -tags=k8s_integration -timeout=10m ./internal/orchestrator/kubernetes/... ./internal/deployment/kubernetes/...
test-e2e:
desc: Run e2e tests (full system)
deps: [build]
cmds:
- go test -race -tags=e2e -timeout=10m ./...
test-all:
desc: Run all tests
deps: [build]
cmds:
- go test -race ./...
- go test -race -tags=integration -timeout=10m ./...
- go test -race -tags=e2e -timeout=10m ./...
# === Code Quality ===
lint:
desc: Run linter
deps: [tools]
cmds:
- "{{.LINT}} run"
fmt:
desc: Format code
deps: [tools]
cmds:
- "{{.LINT}} run --fix"
# === Helm chart ===
helm:lint:
desc: Lint the orchestrator Helm chart
deps: [tools]
cmds:
- "{{.HELM}} lint charts/orchestrator"
helm:template:
desc: Render the orchestrator Helm chart with dev-values to stdout
deps: [tools]
cmds:
- "{{.HELM}} template orchestrator charts/orchestrator --namespace orchestrator --values hack/dev-values.yaml"
# === Kubernetes dev (kind + Tilt) ===
# Requires: kind on PATH, ./bin/helm installed (via `task tools`), tilt on PATH.
# Cluster context: kind-orchestrator-dev
kind:up:
desc: Create the kind dev cluster
cmds:
- kind get clusters 2>/dev/null | grep -q '^{{.KIND_CLUSTER}}$' || kind create cluster --name {{.KIND_CLUSTER}} --config hack/kind-config.yaml
kind:down:
desc: Delete the kind dev cluster
cmds:
- kind delete cluster --name {{.KIND_CLUSTER}}
dev:k8s:
desc: Live-reload K8s dev loop (tilt up against kind-orchestrator-dev)
deps: [kind:up, tools]
cmds:
- tilt up
k8s:logs:
desc: Follow jobs-service logs in the kind cluster
cmds:
- kubectl --context {{.KIND_CONTEXT}} -n orchestrator logs -f deploy/jobs
k8s:jobs:
desc: List job resources managed by the orchestrator
cmds:
- kubectl --context {{.KIND_CONTEXT}} -n orchestrator get jobs,pods -l managed-by=jobs-service
# === Cleanup ===
clean:
desc: Clean caches, built images, and the kind cluster
cmds:
- go clean -cache -testcache
- docker rmi ko.local/jobs-service:latest ko.local/job-sidecar:latest 2>/dev/null || true
- kind delete cluster --name {{.KIND_CLUSTER}} 2>/dev/null || true