-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
272 lines (247 loc) Β· 8.58 KB
/
Taskfile.yml
File metadata and controls
272 lines (247 loc) Β· 8.58 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
version: '3'
vars:
N: "nix develop -c"
PODMAN_SOCKET:
sh: |
if command -v podman &> /dev/null; then
podman machine inspect --format '{{"{{"}}.ConnectionInfo.PodmanSocket.Path{{"}}"}}' 2>/dev/null || echo ""
fi
CONTAINER_HOST:
sh: |
# Use existing DOCKER_HOST if set
if [ -n "$DOCKER_HOST" ]; then
echo "$DOCKER_HOST"
exit 0
fi
# Try native Docker
if command -v docker &> /dev/null && docker ps &> /dev/null 2>&1; then
echo ""
exit 0
fi
# Try Podman socket
if command -v podman &> /dev/null; then
SOCKET=$(podman machine inspect --format '{{"{{"}}.ConnectionInfo.PodmanSocket.Path{{"}}"}}' 2>/dev/null || echo "")
if [ -n "$SOCKET" ] && [ -S "$SOCKET" ]; then
echo "unix://$SOCKET"
exit 0
fi
fi
echo ""
tasks:
default:
desc: List all available tasks
silent: true
cmds:
- task --list
vendor:
desc: Run go mod vendor
silent: true
cmds:
- '{{.N}} go mod tidy'
- '{{.N}} go mod vendor'
test:
desc: Run unit tests with coverage
silent: true
cmds:
- mkdir -p output
- '{{.N}} go test -race -count=1 -coverprofile=output/coverage.out -covermode=atomic ./... -tags=!examples'
- '{{.N}} go tool cover -html=output/coverage.out -o output/coverage.html'
- 'echo "β Coverage: output/coverage.html"'
test:integration:
desc: Run integration tests including temporal (testcontainers, Docker or Podman required)
silent: true
deps: [docker:check]
env:
DOCKER_HOST: '{{.CONTAINER_HOST}}'
TESTCONTAINERS_RYUK_DISABLED: '{{if .CONTAINER_HOST}}true{{end}}'
cmds:
- mkdir -p output
- '{{.N}} bash -c "go list ./... | grep -v examples | xargs go test -race -count=1 -coverprofile=output/coverage-integration.out -covermode=atomic -tags=integration -timeout=15m"'
- '{{.N}} go tool cover -html=output/coverage-integration.out -o output/coverage-integration.html'
- 'echo "β Integration coverage: output/coverage-integration.html"'
test:argo:
desc: Run Argo integration tests (requires k8s cluster with Argo Workflows)
silent: true
cmds:
- task: argo:check
- mkdir -p output
- '{{.N}} go test -race -count=1 -coverprofile=output/coverage-argo.out -covermode=atomic -tags=argo -timeout=15m ./argo/...'
- '{{.N}} go tool cover -html=output/coverage-argo.out -o output/coverage-argo.html'
- 'echo "β Argo coverage: output/coverage-argo.html"'
- '{{.N}} bash -c "go tool cover -func=output/coverage-argo.out | grep total"'
test:complete:
desc: Run ALL tests (unit + integration + argo) with single comprehensive coverage report
silent: true
deps: [docker:check]
env:
DOCKER_HOST: '{{.CONTAINER_HOST}}'
TESTCONTAINERS_RYUK_DISABLED: '{{if .CONTAINER_HOST}}true{{end}}'
cmds:
- task: argo:check
- mkdir -p output
- echo "π§ͺ Running all tests (unit + integration + argo)..."
- '{{.N}} bash -c "go list ./... | grep -v examples | xargs go test -race -count=1 -coverprofile=output/coverage-complete.out -covermode=atomic -tags=integration,argo -timeout=20m -v"'
- '{{.N}} go tool cover -html=output/coverage-complete.out -o output/coverage-complete.html'
- 'echo ""'
- 'echo "β
Complete test coverage report:"'
- '{{.N}} bash -c "go tool cover -func=output/coverage-complete.out | grep total"'
- 'echo "π HTML Report: output/coverage-complete.html"'
- 'echo "π Coverage Data: output/coverage-complete.out"'
docker:check:
desc: Check Docker or Podman availability and daemon status
silent: true
cmds:
- |
# 1. If DOCKER_HOST is already set by user, trust it
if [ -n "$DOCKER_HOST" ]; then
echo "β
DOCKER_HOST is set: $DOCKER_HOST"
exit 0
fi
# 2. Try native Docker
if command -v docker &> /dev/null && docker ps &> /dev/null 2>&1; then
echo "β
Docker is available and running"
docker --version
exit 0
fi
# 3. Try Podman via detected socket
CONTAINER_HOST="{{.CONTAINER_HOST}}"
if [ -n "$CONTAINER_HOST" ]; then
echo "β
Podman is available"
podman --version
echo " Container host: $CONTAINER_HOST"
exit 0
fi
# 4. Podman is installed but socket not found
if command -v podman &> /dev/null; then
echo "β Podman is installed but no running machine detected"
echo " Start with: podman machine start"
exit 1
fi
echo "β Neither Docker nor Podman found"
echo " Install Docker or Podman and try again"
exit 1
lint:
desc: Run golangci-lint
silent: true
cmds:
- '{{.N}} golangci-lint run ./...'
check:
desc: Run all checks (test + lint)
silent: true
cmds:
- task: test
- task: lint
# Infrastructure checks
k8s:check:
desc: Check Kubernetes cluster availability
silent: true
cmds:
- |
if ! command -v kubectl &> /dev/null; then
echo "β kubectl not installed"
exit 1
fi
if kubectl cluster-info &> /dev/null; then
echo "β
Kubernetes cluster is available"
kubectl cluster-info | head -2
echo " Context: $(kubectl config current-context)"
else
echo "β Kubernetes cluster not accessible"
echo " Check your kubeconfig or cluster status"
exit 1
fi
argo:check:
desc: Check Argo Workflows availability in cluster
silent: true
cmds:
- |
if ! command -v kubectl &> /dev/null; then
echo "β kubectl not installed"
exit 1
fi
if ! kubectl cluster-info &> /dev/null; then
echo "β Kubernetes cluster not accessible"
exit 1
fi
if kubectl get namespace argo &> /dev/null; then
echo "β
Argo namespace exists"
if kubectl get deployment -n argo 2> /dev/null | grep -q workflow-controller; then
echo "β
Argo Workflows is installed"
kubectl get pods -n argo -l app=workflow-controller --no-headers 2>/dev/null | head -1
else
echo "β οΈ Argo namespace exists but Argo Workflows not detected"
fi
else
echo "β Argo namespace not found"
echo " Install: kubectl create namespace argo"
echo " Then install Argo Workflows from https://argo-workflows.readthedocs.io"
exit 1
fi
# Utilities
nix:check:
desc: Verify Nix environment and tool availability
silent: true
cmds:
- |
if ! command -v nix &> /dev/null; then
echo "β Nix not installed"
echo " Install: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install"
exit 1
fi
echo "β
Nix $(nix --version)"
echo "Checking devShell tools..."
{{.N}} go version
{{.N}} golangci-lint --version
{{.N}} gofumpt --version
{{.N}} gosec --version
{{.N}} podman --version
{{.N}} docker --version
{{.N}} bun --version
{{.N}} jq --version
echo "β
All tools available"
nix:update:
desc: Update flake inputs (bump tool versions)
silent: true
cmds:
- nix flake update
- echo "β
Flake inputs updated. Run 'task nix:check' to verify."
fmt:
desc: Format all Go files with gofumpt
cmds:
- '{{.N}} gofumpt -l -w .'
ci:test:
desc: Run unit tests for CI (no coverage HTML)
silent: true
cmds:
- '{{.N}} go test -race -count=1 ./... -tags=!examples'
ci:lint:
desc: Run golangci-lint for CI
silent: true
cmds:
- '{{.N}} golangci-lint run ./...'
ci:check:
desc: Run all CI checks (test + lint)
silent: true
cmds:
- task: ci:test
- task: ci:lint
release:
desc: Run semantic-release (CI only)
silent: true
cmds:
- '{{.N}} bunx semantic-release'
release:proxy-warmup:
desc: Warm Go module proxy with latest tag
silent: true
cmds:
- |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LATEST_TAG" ]; then
echo "Warming Go proxy for github.com/jasoet/pkg/v2@${LATEST_TAG}"
{{.N}} bash -c "GOPROXY=https://proxy.golang.org GO111MODULE=on go list -m \"github.com/jasoet/pkg/v2@${LATEST_TAG}\"" || true
fi
clean:
desc: Clean build artifacts
silent: true
cmds:
- rm -rf dist output