-
-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy path.mise.toml
More file actions
315 lines (274 loc) · 7.17 KB
/
.mise.toml
File metadata and controls
315 lines (274 loc) · 7.17 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
[tools]
go = "1.26"
node = "20"
golangci-lint = "2.12.2"
buf = "1.70.0"
dagger = "0.21.0"
mockery = "3.7.0"
[tasks.bootstrap]
description = "Install required development tools"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Bootstrapping tools..."
(cd internal/cmd/protoc-gen-go-flipt-sdk && go install .)
go install tool
(cd internal/cmd/protoc-gen-flipt-openapi && go install .)
go install tool
"""
[tasks.clean]
description = "Clean built files and tidy go.mod"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Cleaning..."
go mod tidy
rm -rf dist/* pkg/* bin/* ui/dist
"""
[tasks."ui:deps"]
description = "Install UI dependencies"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Installing UI deps..."
cd ui
if [ ! -d node_modules ]; then
npm ci
else
npx --yes package-changed install --ci
fi
"""
[tasks."ui:build"]
description = "Build UI assets for release"
depends = ["ui:deps"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Building UI assets..."
cd ui
npm run build
"""
[tasks."ui:dev"]
description = "Run UI in development mode"
depends = ["ui:deps"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Starting UI..."
cd ui
npm run dev
"""
[tasks."ui:fmt"]
description = "Format UI code with Prettier"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Formatting UI..."
cd ui
npm run format
"""
[tasks."ui:lint"]
description = "Lint UI code with ESLint"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Linting UI..."
cd ui
npm run lint
"""
[tasks.prep]
description = "Prepare project for building (clean + ui:build)"
depends = ["clean", "ui:build"]
run = 'echo " > Prepared."'
[tasks.build]
description = "Build the project similar to a release build"
depends = ["prep"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Building..."
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_COMMIT=$(git rev-parse HEAD)
LDFLAGS="-X main.commit=${GIT_COMMIT} -X main.date=${BUILD_DATE}"
if [ -n "${KEYGEN_VERIFY_KEY:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenVerifyKey=${KEYGEN_VERIFY_KEY}"
fi
if [ -n "${KEYGEN_ACCOUNT_ID:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenAccountID=${KEYGEN_ACCOUNT_ID}"
fi
if [ -n "${KEYGEN_PRODUCT_ID:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenProductID=${KEYGEN_PRODUCT_ID}"
fi
go build -trimpath -tags assets -ldflags "${LDFLAGS}" -o ./bin/flipt ./cmd/flipt/
echo ""
echo "Run the following to start Flipt:"
echo ""
echo " ./bin/flipt server [--config config/local.yml]"
"""
[tasks."go:build"]
description = "Build Go server for development without bundling assets"
depends = ["clean"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Building..."
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
GIT_COMMIT=$(git rev-parse HEAD)
LDFLAGS="-X main.commit=${GIT_COMMIT} -X main.date=${BUILD_DATE}"
if [ -n "${KEYGEN_VERIFY_KEY:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenVerifyKey=${KEYGEN_VERIFY_KEY}"
fi
if [ -n "${KEYGEN_ACCOUNT_ID:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenAccountID=${KEYGEN_ACCOUNT_ID}"
fi
if [ -n "${KEYGEN_PRODUCT_ID:-}" ]; then
LDFLAGS="${LDFLAGS} -X main.keygenProductID=${KEYGEN_PRODUCT_ID}"
fi
go build -trimpath -ldflags "${LDFLAGS}" -o ./bin/flipt ./cmd/flipt/
echo ""
echo "Run the following to start Flipt server:"
echo ""
echo " ./bin/flipt server [--config config/local.yml]"
echo ""
echo "In another shell, run the following to start the UI in dev mode:"
echo ""
echo " cd ui && npm run dev"
"""
[tasks.dev]
description = "Run Go server in development mode with local config"
run = """
#!/usr/bin/env bash
set -euo pipefail
CONFIG="config/dev.yml"
if [ ! -f "$CONFIG" ]; then
CONFIG="config/local.yml"
fi
exec go run ./cmd/flipt/... server --config "$CONFIG"
"""
[tasks."go:test"]
alias = "test"
description = "Run Go unit tests"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Testing..."
ARGS=(-v -covermode=atomic -count=1 -coverprofile=coverage.txt -timeout=60s -coverpkg=./...)
if [ -n "${FLIPT_TEST_SHORT:-}" ]; then
ARGS+=(-short)
fi
go tool github.com/rakyll/gotest "${ARGS[@]}" ./...
"""
[tasks."go:bench"]
alias = "bench"
description = "Run Go benchmarks"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Running benchmarks..."
go test -run XXX -bench . -benchmem -short ./...
"""
[tasks."go:cover"]
description = "Run tests and generate coverage report"
depends = ["go:test"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Running coverage..."
go tool cover -html=coverage.txt
"""
[tasks."go:fmt"]
alias = "fmt"
description = "Format Go code with goimports"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Formatting..."
golangci-lint fmt
"""
[tasks."go:lint"]
alias = "lint"
description = "Run Go linters (golangci-lint and buf)"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Linting..."
golangci-lint run
buf lint
"""
[tasks."go:modernize"]
description = "Run Go modernize tool"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Running modernize..."
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -category=-omitzero -fix -test ./...
"""
[tasks."go:proto"]
alias = "proto"
description = "Generate protobuf files and gRPC stubs"
depends = ["bootstrap"]
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Generating proto files..."
for module in rpc/flipt rpc/v2; do
(cd "$module" && buf generate)
done
(cd rpc/v2 && buf generate --path environments/environments.proto --template environments/buf.gen.yaml)
(cd rpc/v2 && buf generate --path evaluation/evaluationv2.proto --template evaluation/buf.gen.yaml)
"""
[tasks."go:mockery"]
description = "Generate mocks"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Generating mocks..."
mockery
"""
[tasks."go:fuzz"]
alias = "fuzz"
description = "Run Go fuzz tests (set FLIPT_FUZZ_TIME to control duration, default 10s per target)"
run = """
#!/usr/bin/env bash
set -euo pipefail
echo " > Running fuzz tests..."
FUZZ_TIME="${FLIPT_FUZZ_TIME:-10s}"
# find_module_root returns the nearest parent directory containing a go.mod
find_module_root() {
local dir="$1"
while [ "$dir" != "." ] && [ "$dir" != "/" ]; do
if [ -f "$dir/go.mod" ]; then
echo "$dir"
return
fi
dir="$(dirname "$dir")"
done
echo "."
}
# Find all packages containing fuzz tests, then run each fuzz target
grep -rl --include='*_test.go' 'func Fuzz' . | while read -r file; do
dir="$(dirname "$file")"
mod_root="$(find_module_root "$dir")"
# Get the package path relative to the module root
pkg_rel="./${dir#"$mod_root"}"
pkg_rel="${pkg_rel#./}"
[ -z "$pkg_rel" ] && pkg_rel="."
pkg_rel="./$pkg_rel"
grep -o 'func Fuzz[A-Za-z0-9_]*' "$file" | sed 's/^func //' | while read -r func; do
echo " > Running $func in $mod_root ($pkg_rel) for $FUZZ_TIME..."
(cd "$mod_root" && go test -run='^$' -fuzz="^${func}$" -fuzztime="$FUZZ_TIME" -timeout=0 "$pkg_rel")
done
done
"""
[tasks."dagger:integration"]
alias = "di"
description = "Run a Dagger integration test by name (e.g. mise di signing/azure)"
run = """
#!/usr/bin/env bash
set -euo pipefail
dagger call test --source . integration --cases="$*"
"""
[tasks."go:generate"]
description = "Generate mocks and proto files"
depends = ["go:mockery", "go:proto"]
run = 'echo " > Generation complete."'