-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
251 lines (225 loc) · 10.2 KB
/
Copy pathTaskfile.yml
File metadata and controls
251 lines (225 loc) · 10.2 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
version: "3"
vars:
GOCACHE: "/tmp/go-build"
GOMODCACHE: "{{.ROOT_DIR}}/.gomodcache"
USEARCH_VERSION: "2.26.0"
USEARCH_COMMIT: "cc23bbaf21ef52313c5a495adbc40cbd733cdcfb"
USEARCH_SOURCE_URL: "https://proxy.golang.org/github.com/unum-cloud/usearch/@v/v2.26.0+incompatible.zip"
USEARCH_SOURCE_SHA256: "54f280b044757a391a6905b0850ad96789b6b2ce7c20ec9511b3b4628e27b0bd"
USEARCH_MACOS_DEPLOYMENT_TARGET: "12.0"
USEARCH_BUILD_ROOT: "/private/tmp/dbrain-usearch-v2.26.0-darwin-arm64"
USEARCH_STAGE_DIR: "{{.USEARCH_BUILD_ROOT}}/stage"
USEARCH_RACE_PACKAGES: "./cmd/devtools/semantic_usearch_bakeoff ./cmd/devtools/semantic_usearch_segment_flush ./internal/annbakeoff ./internal/app ./internal/brainresearch ./internal/semanticbuild ./internal/semanticindex ./internal/semanticruntime"
RELEASE_VERSION:
sh: |
if [ -n "${DBRAIN_RELEASE_VERSION:-}" ]; then
printf "%s" "${DBRAIN_RELEASE_VERSION}"
elif [ "${GITHUB_REF_TYPE:-}" = "tag" ] && [ -n "${GITHUB_REF_NAME:-}" ]; then
printf "%s" "${GITHUB_REF_NAME}"
else
git describe --tags --exact-match 2>/dev/null || echo unknown
fi
BUILD_PLATFORM:
sh: printf "%s/%s" "$(go env GOOS)" "$(go env GOARCH)"
tasks:
build:
desc: Build the dbrain CLI
cmds:
- mkdir -p bin
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go build -buildvcs=true -ldflags "-X github.com/darron/dbrain/internal/version.ReleaseVersion={{.RELEASE_VERSION}} -X github.com/darron/dbrain/internal/version.BuildPlatform={{.BUILD_PLATFORM}}" -o ./bin/dbrain ./cmd/dbrain
usearch-static-darwin-arm64:
desc: Build and stage the pinned static USearch C library for Darwin arm64
cmds:
- |
set -eu
if [ "$(go env GOOS)" != "darwin" ] || [ "$(go env GOARCH)" != "arm64" ]; then
echo "usearch-static-darwin-arm64 requires a Darwin arm64 host" >&2
exit 1
fi
for tool in cmake curl shasum unzip; do
if ! command -v "${tool}" >/dev/null 2>&1; then
echo "missing required tool: ${tool}" >&2
exit 1
fi
done
archive_dir="{{.USEARCH_BUILD_ROOT}}/download"
source_root="{{.USEARCH_BUILD_ROOT}}/source"
source_dir="${source_root}/github.com/unum-cloud/usearch@v{{.USEARCH_VERSION}}+incompatible"
build_dir="{{.USEARCH_BUILD_ROOT}}/build"
stage_dir="{{.USEARCH_STAGE_DIR}}"
archive="${archive_dir}/usearch-v{{.USEARCH_VERSION}}.zip"
archive_tmp="${archive}.tmp"
mkdir -p "${archive_dir}" "${source_root}" "${build_dir}" "${stage_dir}/include" "${stage_dir}/lib"
curl --fail --location --silent --show-error "{{.USEARCH_SOURCE_URL}}" --output "${archive_tmp}"
actual_sha="$(shasum -a 256 "${archive_tmp}" | awk '{print $1}')"
if [ "${actual_sha}" != "{{.USEARCH_SOURCE_SHA256}}" ]; then
echo "USearch source checksum mismatch: got ${actual_sha}, want {{.USEARCH_SOURCE_SHA256}}" >&2
exit 1
fi
mv "${archive_tmp}" "${archive}"
unzip -q -o "${archive}" -d "${source_root}"
if [ ! -f "${source_dir}/CMakeLists.txt" ] || [ ! -f "${source_dir}/c/usearch.h" ]; then
echo "verified USearch archive has an unexpected layout" >&2
exit 1
fi
MACOSX_DEPLOYMENT_TARGET={{.USEARCH_MACOS_DEPLOYMENT_TARGET}} cmake \
-S "${source_dir}" \
-B "${build_dir}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET={{.USEARCH_MACOS_DEPLOYMENT_TARGET}} \
-DUSEARCH_BUILD_LIB_C=ON \
-DUSEARCH_BUILD_TEST_CPP=OFF \
-DUSEARCH_BUILD_BENCH_CPP=OFF \
-DUSEARCH_BUILD_TEST_C=OFF \
-DUSEARCH_USE_OPENMP=OFF \
-DUSEARCH_USE_NUMKONG=OFF \
-DUSEARCH_USE_JEMALLOC=OFF
cmake --build "${build_dir}" --config Release --target usearch_static_c --parallel 2
cp "${build_dir}/libusearch_static_c.a" "${stage_dir}/lib/libusearch_c.a"
cp "${source_dir}/c/usearch.h" "${stage_dir}/include/usearch.h"
test-usearch-darwin-arm64:
desc: Run full tagged tests and race-test packages selected by the USearch build tag
deps: [usearch-static-darwin-arm64]
cmds:
- >
MACOSX_DEPLOYMENT_TARGET={{.USEARCH_MACOS_DEPLOYMENT_TARGET}}
CGO_ENABLED=1
GOOS=darwin
GOARCH=arm64
CGO_CFLAGS="-I{{.USEARCH_STAGE_DIR}}/include"
CGO_LDFLAGS="-L{{.USEARCH_STAGE_DIR}}/lib"
GOCACHE={{.GOCACHE}}
GOMODCACHE={{.GOMODCACHE}}
go test -count=1 -tags usearch -timeout=20m ./...
- >
MACOSX_DEPLOYMENT_TARGET={{.USEARCH_MACOS_DEPLOYMENT_TARGET}}
CGO_ENABLED=1
GOOS=darwin
GOARCH=arm64
CGO_CFLAGS="-I{{.USEARCH_STAGE_DIR}}/include"
CGO_LDFLAGS="-L{{.USEARCH_STAGE_DIR}}/lib"
GOCACHE={{.GOCACHE}}
GOMODCACHE={{.GOMODCACHE}}
go test -count=1 -race -tags usearch -timeout=20m {{.USEARCH_RACE_PACKAGES}}
build-usearch-darwin-arm64:
desc: Build the tagged native Darwin arm64 dbrain binary
deps: [usearch-static-darwin-arm64]
cmds:
- mkdir -p bin
- >
MACOSX_DEPLOYMENT_TARGET={{.USEARCH_MACOS_DEPLOYMENT_TARGET}}
CGO_ENABLED=1
GOOS=darwin
GOARCH=arm64
CGO_CFLAGS="-I{{.USEARCH_STAGE_DIR}}/include"
CGO_LDFLAGS="-L{{.USEARCH_STAGE_DIR}}/lib"
GOCACHE={{.GOCACHE}}
GOMODCACHE={{.GOMODCACHE}}
go build -tags usearch -buildvcs=true
-ldflags "-X github.com/darron/dbrain/internal/version.ReleaseVersion={{.RELEASE_VERSION}} -X github.com/darron/dbrain/internal/version.BuildPlatform=darwin/arm64"
-o ./bin/dbrain ./cmd/dbrain
build-semantic:
desc: Build bin/dbrain with native semantic retrieval enabled
deps: [build-usearch-darwin-arm64]
verify-usearch-darwin-arm64:
desc: Verify native architecture, linkage, deployment target, and semantic capability
deps: [build-usearch-darwin-arm64]
cmds:
- |
set -eu
binary="./bin/dbrain"
file "${binary}" | grep -Fq "Mach-O 64-bit executable arm64"
test "$(lipo -archs "${binary}")" = "arm64"
metadata="$(go version -m "${binary}")"
printf '%s\n' "${metadata}"
printf '%s\n' "${metadata}" | grep -Fq "CGO_ENABLED=1"
printf '%s\n' "${metadata}" | grep -Fq "GOOS=darwin"
printf '%s\n' "${metadata}" | grep -Fq "GOARCH=arm64"
printf '%s\n' "${metadata}" | grep -Fq -- "-tags=usearch"
expected_minos="minos {{.USEARCH_MACOS_DEPLOYMENT_TARGET}}"
otool -l "${binary}" | grep -A 5 "LC_BUILD_VERSION" | grep -Fq "${expected_minos}"
dependencies="$(otool -L "${binary}" | tail -n +2 | awk '{print $1}')"
printf '%s\n' "${dependencies}"
if printf '%s\n' "${dependencies}" | grep -Fqi "libusearch"; then
echo "native artifact must not depend on an external USearch dylib" >&2
exit 1
fi
unexpected=0
for dependency in ${dependencies}; do
case "${dependency}" in
/usr/lib/libresolv.9.dylib|/usr/lib/libc++.1.dylib|/usr/lib/libSystem.B.dylib|/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation|/System/Library/Frameworks/Security.framework/Versions/A/Security)
;;
*)
echo "unexpected native dependency: ${dependency}" >&2
unexpected=1
;;
esac
done
test "${unexpected}" -eq 0
status_root="/private/tmp/dbrain-usearch-native-verification"
mkdir -p "${status_root}"
status="$("${binary}" --root "${status_root}" --no-debug semantic status --json)"
printf '%s\n' "${status}"
compact_status="$(printf '%s' "${status}" | tr -d '[:space:]')"
printf '%s\n' "${compact_status}" | grep -Fq '"state":"supported_ready"'
printf '%s\n' "${compact_status}" | grep -Fq '"backend":"usearch"'
printf '%s\n' "${compact_status}" | grep -Fq '"version":"{{.USEARCH_VERSION}}"'
fmt:
desc: Format Go source files
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go fmt ./...
web-install:
desc: Install the web UI dependencies
cmds:
- cd web/ui && npm install
web-build:
desc: Build the embedded web UI assets
cmds:
- cd web/ui && npm run build
lint:
desc: Run golangci-lint
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} golangci-lint run ./...
test:
desc: Run the Go test suite with the current shell environment
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test -cover -race -timeout=20m ./...
test-ci:
desc: Run the standard Go test gate with a clean CI-like environment
cmds:
- >
env -i
HOME="${HOME}"
USER="${USER:-$(id -un)}"
LOGNAME="${LOGNAME:-${USER:-$(id -un)}}"
PATH="${PATH:-/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin}"
TMPDIR="${TMPDIR:-/tmp}"
SHELL="${SHELL:-/bin/sh}"
GOCACHE={{.GOCACHE}}
GOMODCACHE={{.GOMODCACHE}}
go test -cover -race -timeout=20m ${TEST_PACKAGES:-./...}
test-go:
desc: Run the Go test suite without race or coverage
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test ./...
test-release-automation:
desc: Run deterministic release and workflow automation tests
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test ./internal/releaseautomation ./cmd/devtools/homebrew_test_release
test-feeds:
desc: Run feed ingestion related tests
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test ./internal/feedimport ./internal/store ./internal/syncjob
test-pkg:
desc: Run go test for package args passed after --
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test {{.CLI_ARGS}}
test-race-pkg:
desc: Run go test -cover -race for package args passed after --
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test -cover -race {{.CLI_ARGS}}
test-mcp:
desc: Run deterministic MCP retrieval and server tests
cmds:
- GOCACHE={{.GOCACHE}} GOMODCACHE={{.GOMODCACHE}} go test ./internal/ask ./internal/mcpeval ./internal/mcpserver