Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
251 lines (215 loc) · 11.4 KB
/
Copy pathMakefile
File metadata and controls
251 lines (215 loc) · 11.4 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
# SPDX-License-Identifier: MPL-2.0
# kaptinlin/jsonschema v0.9.9 imports encoding/json/jsontext, which is available
# with Go 1.27's default experiment set. Do not disable jsonv2 here.
export GOFLAGS := -buildvcs=false
test-clean:
go clean -testcache
test:
go test ./internal/... -v -race -short
go test ./api/... -v -race -short
go test ./system/... -v -race -short
go test ./service/... -v -race -short
go test ./cluster/... -v -race -short
go test --tags "$(WIPPY_BUILD_TAGS)" ./runtime/... -v -race -short
go test ./boot/... -v -race -short
go test --tags "$(WIPPY_BUILD_TAGS)" ./cmd/... -v -race -short
$(MAKE) test-optional-features
.PHONY: test-optional-features
test-optional-features:
go test -tags "$(WIPPY_BUILD_TAGS) tailscale treesitter" -race -short ./boot/components/service ./service/net/tailscale ./runtime/lua/modules/treesitter
# Local heavy WASM acceptance, excluded from the normal CI short suite.
# Includes both sustained SQLite load windows; fixtures fail closed if missing.
.PHONY: test-wasm-heavy
test-wasm-heavy:
WIPPY_SQLITE_LOAD=1 WIPPY_SQLITE_OPEN_LOOP=1 go test ./runtime/wasm/engine -race -count=1 -short=false -timeout 30m -v -run '^(TestSQLiteActor_|TestSQLiteActorLoad_|TestQuickJSActor_)'
# The default service test intentionally stays untagged so the SQLite stub and
# the non-CGO portability path remain covered. The real preupdate-hook source
# is exercised by the Linux CGO CI job through this target.
.PHONY: test-cdc-sqlite
test-cdc-sqlite:
CGO_ENABLED=1 go test ./service/sql/... ./service/cdc/sqlite -v -race -tags sqlite_preupdate_hook
CGO_ENABLED=1 go test ./service/cdc/sqlite -v -race -timeout 300s -tags "integration sqlite_preupdate_hook"
$(MAKE) test-cdc-native
.PHONY: test-cdc-postgres
test-cdc-postgres:
@test -n "$(WIPPY_CDC_IT_ADMIN_DSN)" && test -n "$(WIPPY_CDC_IT_REPL_DSN)" || (echo "Set both WIPPY_CDC_IT_ADMIN_DSN and WIPPY_CDC_IT_REPL_DSN" >&2; exit 1)
go test -race -count=1 -timeout 180s -tags integration ./service/cdc/postgres
.PHONY: test-cdc-native
test-cdc-native: build-wippy-local
cd tests/sqlite-cdc && ../../dist/wippy-$(shell go env GOOS)-$(shell go env GOARCH) test -s
test-system:
go test ./internal/... -v -race
go test ./api/... -v -race
go test ./system/... -v -race
test-runtime:
go test ./internal/... -v -race
go test ./api/... -v -race
go test --tags "$(WIPPY_BUILD_TAGS)" ./runtime/... -v -race
test-service:
go test ./internal/... -v -race
go test ./api/... -v -race
go test ./service/... -v -race
test-cluster:
go test ./internal/... -v -race
go test ./api/... -v -race
go test ./cluster/... -v -race
test-integration:
CGO_ENABLED=1 go test ./tests/... -v -race -timeout 120s
test-network:
go test -v -race -timeout 300s ./service/net/...
LINT_PACKAGES ?= ./...
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 run --timeout=10m --max-issues-per-linter=0 --max-same-issues=0 --build-tags=race,sqlite_preupdate_hook,goexperiment.jsonv2 $(LINT_PACKAGES)
# Mutation testing with gremlins. Coverage is scoped to the directory gremlins
# runs from, so target a package subtree via MUTATE_DIR. workers=1 keeps per-
# mutant timing free of contention and the generous timeout coefficient stops
# fast packages (whose cached coverage baseline is tiny) from spuriously timing
# out while each mutant recompiles — together these make the score deterministic.
# Example: make mutation MUTATE_DIR=system/topology/namereg/kvbacked
MUTATE_DIR ?= service/store/kv
.PHONY: mutation
mutation:
cd $(MUTATE_DIR) && go run github.com/go-gremlins/gremlins/cmd/gremlins@v0.6.0 unleash --workers 1 --timeout-coefficient 30
mock:
go tool mockgen -destination tests/mock/identityv1connect/identityv1connect.go github.com/wippyai/module-registry-proto-go/registry/identity/v1/identityv1connect OrganizationServiceClient
go tool mockgen -destination tests/mock/modulev1connect/modulev1connect.go github.com/wippyai/module-registry-proto-go/registry/module/v1/modulev1connect ModuleServiceClient,CommitServiceClient,LabelServiceClient,DownloadServiceClient
go tool mockgen -destination tests/mock/deps/moduleloader.go github.com/wippyai/runtime/deps ManifestLoader
otel-up:
cd tests && docker-compose up -d --remove-orphans
otel-down:
cd tests && docker-compose down
# otel-e2e starts only Jaeger and runs the OTLP round-trip test (needs docker).
otel-e2e:
cd tests && docker-compose up -d jaeger
go test -tags integration -run TestOTLP_TracesReachJaeger ./tests/ -timeout 120s
# Wippy CLI build targets. Optional features are disabled unless requested.
WIPPY_FEATURES ?=
WIPPY_BUILD_TAGS := fts5 sqlite_vec sqlite_preupdate_hook $(WIPPY_FEATURES)
WIPPY_VERSION ?= $(shell if wippy_description=$$(git describe --tags --always --dirty 2>/dev/null); then printf 'dev-%s' "$$wippy_description"; else printf 'dev'; fi)
WIPPY_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
WIPPY_DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
WIPPY_BUILDER ?= $(shell whoami)@$(shell hostname)
WIPPY_LDFLAGS := -s -w \
-X github.com/wippyai/runtime/api/version.Version=$(WIPPY_VERSION) \
-X github.com/wippyai/runtime/api/version.Commit=$(WIPPY_COMMIT) \
-X github.com/wippyai/runtime/api/version.Date=$(WIPPY_DATE) \
-X github.com/wippyai/runtime/api/version.BuiltBy=$(WIPPY_BUILDER)
.PHONY: build-wippy
build-wippy: build-wippy-local
.PHONY: build-wippy-local
build-wippy-local:
mkdir -p ./dist
@ldflags='$(WIPPY_LDFLAGS)'; helper=''; digest=''; \
if [ "$$(go env GOOS)" = linux ]; then \
helper="./dist/confine-linux-$$(go env GOARCH)"; \
CGO_ENABLED=0 go build -trimpath -o "$$helper" ./service/exec/native/cmd/confine-linux/ || exit; \
digest="$$(sha256sum "$$helper" | cut -d ' ' -f 1)"; \
ldflags="$$ldflags -X github.com/wippyai/runtime/service/exec/native.linuxHelperSHA256=$$digest"; \
elif [ "$$(go env GOOS)" = darwin ]; then \
helper="./dist/confine-darwin-$$(go env GOARCH)"; \
CGO_ENABLED=1 go build -trimpath -o "$$helper" ./service/exec/native/cmd/confine-darwin/ || exit; \
codesign --force --sign - --options hard,kill,runtime "$$helper" || exit; \
digest="$$(shasum -a 256 "$$helper" | cut -d ' ' -f 1)"; \
cdhash="$$(codesign -d --verbose=4 "$$helper" 2>&1 | sed -n 's/^CDHash=//p')"; \
test -n "$$cdhash" || exit 1; \
ldflags="$$ldflags -X github.com/wippyai/runtime/service/exec/native.darwinHelperSHA256=$$digest -X github.com/wippyai/runtime/service/exec/native.darwinHelperCDHash=$$cdhash"; \
fi; \
CGO_ENABLED=1 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$$ldflags" \
-trimpath \
-o ./dist/wippy-$(shell go env GOOS)-$(shell go env GOARCH) \
./cmd/wippy/ || exit; \
if [ -n "$$helper" ]; then \
go run ./tools/packhelper ./dist/wippy-$$(go env GOOS)-$$(go env GOARCH) "$$helper" "$$digest"; \
fi
.PHONY: build-wippy-all
build-wippy-all: build-wippy-linux-amd64 build-wippy-linux-arm64 build-wippy-darwin-amd64 build-wippy-darwin-arm64 build-wippy-windows-amd64
.PHONY: build-wippy-linux-amd64
build-wippy-linux-amd64:
mkdir -p ./dist
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -o ./dist/confine-linux-amd64 ./service/exec/native/cmd/confine-linux/
@digest="$$(sha256sum ./dist/confine-linux-amd64 | cut -d ' ' -f 1)"; \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$(WIPPY_LDFLAGS) -X github.com/wippyai/runtime/service/exec/native.linuxHelperSHA256=$$digest" \
-trimpath \
-o ./dist/wippy-linux-amd64 \
./cmd/wippy/ && \
go run ./tools/packhelper ./dist/wippy-linux-amd64 ./dist/confine-linux-amd64 "$$digest"
.PHONY: build-wippy-linux-arm64
build-wippy-linux-arm64:
mkdir -p ./dist
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -o ./dist/confine-linux-arm64 ./service/exec/native/cmd/confine-linux/
@digest="$$(sha256sum ./dist/confine-linux-arm64 | cut -d ' ' -f 1)"; \
CGO_LDFLAGS="" CGO_CFLAGS="" CC=aarch64-linux-gnu-gcc \
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$(WIPPY_LDFLAGS) -X github.com/wippyai/runtime/service/exec/native.linuxHelperSHA256=$$digest" \
-trimpath \
-o ./dist/wippy-linux-arm64 \
./cmd/wippy/ && \
go run ./tools/packhelper ./dist/wippy-linux-arm64 ./dist/confine-linux-arm64 "$$digest"
.PHONY: build-wippy-darwin-amd64
build-wippy-darwin-amd64:
mkdir -p ./dist
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -trimpath -o ./dist/confine-darwin-amd64 ./service/exec/native/cmd/confine-darwin/
codesign --force --sign - --options hard,kill,runtime ./dist/confine-darwin-amd64
@digest="$$(shasum -a 256 ./dist/confine-darwin-amd64 | cut -d ' ' -f 1)"; \
cdhash="$$(codesign -d --verbose=4 ./dist/confine-darwin-amd64 2>&1 | sed -n 's/^CDHash=//p')"; \
test -n "$$cdhash" && \
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$(WIPPY_LDFLAGS) -X github.com/wippyai/runtime/service/exec/native.darwinHelperSHA256=$$digest -X github.com/wippyai/runtime/service/exec/native.darwinHelperCDHash=$$cdhash" \
-trimpath \
-o ./dist/wippy-darwin-amd64 \
./cmd/wippy/ && \
go run ./tools/packhelper ./dist/wippy-darwin-amd64 ./dist/confine-darwin-amd64 "$$digest"
.PHONY: build-wippy-darwin-arm64
build-wippy-darwin-arm64:
mkdir -p ./dist
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -trimpath -o ./dist/confine-darwin-arm64 ./service/exec/native/cmd/confine-darwin/
codesign --force --sign - --options hard,kill,runtime ./dist/confine-darwin-arm64
@digest="$$(shasum -a 256 ./dist/confine-darwin-arm64 | cut -d ' ' -f 1)"; \
cdhash="$$(codesign -d --verbose=4 ./dist/confine-darwin-arm64 2>&1 | sed -n 's/^CDHash=//p')"; \
test -n "$$cdhash" && \
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$(WIPPY_LDFLAGS) -X github.com/wippyai/runtime/service/exec/native.darwinHelperSHA256=$$digest -X github.com/wippyai/runtime/service/exec/native.darwinHelperCDHash=$$cdhash" \
-trimpath \
-o ./dist/wippy-darwin-arm64 \
./cmd/wippy/ && \
go run ./tools/packhelper ./dist/wippy-darwin-arm64 ./dist/confine-darwin-arm64 "$$digest"
.PHONY: build-wippy-windows-amd64
build-wippy-windows-amd64:
mkdir -p ./dist
CGO_LDFLAGS="" CGO_CFLAGS="" CC=x86_64-w64-mingw32-gcc \
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build --tags "$(WIPPY_BUILD_TAGS)" \
-ldflags="$(WIPPY_LDFLAGS)" \
-trimpath \
-o ./dist/wippy-windows-amd64.exe \
./cmd/wippy/
# Azure Trusted Signing configuration
AZURE_CLIENT_ID ?=
AZURE_CLIENT_SECRET ?=
AZURE_TENANT_ID ?=
AZURE_ENDPOINT ?= https://eus.codesigning.azure.net/
AZURE_ACCOUNT_NAME ?= SpiralScout
AZURE_CERT_PROFILE ?= SpiralScout
AZURE_METADATA_JSON ?= C:\Projects\gen2-electron\metadata.json
AZURE_CODE_SIGNING_DLIB ?= C:\Users\ryots\AppData\Local\Microsoft\MicrosoftTrustedSigningClientTools\Azure.CodeSigning.Dlib.dll
SIGNTOOL_PATH ?= c:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\signtool.exe
.PHONY: sign-wippy-windows
sign-wippy-windows:
AZURE_CLIENT_ID=$(AZURE_CLIENT_ID) \
AZURE_CLIENT_SECRET=$(AZURE_CLIENT_SECRET) \
AZURE_TENANT_ID=$(AZURE_TENANT_ID) \
"$(SIGNTOOL_PATH)" sign /v /fd SHA256 \
/tr "http://timestamp.acs.microsoft.com" /td SHA256 \
/dlib "$(AZURE_CODE_SIGNING_DLIB)" \
/dmdf "$(AZURE_METADATA_JSON)" \
./dist/wippy-windows-amd64.exe
.PHONY: build-sign-wippy-windows
build-sign-wippy-windows: build-wippy-windows-amd64 sign-wippy-windows
.PHONY: run-wippy
run-wippy:
go run --tags "$(WIPPY_BUILD_TAGS)" -ldflags="$(WIPPY_LDFLAGS)" ./cmd/wippy/ $(ARGS)
.PHONY: test-application
test-application:
go test -tags "$(WIPPY_BUILD_TAGS)" ./cmd/app ./cmd/wippy/cmd ./cmd/internal/entries ./boot/deps/lock