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
236 lines (209 loc) · 8.46 KB
/
Taskfile.yml
File metadata and controls
236 lines (209 loc) · 8.46 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
version: '3'
includes:
operator:
taskfile: ./cmd/thv-operator/Taskfile.yml
flatten: true
tasks:
docs:
desc: Regenerate the docs
deps: [swagger-install]
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
swagger-install:
desc: Install the swag tool for OpenAPI/Swagger generation
cmds:
- go install github.com/swaggo/swag/v2/cmd/swag@latest
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 ./...
lint:
desc: Run linting tools
cmds:
- golangci-lint run ./...
- go vet ./...
lint-fix:
desc: Run linting tools, and apply fixes.
cmds:
- golangci-lint run --fix ./...
test-unixlike:
desc: Run unit tests (excluding e2e tests) on Linux and macOS with race detection
platforms: [linux, darwin]
internal: true
cmds:
- go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
# 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]
- go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
# 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 -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
- go test -race -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-all:
desc: Run all tests (unit and e2e)
deps: [test, test-e2e]
build:
desc: Build the binary
deps: [gen]
vars:
VERSION:
sh: git describe --tags --always --dirty --match "v*" || 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 --always --dirty --match "v*" || 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 --always --dirty --match "v*" || 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 --always --dirty --match "v*" || 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]