Repository navigation
288 lines (252 loc) · 10.1 KB
/
Copy pathci.yml
File metadata and controls
288 lines (252 loc) · 10.1 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
name: Tests
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
guard:
name: Guard (paths, pycache)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: No hardcoded user/mount paths in tracked non-md files
run: |
# split literals so this line cannot match its own pattern
re="/m""nt/|/h""ome/[a-z]+/|/U""sers/"
if git grep -nE "$re" -- ':!*.md'; then
echo "::error::hardcoded absolute path(s) above; use env vars (\$HOME, \$PROJECTS_ROOT)" >&2
exit 1
fi
- name: No __pycache__ under bin/
run: |
if find bin -type d -name __pycache__ | grep -q .; then
echo "::error::__pycache__ directories found under bin/:" >&2
find bin -type d -name __pycache__
exit 1
fi
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Shell syntax check
run: |
bash -n scripts/db/psql-yq
bash -n scripts/db/ssh-tunnel
bash -n scripts/docker-entrypoint
bash -n bin/cgo/zig
sh -n bin/cgo/zcc
sh -n bin/cgo/zc++
- name: Go tests (root module; duckdb-go CGO via gcc, no ladybug)
if: github.server_url == 'https://github.com'
run: |
CC=gcc CXX=g++ CGO_CFLAGS= CGO_LDFLAGS= go vet ./...
CC=gcc CXX=g++ CGO_CFLAGS= CGO_LDFLAGS= go test ./... -count=1
- name: Go tests (root module, no duckdb CGO; Gitea runner libstdc++ is too old for duckdb static lib)
if: github.server_url != 'https://github.com'
run: |
PKGS="$(go list ./... | grep -v /pkg/duckdb)"
go vet $PKGS
go test $PKGS -count=1
- name: brain ranking tests (no cgo / no ladybug)
run: go test ./internal/brain/rank -count=1
- name: brain client (P-9.5, cgo-free SDK + CLI compile)
run: |
go test ./pkg/brainclient/... -count=1
go run -tags=brain_client ./bin/brain/client.go help >/dev/null
- name: facts/audit self (lexicon consistency, no network)
run: ./bin/facts/audit.go self
- name: CGO via Zig (compile brain/search + index + add + eval + bench + ann)
run: |
chmod +x bin/cgo/zig bin/cgo/zcc bin/cgo/zc++
bin/cgo/zig go build -tags system_ladybug -o /tmp/brain-search ./bin/brain/search.go
bin/cgo/zig go build -tags 'system_ladybug,brain_index' -o /tmp/brain-index ./bin/brain/index.go
bin/cgo/zig go build -tags 'system_ladybug,brain_add' -o /tmp/brain-add ./bin/brain/add.go
bin/cgo/zig go build -tags 'system_ladybug,brain_eval' -o /tmp/brain-eval ./bin/brain/eval.go
bin/cgo/zig go build -tags 'system_ladybug,brain_bench' -o /tmp/brain-bench ./bin/brain/bench.go
bin/cgo/zig go build -tags 'system_ladybug,brain_ann' -o /tmp/brain-ann ./bin/brain/ann.go
- name: Go write-path tests (Zig CGO ladybug, in-process)
if: github.server_url == 'https://github.com'
run: bin/cgo/zig go test -tags system_ladybug ./internal/brain/... -count=1
- name: mailgraph import cycle (gcc CGO ladybug + duckdb, D-1.3)
if: github.server_url == 'https://github.com'
run: |
# zig-линковка duckdb static lib не встаёт (libstdc++ ABI), поэтому
# полный цикл parquet → Ladybug гоняется gcc: bin/cgo/zig env ниже
# только скачивает liblbug в lib-ladybug.
./bin/cgo/zig env >/dev/null
CC=gcc CXX=g++ \
CGO_CFLAGS="-I$PWD/lib-ladybug" \
CGO_LDFLAGS="-L$PWD/lib-ladybug -Wl,-rpath,$PWD/lib-ladybug -llbug" \
LD_LIBRARY_PATH="$PWD/lib-ladybug${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \
go test -tags system_ladybug ./internal/mailgraph/ -run TestImportCycle -count=1
- uses: actions/cache@v4
with:
path: ~/.cache/huggingface
key: ${{ runner.os }}-hf-potion-multilingual-128M
- name: recall@5 SoT (Go index + Zig bin/brain/eval.go)
if: github.server_url == 'https://github.com'
run: |
# Go downloader fetches potion weights into the HF cache (skips if cached)
go run ./bin/brain/model.go
/tmp/brain-index --rebuild --json
KB_ROOT="$PWD" /tmp/brain-eval --json
- name: search bench gate (golden-set recall@5 >= 0.95, offline)
if: github.server_url == 'https://github.com'
run: |
# Same schema as eval.go: corpus rebuilt above, DB quiescent →
# --inproc opens it read-only; the /embed daemon spawns from the
# bench binary itself. Exits 2 when the recall gate fails.
KB_ROOT="$PWD" /tmp/brain-bench --inproc --json
secret-scan:
name: Secret scan (gitleaks)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute scan range (diff of new commits only)
id: range
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
RANGE="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
else
BEFORE="${{ github.event.before }}"
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
RANGE="$(git rev-list --max-parents=0 HEAD | tail -1)..$GITHUB_SHA"
else
RANGE="$BEFORE..$GITHUB_SHA"
fi
fi
echo "RANGE=$RANGE" >> "$GITHUB_ENV"
echo "Scanning range: $RANGE"
- name: Gitleaks (diff-only, fail on leak)
env:
GITLEAKS_RANGE: ${{ env.RANGE }}
run: |
set -euo pipefail
# install the gitleaks binary (linux-amd64) instead of a docker action:
# the docker://zricethezav/gitleaks action hardcodes /github/workspace,
# which does not exist on the Gitea (act) runner. $GITHUB_WORKSPACE is the
# checkout dir on BOTH runners (GitHub and Gitea act).
curl -fsSLo /tmp/gitleaks.tar.gz \
https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
tar -xzf /tmp/gitleaks.tar.gz -C /tmp gitleaks
chmod +x /tmp/gitleaks
/tmp/gitleaks detect \
--source "$GITHUB_WORKSPACE" \
--log-opts="$GITLEAKS_RANGE" \
--redact \
--verbose
ocr:
name: OCR (tesseract fixture)
if: github.server_url == 'https://github.com'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: OCR tests (tesseract in docker, no apt)
run: |
go test -c -o /tmp/ocr.test ./internal/ocr
docker run --rm --user root --entrypoint bash \
-e OCR_LANG=eng \
-v /tmp/ocr.test:/ocr.test \
-v "$PWD":/work:ro -w /work/internal/ocr \
jitesoft/tesseract-ocr:latest -c '/ocr.test -test.v'
release:
name: Release (semver)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.server_url == 'https://github.com'
needs: [test, ocr]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Compute next semver from conventional commits
id: semver
run: |
bin/semver/next.go > /tmp/next
echo "next=$(cat /tmp/next)" >> "$GITHUB_OUTPUT"
- name: Create tag + GitHub Release
if: steps.semver.outputs.next != 'none'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.semver.outputs.next }}
run: |
set -euo pipefail
PREV=$(git tag --sort=-v:refname | grep -v "^$TAG$" | head -1 || true)
RANGE=""
[ -n "$PREV" ] && RANGE="$PREV..HEAD"
# git log limited with -n (not piped to head) to avoid SIGPIPE under pipefail
{ echo "2dph $TAG — changes from conventional commits";
git log --format='- %s' -n 40 $RANGE; } > /tmp/notes
gh release create "$TAG" \
--repo "${{ github.repository }}" \
--target "$GITHUB_SHA" \
--title "$TAG" \
--notes-file /tmp/notes
docker:
name: Docker (api image)
if: github.event_name == 'push' && github.server_url == 'https://github.com' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
needs: [test, ocr]
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image tags
id: meta
run: |
REPO="ghcr.io/${GITHUB_REPOSITORY,,}"
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
echo "tags=$REPO:api,$REPO:$GITHUB_REF_NAME,$REPO:latest" >> "$GITHUB_OUTPUT"
else
echo "tags=$REPO:api,$REPO:sha-${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
fi
- name: Build and push api image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: api
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max