-
Notifications
You must be signed in to change notification settings - Fork 131
493 lines (422 loc) · 19.4 KB
/
Copy pathci.yml
File metadata and controls
493 lines (422 loc) · 19.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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
name: CI
permissions:
contents: read
on:
workflow_call:
push:
branches: [main]
workflow_dispatch:
schedule:
- cron: '23 8 * * 1'
jobs:
release-linux-smoke:
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
runner: ubuntu-latest
go_arch_name: amd64
- goarch: arm64
runner: ubuntu-24.04-arm
go_arch_name: arm64
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.runner) && github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.runner }}
container:
image: ubuntu:22.04
steps:
- name: Install build tools
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt-get update
apt-get install -y gcc g++ make git curl tar gzip file binutils libsqlite3-dev
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install Go
run: |
GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')
curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${{ matrix.go_arch_name }}.tar.gz" -o go.tar.gz
tar -C /usr/local -xzf go.tar.gz
rm go.tar.gz
echo "/usr/local/go/bin" >> "$GITHUB_PATH"
echo "$HOME/go/bin" >> "$GITHUB_PATH"
- name: Build Linux release binary
env:
GOOS: linux
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: '1'
run: |
export PATH="/usr/local/go/bin:$HOME/go/bin:$PATH"
COMMIT=$(printf '%s' "$GITHUB_SHA" | cut -c1-8)
VERSION="ci-$COMMIT"
mkdir -p dist
LDFLAGS="-s -w -X go.kenn.io/msgvault/cmd/msgvault/cmd.Version=${VERSION} -X go.kenn.io/msgvault/cmd/msgvault/cmd.Commit=${COMMIT} -X go.kenn.io/msgvault/cmd/msgvault/cmd.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ) -extldflags '-lstdc++ -lm'"
go build -tags "fts5 sqlite_vec" -trimpath -buildvcs=false -ldflags="$LDFLAGS" -o dist/msgvault ./cmd/msgvault
echo "--- Binary info ---"
file dist/msgvault
ldd dist/msgvault || true
echo "--- Runtime requirements ---"
objdump -T dist/msgvault 2>/dev/null | grep -oP 'GLIBC_\d+\.\d+' | sort -uV | tail -1 || true
objdump -T dist/msgvault 2>/dev/null | grep -oP 'GLIBCXX_\d+\.\d+(\.\d+)?' | sort -uV | tail -1 || true
echo "--- Smoke test ---"
SMOKE_OUT=$(dist/msgvault version 2>&1)
echo "$SMOKE_OUT"
echo "$SMOKE_OUT" | grep -q "$VERSION" || { echo "FATAL: version output doesn't match CI build version"; exit 1; }
test:
runs-on: macos-15
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
- name: Test
run: make test
- name: Check OpenAPI artifacts
run: make openapi-check
- name: Lint
run: make lint-ci
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.4
- name: Vulnerability check
run: govulncheck -tags "fts5 sqlite_vec" ./...
frontend:
runs-on: ${{ github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-24.04' }}
container:
image: mcr.microsoft.com/playwright:v1.61.1-noble@sha256:5b8f294aff9041b7191c34a4bab3ac270157a28774d4b0660e9743297b697e48
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install container build tools
# Mirror hiccups have hung plain apt-get for 15+ minutes; bounded
# timeouts plus retries turn an outage into a short delay.
run: |
for attempt in 1 2 3; do
if apt-get update -o Acquire::Retries=3 -o Acquire::http::Timeout=30 \
&& apt-get install -y --no-install-recommends -o Acquire::Retries=3 -o Acquire::http::Timeout=30 gcc g++ make unzip; then
exit 0
fi
echo "apt attempt $attempt failed; retrying" >&2
sleep 30
done
exit 1
- name: Trust the checkout in the container
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: web/package.json
- name: Install frontend dependencies
working-directory: web
run: bun install --frozen-lockfile
- name: Check, test, and build frontend
run: make web-check web-test web-build
# The e2e specs generate their archive fixture by running a Go test;
# compile it here so the first Playwright test doesn't pay the cold
# cgo build inside its own timeout.
- name: Precompile e2e archive fixture
run: go test -tags "fts5 sqlite_vec" -run '^$' -count=1 ./internal/query
- name: Run deterministic browser and visual tests
run: make web-test-browser
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: playwright-browser-failures
path: |
web/playwright-report
web/test-results
if-no-files-found: ignore
web-e2e:
runs-on: ${{ github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-24.04' }}
container:
image: mcr.microsoft.com/playwright:v1.61.1-noble@sha256:5b8f294aff9041b7191c34a4bab3ac270157a28774d4b0660e9743297b697e48
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install container build tools
# Mirror hiccups have hung plain apt-get for 15+ minutes; bounded
# timeouts plus retries turn an outage into a short delay.
run: |
for attempt in 1 2 3; do
if apt-get update -o Acquire::Retries=3 -o Acquire::http::Timeout=30 \
&& apt-get install -y --no-install-recommends -o Acquire::Retries=3 -o Acquire::http::Timeout=30 gcc g++ make unzip; then
exit 0
fi
echo "apt attempt $attempt failed; retrying" >&2
sleep 30
done
exit 1
- name: Trust the checkout in the container
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: web/package.json
- name: Install frontend dependencies
working-directory: web
run: bun install --frozen-lockfile
# See the frontend job: warm the cgo fixture compile outside test timeouts.
- name: Precompile e2e archive fixture
run: go test -tags "fts5 sqlite_vec" -run '^$' -count=1 ./internal/query
- name: Run accessibility, keyboard, security, and mixed-archive gates
run: make web-e2e
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: playwright-e2e-failures
path: |
web/playwright-report
web/test-results
if-no-files-found: ignore
large-archive-benchmark:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: macos-15
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Run mixed-archive analytical reference benchmark
run: |
go test -tags "fts5 sqlite_vec" ./internal/query -run '^$' \
-bench '^BenchmarkExploreLargeArchive$' -benchtime=3x -count=1 \
| tee large-archive-benchmark.txt
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: large-archive-benchmark
path: large-archive-benchmark.txt
if-no-files-found: error
test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
# sqlite-vec's CGo bindings #include <sqlite3.h>, which isn't on
# the default windows-latest include path. Install it from MSYS2
# (already present on the runner) and point CGO_CFLAGS at it.
#
# arrow-go/v18's cdata helpers.h declares its helpers as plain
# `inline` (not `static inline`). Under C99 that requires exactly
# one external definition somewhere, and no TU in arrow-go
# provides one. -fgnu89-inline forces every TU to emit the
# external copy, and --allow-multiple-definition lets MinGW's ld
# pick the first and continue instead of erroring on the
# duplicates that flag produces.
- name: Install sqlite3 dev headers
shell: pwsh
run: |
C:\msys64\usr\bin\pacman.exe -S --noconfirm --needed mingw-w64-x86_64-sqlite3
- name: Build
shell: pwsh
env:
CGO_ENABLED: "1"
CGO_CFLAGS: "-IC:/msys64/mingw64/include -fgnu89-inline"
CGO_LDFLAGS: "-Wl,--allow-multiple-definition"
run: go build -tags "fts5 sqlite_vec" -o msgvault.exe ./cmd/msgvault
- name: Test
shell: pwsh
env:
CGO_ENABLED: "1"
CGO_CFLAGS: "-IC:/msys64/mingw64/include -fgnu89-inline"
CGO_LDFLAGS: "-Wl,--allow-multiple-definition"
run: |
$separatePackages = @(
"go.kenn.io/msgvault/cmd/msgvault/cmd"
"go.kenn.io/msgvault/internal/api"
"go.kenn.io/msgvault/internal/importer"
"go.kenn.io/msgvault/internal/store"
"go.kenn.io/msgvault/internal/sync"
"go.kenn.io/msgvault/internal/vector/embed"
"go.kenn.io/msgvault/internal/vector/sqlitevec"
"go.kenn.io/msgvault/scripts"
)
$packages = go list -tags "fts5 sqlite_vec" ./... |
Where-Object { $_ -notin $separatePackages }
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
go test -timeout 20m -tags "fts5 sqlite_vec" $packages
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: msgvault-windows-amd64
path: msgvault.exe
test-windows-slow-packages:
runs-on: windows-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install sqlite3 dev headers
shell: pwsh
run: |
C:\msys64\usr\bin\pacman.exe -S --noconfirm --needed mingw-w64-x86_64-sqlite3
- name: Test slow packages
shell: pwsh
env:
CGO_ENABLED: "1"
CGO_CFLAGS: "-IC:/msys64/mingw64/include -fgnu89-inline"
CGO_LDFLAGS: "-Wl,--allow-multiple-definition"
run: |
go test -timeout 20m -tags "fts5 sqlite_vec" `
./internal/api `
./internal/importer `
./internal/store `
./scripts
test-windows-sharded:
name: test-windows-sharded (${{ matrix.name }})
strategy:
fail-fast: false
matrix:
include:
- name: cli
package: ./cmd/msgvault/cmd
- name: sync-vector-embed
package: ./internal/sync
package2: ./internal/vector/embed
- name: vector-sqlite
package: ./internal/vector/sqlitevec
runs-on: windows-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install sqlite3 dev headers
shell: pwsh
run: |
C:\msys64\usr\bin\pacman.exe -S --noconfirm --needed mingw-w64-x86_64-sqlite3
- name: Test package in isolated shards
shell: pwsh
env:
CGO_ENABLED: "1"
CGO_CFLAGS: "-IC:/msys64/mingw64/include -fgnu89-inline"
CGO_LDFLAGS: "-Wl,--allow-multiple-definition"
run: |
$packages = @('${{ matrix.package }}', '${{ matrix.package2 }}') |
Where-Object { $_ }
foreach ($package in $packages) {
./scripts/test-package-shards.ps1 `
-Package $package `
-ShardCount 4 `
-Tags "fts5 sqlite_vec" `
-Timeout 20m
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
test-windows-pack-restore:
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install sqlite3 dev headers
shell: pwsh
run: |
C:\msys64\usr\bin\pacman.exe -S --noconfirm --needed mingw-w64-x86_64-sqlite3
- name: Measure packed and loose restore layouts
shell: pwsh
env:
CGO_ENABLED: "1"
CGO_CFLAGS: "-IC:/msys64/mingw64/include -fgnu89-inline"
CGO_LDFLAGS: "-Wl,--allow-multiple-definition"
run: |
go test -tags "fts5 sqlite_vec" ./internal/backupapp `
-run '^$' -bench '^BenchmarkBackupRestoreLayouts$' -benchtime=1x -count=3 `
2>&1 | Tee-Object -FilePath pack-restore-benchmark.txt
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: msgvault-windows-pack-restore-benchmark
path: pack-restore-benchmark.txt
if-no-files-found: ignore
# pgvector lane: runs every pgvector-tagged test against a live
# pgvector/pgvector image — backend, embed queue/worker/enqueue, hybrid
# filter, scheduler embed-job, and serve/search CLI. The `pgvector` build
# tag is required; without it these files compile out and ship no tests,
# so this code would otherwise have zero CI coverage.
test-pgvector:
runs-on: ${{ github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: msgvault_test
POSTGRES_PASSWORD: testpw
POSTGRES_DB: msgvault_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U msgvault_test -d msgvault_test"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
MSGVAULT_TEST_DB: postgres://msgvault_test:testpw@localhost:5432/msgvault_test
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
- name: Install psql client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
- name: Enable pgvector extension
env:
PGPASSWORD: testpw
run: |
psql -h localhost -U msgvault_test -d msgvault_test -c "CREATE EXTENSION IF NOT EXISTS vector"
- name: Test (pgvector-tagged)
run: go test -tags "fts5 sqlite_vec pgvector" -count=1 ./internal/vector/... ./internal/scheduler/... ./cmd/msgvault/cmd/...
nix-build:
runs-on: ${{ github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
- name: Build
run: nix build
# PostgreSQL backend lane: runs the full Go test suite against a live
# PostgreSQL service. Tests that use testutil.NewTestStore read
# MSGVAULT_TEST_DB and switch backends without a recompile. Concurrency
# tests use -count=5 so non-deterministic races (lost updates, missing
# unique constraints) surface here rather than slipping past a single
# pass.
test-postgres:
runs-on: ${{ github.repository == 'kenn-io/msgvault' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: msgvault_test
POSTGRES_PASSWORD: msgvault_test
POSTGRES_DB: msgvault_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
MSGVAULT_TEST_DB: postgres://msgvault_test:msgvault_test@localhost:5432/msgvault_test?sslmode=disable
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod
# This lane uses a stock postgres:16 image (no pgvector extension), so it
# must NOT build the pgvector tag — those tests CREATE EXTENSION "vector"
# and fail here. pgvector is covered by the dedicated test-pgvector job
# against a pgvector/pgvector image. (Run go test directly rather than
# `make test-pg`, whose PG_TEST_TAGS include pgvector.)
- name: Test (PostgreSQL)
run: go test -tags "fts5 sqlite_vec" ./...
- name: Concurrency tests (-count=5)
run: |
go test -tags fts5 -count=5 -run 'Concurrent' ./internal/store