-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
181 lines (156 loc) · 5.2 KB
/
Copy pathTaskfile.yml
File metadata and controls
181 lines (156 loc) · 5.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
version: "3"
vars:
MODULE: github.com/senthilsam/kcl-go
COVERAGE_THRESHOLD: "80"
COVERAGE_FILE: coverage.out
tasks:
default:
desc: Show available tasks
cmds:
- task --list
setup:
desc: Tidy dependencies
cmds:
- go mod tidy
gen:
desc: Run go generate for all packages (regenerates mocks from //go:generate directives)
cmds:
- go generate ./...
build:
desc: Build all packages
cmds:
- go build ./...
test:
desc: Run unit tests with race detector and coverage gate (≥80%)
cmds:
- go test ./... -race -coverprofile={{.COVERAGE_FILE}} -covermode=atomic
# Filter out generated mocks and infrastructure-only packages (CloudWatch, DynamoDB store,
# Postgres) from the coverage denominator — they require live AWS services to exercise.
- grep -v '/internal/mocks/' {{.COVERAGE_FILE}} | grep -v 'dynamodb_store.go' | grep -v 'postgres.go' | grep -v 'cloudwatch.go' | grep -v 'examples/' > coverage_filtered.out
- go tool cover -func coverage_filtered.out | grep ^total
- |
COVERAGE=$(go tool cover -func coverage_filtered.out | grep ^total | awk '{gsub(/%/,""); print $3}')
echo "Coverage: ${COVERAGE}%"
if [ $(echo "$COVERAGE < {{.COVERAGE_THRESHOLD}}" | bc -l) -eq 1 ]; then
echo "FAIL: Coverage ${COVERAGE}% is below threshold {{.COVERAGE_THRESHOLD}}%"
exit 1
fi
echo "PASS: Coverage ${COVERAGE}% meets threshold {{.COVERAGE_THRESHOLD}}%"
test:integration:
desc: Run ALL integration tests (starts LocalStack automatically via testcontainers — requires Podman/Docker)
env:
INTEGRATION: "1"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 15m
test:integration:consumer:
desc: Run consumer integration tests only
env:
INTEGRATION: "1"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 10m -run TestConsumer
test:integration:producer:
desc: Run producer integration tests only
env:
INTEGRATION: "1"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 10m -run TestProducer
test:integration:lease:
desc: Run lease / multi-worker integration tests only
env:
INTEGRATION: "1"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 10m -run TestLease
test:integration:e2e:
desc: Run end-to-end integration tests only
env:
INTEGRATION: "1"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 15m -run TestE2E
test:integration:localstack:
desc: Run ALL integration tests against an already-running LocalStack (no container spin-up)
env:
INTEGRATION: "1"
LOCALSTACK_ENDPOINT: "http://localhost:4566"
TESTCONTAINERS_RYUK_DISABLED: "true"
cmds:
- go test ./test/integration -race -v -tags integration -timeout 15m
coverage:html:
desc: Open coverage report in browser
deps: [test]
cmds:
- go tool cover -html={{.COVERAGE_FILE}}
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run --enable-only wsl_v5 --fix ./...
- golangci-lint run ./...
lint:fix:
desc: Run golangci-lint with auto-fix
cmds:
- golangci-lint run --fix ./...
vet:
desc: Run go vet
cmds:
- go vet ./...
mocks:
desc: "Alias for 'task gen' — regenerates all mocks via go generate ./..."
cmds:
- task: gen
tidy:
desc: Tidy go.mod and go.sum
cmds:
- go mod tidy
ci:
desc: Full CI pipeline — lint + unit tests (used in PR checks)
deps: [lint, test]
ci:full:
desc: Full CI pipeline including integration tests
deps: [lint, test, test:integration]
example:consumer:
desc: Run basic-consumer example against LocalStack (stream auto-created)
env:
LOCALSTACK: "1"
STREAM_NAME: "example-stream"
APP_NAME: "example-consumer"
cmds:
- go run ./examples/basic-consumer
example:efo:
desc: Run EFO consumer example against LocalStack
env:
LOCALSTACK: "1"
STREAM_NAME: "example-stream"
APP_NAME: "example-efo"
cmds:
- go run ./examples/efo-consumer
example:producer:
desc: Run producer example against LocalStack (sends 100 records)
env:
LOCALSTACK: "1"
STREAM_NAME: "example-stream"
RECORD_COUNT: "100"
cmds:
- go run ./examples/producer
example:multi-worker:
desc: Run multi-worker example (start 3 terminals with WORKER_ID=w-1/w-2/w-3)
env:
LOCALSTACK: "1"
STREAM_NAME: "example-stream"
APP_NAME: "example-multi"
vars:
WORKER_ID: '{{.WORKER_ID | default "worker-1"}}'
cmds:
- WORKER_ID={{.WORKER_ID}} go run ./examples/multi-worker
example:compressed:
desc: Run compressed producer-consumer example against LocalStack
env:
LOCALSTACK: "1"
STREAM_NAME: "compressed-example-stream"
RECORD_COUNT: "100"
CODEC: "gzip"
cmds:
- go run ./examples/compressed-producer-consumer