-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskfile.yaml
More file actions
224 lines (197 loc) · 6.53 KB
/
taskfile.yaml
File metadata and controls
224 lines (197 loc) · 6.53 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
version: "3"
vars:
# All Go source files (excluding vendor)
GO_FILES:
sh: find . -type f -name '*.go' -not -path "./vendor/*"
# Package list for analysis scoped to project sources
GO_PKGS:
sh: go list ./...
tasks:
install-tools-mac:
desc: Install all required Go tools on macOS
cmds:
- brew install golangci-lint
- brew install aquasecurity/trivy/trivy
- brew install govulncheck
- brew install coreutils
- go install github.com/google/go-licenses/v2@latest
build:
desc: Build all CLI tools
cmds:
- mkdir -p bin
- go build -o bin/coaptool ./coaptool
- go build -o bin/httptool ./httptool
- go build -o bin/mqtttool ./mqtttool
- go build -o bin/natstool ./natstool
- go build -o bin/kafkatool ./kafkatool
- go build -o bin/redistool ./redistool
- go build -o bin/pubsubtool ./pubsubtool
- go build -o bin/pgsqltool ./pgsqltool
- go build -o bin/gittool ./gittool
- go build -o bin/mongotool ./mongotool
fmt-check:
desc: Check Go code formatting without making changes
cmds:
- echo "Running gofmt..."
- gofmt -d -e -l -s .
fmt:
desc: Format Go code with simplification
cmds:
- echo "Running gofmt..."
- gofmt -s -l -w .
lint:
desc: Run golangci-lint across the codebase
cmds:
- echo "Running golangci-lint..."
- golangci-lint run
vet:
desc: Run static analysis with go vet
cmds:
- echo "Running go vet..."
- go vet ./...
govulncheck:
desc: Run Go vulnerability check with govulncheck
cmds:
- echo "Running govulncheck..."
- govulncheck ./...
test:
desc: Run unit tests with coverage
cmds:
- echo "Running unit tests with coverage..."
- go test -coverprofile=coverage.out -covermode=atomic ./pkg/...
- go tool cover -html=coverage.out -o coverage.html
- echo "Coverage report generated at coverage.html"
- go tool cover -func=coverage.out
test-integration:
desc: Run integration tests with testcontainers
cmds:
- echo "Running integration tests..."
- go test ./test/integration/... -v -timeout 5m
test-e2e:
desc: Run end-to-end tests
deps: [services-start]
cmds:
- echo "Running E2E tests..."
- ./test/e2e/run-e2e.sh
test-all:
desc: Run all tests (unit, integration, e2e)
cmds:
- task: test
- task: test-integration
- task: test-e2e
gosec:
desc: Run security checks with gosec
vars:
GOSEC_INSTALLED:
sh: command -v gosec || echo "not_found"
cmds:
- echo "Running gosec security scanner..."
- gosec -exclude-generated ./...
trivy:
desc: Run Trivy filesystem scanner (vuln, secret, misconfig)
vars:
cmds:
- echo "Running Trivy vulnerability scanner..."
- trivy fs --scanners vuln,secret,misconfig .
- trivy fs --format json --output trivy-results.json .
licenses:
desc: Check for forbidden licenses (GPL-like) and export CSV report
cmds:
- echo "Checking for forbidden licenses (GPL, LGPL, AGPL)..."
- |
go-licenses check ./... \
--disallowed_types=GPL-2.0,GPL-3.0,LGPL-2.0,LGPL-2.1,LGPL-3.0,AGPL-1.0,AGPL-3.0 \
|| echo "⚠️ WARNING: Found forbidden licenses!"
- echo "Generating CSV license report..."
- go-licenses csv ./... > licenses.csv
- echo "✅ License report saved to licenses.csv"
- echo "Review licenses.csv to verify all dependencies"
check:
desc: Run all checks (fmt, lint, vet, test, gosec, trivy)
cmds:
- task: fmt
- task: lint
- task: govulncheck
- task: trivy
- task: licenses
- task: test
install-deps:
desc: Install and tidy Go module dependencies
cmds:
- go mod download
- go mod tidy
clean:
desc: Clean build and analysis artifacts
cmds:
- go clean -cache -testcache -modcache
- rm -rf bin/
- rm -f coverage.out
- rm -f coverage.html
- rm -f security-report.json
- rm -f trivy-results.json
- rm -f licenses.csv
# Docker Services Management
services-start:
desc: Start all Docker services
cmds:
- echo "Starting Docker services..."
- docker compose up -d
- echo "Waiting for services to be ready..."
- sleep 10
- echo "Initializing MongoDB replica set..."
- docker exec eventkit-mongodb mongosh --eval 'rs.initiate({_id:"rs0",members:[{_id:0,host:"localhost:27017"}]})'
- echo "Services started successfully"
services-stop:
desc: Stop all Docker services
cmds:
- echo "Stopping Docker services..."
- docker compose down
services-restart:
desc: Restart all Docker services
cmds:
- task: services-stop
- task: services-start
services-status:
desc: Show status of all Docker services
cmds:
- docker compose ps
services-logs:
desc: Show logs from all Docker services
cmds:
- docker compose logs -f
services-health:
desc: Check health of all Docker services
cmds:
- echo "Checking service health..."
- |
echo "MQTT (NanoMQ):" && (nc -z localhost 1883 && echo "✓ Running" || echo "✗ Not accessible")
echo "NATS:" && (nc -z localhost 4222 && echo "✓ Running" || echo "✗ Not accessible")
echo "Redis:" && (nc -z localhost 6379 && echo "✓ Running" || echo "✗ Not accessible")
echo "PostgreSQL:" && (nc -z localhost 5432 && echo "✓ Running" || echo "✗ Not accessible")
echo "MongoDB:" && (nc -z localhost 27017 && echo "✓ Running" || echo "✗ Not accessible")
echo "Kafka:" && (nc -z localhost 9092 && echo "✓ Running" || echo "✗ Not accessible")
echo "HTTP Server:" && (nc -z localhost 8080 && echo "✓ Running" || echo "✗ Not accessible")
echo "CoAP Server:" && (nc -zu localhost 5683 && echo "✓ Running" || echo "✗ Not accessible")
services-clean:
desc: Stop services and remove volumes
cmds:
- echo "Stopping services and cleaning volumes..."
- docker compose down -v
- echo "Services and volumes removed"
# Development workflow
dev-setup:
desc: Setup complete development environment
cmds:
- task: install-deps
- task: services-start
- echo "Development environment ready!"
ci:
desc: Run CI pipeline (lint, test, build)
cmds:
- task: fmt-check
- task: lint
- task: vet
- task: test
- task: test-integration
- task: build
- echo "CI pipeline completed successfully!"