-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTaskfile.yml
More file actions
175 lines (148 loc) · 5.34 KB
/
Copy pathTaskfile.yml
File metadata and controls
175 lines (148 loc) · 5.34 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
version: "3"
vars:
BINARY: kit
OUTPUT_DIR: output
BUILD_FLAGS: -o {{.OUTPUT_DIR}}/{{.BINARY}}
LDFLAGS: -s -w -X main.version=dev
tasks:
default:
desc: Show available tasks
cmds:
- task --list-all
# -----------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------
build:
desc: Build the kit binary and the kit-tunnel sidecar
deps:
- tunnel
cmds:
- go build {{.BUILD_FLAGS}} -ldflags "{{.LDFLAGS}}" ./cmd/kit
sources:
- "**/*.go"
- go.mod
- go.sum
- internal/daemon/embedded/kit-tunnel-*
generates:
- "{{.OUTPUT_DIR}}/{{.BINARY}}"
tunnel:
desc: Build the kit-tunnel sidecar (Rust; required for daemon/remote)
cmds:
- |
if ! command -v cargo >/dev/null 2>&1; then
echo "warn: cargo not found — skipping kit-tunnel build; 'kit daemon' and '--remote' need it"
exit 0
fi
./scripts/stage-tunnel.sh "$(go env GOOS)" "$(go env GOARCH)" "internal/daemon/embedded/kit-tunnel-$(go env GOOS)-$(go env GOARCH)"
mkdir -p {{.OUTPUT_DIR}}
cp contrib/kit-tunnel/target/release/kit-tunnel{{.exe}} {{.OUTPUT_DIR}}/kit-tunnel{{.exe}}
vars:
exe:
sh: 'if [ "$(go env GOOS)" = "windows" ]; then echo .exe; fi'
sources:
- contrib/kit-tunnel/src/**/*.rs
- contrib/kit-tunnel/Cargo.toml
- contrib/kit-tunnel/Cargo.lock
generates:
- "{{.OUTPUT_DIR}}/kit-tunnel"
- "internal/daemon/embedded/kit-tunnel-*"
# NOTE: these Go builds do NOT stage per-target kit-tunnel sidecars, so
# the artifacts fall back to an external sidecar at runtime. For
# distributable binaries with the sidecar embedded, use goreleaser
# (which runs scripts/stage-tunnel.sh per target), or stage each target
# first: GOOS=x GOARCH=y ./scripts/stage-tunnel.sh x y out
build-all:
desc: Build for all platforms (linux, darwin, windows)
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.OUTPUT_DIR}}/{{.BINARY}}-linux-amd64 -ldflags "{{.LDFLAGS}}" ./cmd/kit
- GOOS=linux GOARCH=arm64 go build -o {{.OUTPUT_DIR}}/{{.BINARY}}-linux-arm64 -ldflags "{{.LDFLAGS}}" ./cmd/kit
- GOOS=darwin GOARCH=amd64 go build -o {{.OUTPUT_DIR}}/{{.BINARY}}-darwin-amd64 -ldflags "{{.LDFLAGS}}" ./cmd/kit
- GOOS=darwin GOARCH=arm64 go build -o {{.OUTPUT_DIR}}/{{.BINARY}}-darwin-arm64 -ldflags "{{.LDFLAGS}}" ./cmd/kit
- GOOS=windows GOARCH=amd64 go build -o {{.OUTPUT_DIR}}/{{.BINARY}}-windows-amd64.exe -ldflags "{{.LDFLAGS}}" ./cmd/kit
install:
desc: Install kit to $GOPATH/bin
cmds:
- go install -ldflags "{{.LDFLAGS}}" ./cmd/kit
# -----------------------------------------------------------------------
# Test
# -----------------------------------------------------------------------
test:
desc: Run all tests with race detector
cmds:
- go test -race ./...
test-v:
desc: Run all tests (verbose)
cmds:
- go test -race -v ./...
test-short:
desc: Run tests in short mode (skip long-running tests)
cmds:
- go test -race -short ./...
test-pkg:
desc: "Run tests for a specific package (usage: task test-pkg -- ./internal/config)"
cmds:
- go test -race -v {{.CLI_ARGS}}
test-run:
desc: "Run a single test by name (usage: task test-run -- TestScriptExecution)"
cmds:
- go test -race -v ./... -run {{.CLI_ARGS}}
test-cover:
desc: Run tests with coverage report
cmds:
- mkdir -p {{.OUTPUT_DIR}}
- go test -race -coverprofile={{.OUTPUT_DIR}}/coverage.out ./...
- go tool cover -html={{.OUTPUT_DIR}}/coverage.out -o {{.OUTPUT_DIR}}/coverage.html
- echo "Coverage report written to {{.OUTPUT_DIR}}/coverage.html"
# -----------------------------------------------------------------------
# Code quality
# -----------------------------------------------------------------------
lint:
desc: Run golangci-lint and go vet
cmds:
- golangci-lint run ./...
- go vet ./...
fmt:
desc: Format all Go files
cmds:
- go fmt ./...
fmt-check:
desc: Check formatting (fails if files need formatting)
cmds:
- test -z "$(gofmt -l .)" || (echo "Files need formatting:" && gofmt -l . && exit 1)
tidy:
desc: Tidy go.mod and go.sum
cmds:
- go mod tidy
check:
desc: Run all quality checks (fmt, vet, test)
cmds:
- task: fmt-check
- task: lint
- task: test
# -----------------------------------------------------------------------
# Development
# -----------------------------------------------------------------------
dev:
desc: Build and run kit with optional args
cmds:
- task: build
- "{{.OUTPUT_DIR}}/{{.BINARY}} {{.CLI_ARGS}}"
watch:
desc: Watch for changes and rebuild (requires watchexec)
cmds:
- watchexec -e go -r -- task build
clean:
desc: Remove build artifacts
cmds:
- rm -rf {{.OUTPUT_DIR}}
# -----------------------------------------------------------------------
# Release
# -----------------------------------------------------------------------
release-snapshot:
desc: Build a release snapshot (no publish)
cmds:
- goreleaser release --snapshot --clean
release-check:
desc: Validate goreleaser config
cmds:
- goreleaser check