forked from stacklok/toolhive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
300 lines (266 loc) · 11.5 KB
/
Taskfile.yml
File metadata and controls
300 lines (266 loc) · 11.5 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
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
version: '3'
includes:
operator:
taskfile: ./cmd/thv-operator/Taskfile.yml
flatten: true
tasks:
docs:
desc: Regenerate the docs
deps: [swagger-install, helm-docs]
cmds:
- rm -rf docs/cli/*
- go run cmd/help/main.go --dir docs/cli
- swag init -g pkg/api/server.go --v3.1 -o docs/server --parseDependencyLevel 1
- task: helm-docs
swagger-install:
desc: Install the swag tool for OpenAPI/Swagger generation
cmds:
- go install github.com/swaggo/swag/v2/cmd/swag@latest
helm-docs:
desc: Generate Helm chart documentation
cmds:
- command -v helm-docs >/dev/null 2>&1 || go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
- helm-docs --chart-search-root=deploy/charts
mock-install:
desc: Install the mockgen tool for mock generation
status:
- which mockgen
cmds:
- go install go.uber.org/mock/mockgen@latest
gen:
desc: Generate mock files using go generate
deps: [mock-install]
cmds:
- go generate ./...
addlicense-install:
desc: Install the addlicense tool for license header management
status:
- which addlicense
cmds:
- go install github.com/google/addlicense@latest
license-check:
desc: Check that all Go files have proper SPDX license headers
deps: [addlicense-install]
cmds:
- addlicense -check -f .github/license-header.txt -ignore '**/mocks/**' -ignore '**/testdata/**' -ignore 'vendor/**' -ignore '**/*.pb.go' -ignore '**/zz_generated*.go' $(find . -name '*.go' -type f)
license-fix:
desc: Add SPDX license headers to Go files that are missing them
deps: [addlicense-install]
cmds:
- addlicense -f .github/license-header.txt -ignore '**/mocks/**' -ignore '**/testdata/**' -ignore 'vendor/**' -ignore '**/*.pb.go' -ignore '**/zz_generated*.go' $(find . -name '*.go' -type f)
lint:
desc: Run linting tools
cmds:
- golangci-lint run --allow-parallel-runners ./...
- go vet ./...
lint-fix:
desc: Run linting tools, and apply fixes.
cmds:
- golangci-lint run --allow-parallel-runners --fix ./...
test-unixlike:
desc: Run unit tests (excluding e2e tests) on Linux and macOS with race detection
platforms: [linux, darwin]
internal: true
cmds:
# Only install gotestfmt if not already installed
- cmd: which gotestfmt > /dev/null 2>&1 || go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
platforms: [linux, darwin]
# we have to use ldflags to avoid the LC_DYSYMTAB linker error.
# https://github.com/stacklok/toolhive/issues/1687
- go test -ldflags=-extldflags=-Wl,-w -v -json -race $(go list ./... | grep -v '/test/e2e' | grep -v '/cmd/thv-operator/test-integration') | gotestfmt -hide "all"
test-windows:
desc: Run unit tests (excluding e2e tests) on Windows with race detection
platforms: [windows]
internal: true
vars:
DIR_LIST:
sh: go list ./... | findstr -V "\/test\/e2e"
cmds:
- go test -v -race {{.DIR_LIST | catLines}}
test:
desc: Run unit tests (excluding e2e tests)
deps: [gen]
cmds:
- task: test-unixlike
platforms: [linux, darwin]
- task: test-windows
platforms: [windows]
test-coverage-unixlike:
desc: Run unit tests with coverage analysis and race detection (excluding e2e tests) on Linux and macOS
platforms: [linux, darwin]
internal: true
cmds:
- cmd: mkdir -p coverage
platforms: [linux, darwin]
# Clear both the test-result cache and the build cache before running coverage.
# The CI build cache is keyed on go.sum, so source-only changes don't bust it.
# With -coverpkg=./..., every test binary instruments all packages; if any binary
# was compiled from a stale cached artifact (different NumStmt than the current
# source), go tool cover -func will error with "inconsistent NumStmt". Clearing
# the full build cache guarantees every package is instrumented from fresh source.
- cmd: go clean -cache -testcache
platforms: [linux, darwin]
# Only install gotestfmt if not already installed
- cmd: which gotestfmt > /dev/null 2>&1 || go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
platforms: [linux, darwin]
# we have to use ldflags to avoid the LC_DYSYMTAB linker error.
# https://github.com/stacklok/toolhive/issues/1687
- go test -ldflags=-extldflags=-Wl,-w -json -race -coverpkg=./... -coverprofile=coverage/coverage.out $(go list ./... | grep -v '/test/e2e' | grep -v '/cmd/thv-operator/test-integration') | gotestfmt -hide "all"
- go tool cover -func=coverage/coverage.out
- echo "Generating HTML coverage report in coverage/coverage.html"
- go tool cover -html=coverage/coverage.out -o coverage/coverage.html
test-coverage-windows:
desc: Run unit tests with coverage analysis and race detection (excluding e2e tests) on Windows
platforms: [windows]
internal: true
vars:
DIR_LIST:
sh: go list ./... | findstr -V "\/test\/e2e"
cmds:
- cmd: cmd.exe /c mkdir coverage
ignore_error: true # Windows has no mkdir -p, so just ignore error if it exists
# Clear both the test-result cache and the build cache before running coverage.
# See the unix variant above for rationale.
- go clean -cache -testcache
- go test -race -coverpkg=./... -coverprofile=coverage/coverage.out {{.DIR_LIST | catLines}}
- go tool cover -func=coverage/coverage.out
- echo "Generating HTML coverage report in coverage/coverage.html"
- go tool cover -html=coverage/coverage.out -o coverage/coverage.html
test-coverage:
desc: Run unit tests with coverage analysis (excluding e2e tests)
cmds:
- task: test-coverage-unixlike
platforms: [linux, darwin]
- task: test-coverage-windows
platforms: [windows]
test-e2e-unixlike:
desc: Run end-to-end tests on Linux and macOS
platforms: [linux, darwin]
internal: true
env:
THV_BINARY: "{{.PWD}}/bin/thv"
cmds:
- ./test/e2e/run_tests.sh
test-e2e-windows:
desc: Run end-to-end tests on Windows
platforms: [windows]
internal: true
env:
THV_BINARY: "{{.ROOT_DIR}}\\bin\\thv.exe"
cmds:
- cmd: .\\test\\e2e\\run_tests.bat
test-e2e:
desc: Run end-to-end tests
deps: [build]
cmds:
- go install github.com/onsi/ginkgo/v2/ginkgo
- task: test-e2e-unixlike
platforms: [linux, darwin]
- task: test-e2e-windows
platforms: [windows]
test-integration-unixlike:
desc: Run integration tests on Linux and macOS (requires Docker)
platforms: [linux, darwin]
internal: true
cmds:
- which gotestfmt > /dev/null 2>&1 || go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- go test -ldflags=-extldflags=-Wl,-w -v -json -race -tags integration ./... | gotestfmt -hide "all"
test-integration-windows:
desc: Run integration tests on Windows (requires Docker)
platforms: [windows]
internal: true
cmds:
- go test -v -race -tags integration ./...
test-integration:
desc: Run integration tests (requires Docker)
cmds:
- task: test-integration-unixlike
platforms: [linux, darwin]
- task: test-integration-windows
platforms: [windows]
test-all:
desc: Run all tests (unit, integration, and e2e)
deps: [test, test-integration, test-e2e]
build:
desc: Build the binary
deps: [gen]
vars:
VERSION:
sh: git describe --tags --dirty --match "v*" 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD || echo "unknown"
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
cmds:
- cmd: mkdir -p bin
platforms: [linux, darwin]
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/thv ./cmd/thv
platforms: [linux, darwin]
- cmd: cmd.exe /c mkdir bin
platforms: [windows]
ignore_error: true # Windows has no mkdir -p, so just ignore error if it exists
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/thv.exe ./cmd/thv
platforms: [windows]
install:
desc: Install the thv binary to GOPATH/bin
vars:
VERSION:
sh: git describe --tags --dirty --match "v*" 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD || echo "unknown"
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
cmds:
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/thv
build-vmcp:
desc: Build the vmcp binary
deps: [gen]
vars:
VERSION:
sh: git describe --tags --dirty --match "v*" 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD || echo "unknown"
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
cmds:
- cmd: mkdir -p bin
platforms: [linux, darwin]
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp ./cmd/vmcp
platforms: [linux, darwin]
- cmd: cmd.exe /c mkdir bin
platforms: [windows]
ignore_error: true
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp.exe ./cmd/vmcp
platforms: [windows]
install-vmcp:
desc: Install the vmcp binary to GOPATH/bin
vars:
VERSION:
sh: git describe --tags --dirty --match "v*" 2>/dev/null || echo "dev"
COMMIT:
sh: git rev-parse --short HEAD || echo "unknown"
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
cmds:
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/vmcp
all:
desc: Run linting, tests, and build
deps: [lint, test, build]
all-with-coverage:
desc: Run linting, tests with coverage, and build
deps: [lint, test-coverage, build]
build-image:
desc: Build the image with ko
env:
KO_DOCKER_REPO: ghcr.io/stacklok/toolhive
cmds:
- ko build --local --bare ./cmd/thv
build-vmcp-image:
desc: Build the vmcp image with ko
env:
KO_DOCKER_REPO: ghcr.io/stacklok/toolhive/vmcp
cmds:
- ko build --local --bare ./cmd/vmcp
build-egress-proxy:
desc: Build the egress proxy container image
cmds:
- docker build --load -t ghcr.io/stacklok/toolhive/egress-proxy:local containers/egress-proxy/
build-all-images:
desc: Build all container images (main app, vmcp, and egress proxy)
deps: [build-image, build-vmcp-image, build-egress-proxy]