mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-11-23 15:11:15 +08:00
Why:
PR CI previously left six production-critical paths unverified:
1. .github/workflows/app.yml ran without PostgreSQL/ParadeDB or Redis service
containers and left WEKNORA_*_POSTGRES_DSN / WEKNORA_TEST_REDIS_ADDR unset,
causing all PostgreSQL migration, row-locking, pgvector, catalog, and
multi-replica Redis tests to 100% t.Skip (masking a step-down regression in
TestPostgresMigrationsServeAgentHistory once migrations >000106 were added).
2. app.yml invoked go vet/test without -tags sqlite_fts5, causing SQLite FTS5
retriever tests under internal/application/repository/retriever/sqlite to
100% t.Skip.
3. Desktop build-tag checks only ran ./internal/container, missing
./internal/application/service, ./cmd/desktop, and darwin/windows
cross-compilation of ./internal/localsandbox/{seatbelt,winhost}, while
release-lite.yml remained pinned to GO_VERSION=1.24 (go.mod requires 1.26.0).
4. The standalone client/ Go SDK module was excluded by app.yml (!client/**)
and ignored by cli.yml / cli-e2e.yml / pre-push hooks despite cli/
depending on ../client (masking unformatted files and a Unix-only 0o640
permission assertion on Windows in client/).
5. High-concurrency packages (internal/stream, internal/sandbox,
internal/agent, internal/im) ran without -race, and PR CI had no
zero-external-dependency Lite mode end-to-end smoke test.
What:
- Provision paradedb/paradedb:v0.25.11-pg17 and redis:7.0-alpine services in
app.yml, create isolated disposable test databases, and inject all
PostgreSQL/Redis test DSNs with WEKNORA_REQUIRE_INTEGRATION=1; fix
TestPostgresMigrationsServeAgentHistory to migrate down before 000106 and
back up instead of stepping -1 from HEAD.
- Pass -tags sqlite_fts5 across app.yml and git hooks while keeping an explicit
non-FTS5 run for TestSaveWorksWhenTheFTS5ModuleIsNotCompiledIn.
- Vet, test, and build ./internal/container, ./internal/application/service,
and ./cmd/desktop with -tags desktop,sqlite_fts5; isolate cgo-only pg_query
and gojieba bindings behind !cgo stubs so darwin/arm64 and windows/amd64
cross-compilation of ./internal/localsandbox/... runs on Linux CI; align
release-lite.yml GO_VERSION to 1.26.
- Watch client/** in cli.yml, cli-e2e.yml, and git pre-push hooks, running
client gofmt, build, vet, and -race tests across Linux, macOS, and Windows,
and fix the pre-existing gofmt drift and Windows permission assertion in
client/ uncovered by the new gate.
- Enable -race on internal/{stream,sandbox,agent,im}/... and add
tests/lite_smoke/lite_e2e_test.go exercising a real WeKnora-lite subprocess
end-to-end (auth, models, KB, Markdown upload/indexing, vector+FTS5 search,
SSE RAG chat, message persistence, and SIGTERM shutdown).
69 lines
2.2 KiB
Bash
69 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Verify that app checks cover unchanged callers and propagate failures.
|
|
set -euo pipefail
|
|
|
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
fixture="$(mktemp -d)"
|
|
trap 'rm -rf "$fixture"' EXIT
|
|
mkdir -p "$fixture/scripts/git-hooks" "$fixture/bin"
|
|
cp "$repo_root/scripts/git-hooks/common.sh" "$fixture/scripts/git-hooks/"
|
|
export HOOK_TEST_LOG="$fixture/go.log"
|
|
export LOG_FORMAT="legacy: %msg"
|
|
export WEKNORA_LOG_FORMAT="developer: %msg"
|
|
cat > "$fixture/bin/go" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
printf '%s\n' "$*" >> "$HOOK_TEST_LOG"
|
|
case "$1" in
|
|
list)
|
|
[[ "${HOOK_TEST_FAIL:-}" != list ]] || exit 1
|
|
printf '%s\n' example/internal/agent/tools example/internal/application/service example/docreader/proto
|
|
;;
|
|
vet|test)
|
|
if [[ "$1" == test && ( -n "${WEKNORA_LOG_FORMAT:-}" || "${WEKNORA_LOG_FORMAT+x}" != x ) ]]; then
|
|
echo "App tests inherited the developer log template" >&2
|
|
exit 1
|
|
fi
|
|
[[ "${HOOK_TEST_FAIL:-}" != "$1" ]] || exit 1
|
|
;;
|
|
*) echo "Unexpected go invocation: $*" >&2; exit 1 ;;
|
|
esac
|
|
EOF
|
|
chmod +x "$fixture/bin/go"
|
|
export PATH="$fixture/bin:$PATH"
|
|
unset HOOK_SKIP_TEST HOOK_TEST_FAIL
|
|
|
|
run_checks() {
|
|
bash -c 'source "$1"; run_app_vet_test' bash "$fixture/scripts/git-hooks/common.sh"
|
|
}
|
|
|
|
run_checks
|
|
cat > "$fixture/expected.log" <<'EOF'
|
|
list ./...
|
|
vet -tags sqlite_fts5 example/internal/agent/tools example/internal/application/service
|
|
test -tags sqlite_fts5 -count=1 example/internal/agent/tools example/internal/application/service
|
|
EOF
|
|
diff -u "$fixture/expected.log" "$HOOK_TEST_LOG"
|
|
|
|
# Keep the explicit local opt-out, but it must not skip vet.
|
|
: > "$HOOK_TEST_LOG"
|
|
HOOK_SKIP_TEST=1 run_checks
|
|
head -n 2 "$fixture/expected.log" > "$fixture/skip.log"
|
|
diff -u "$fixture/skip.log" "$HOOK_TEST_LOG"
|
|
|
|
for phase in list vet test; do
|
|
: > "$HOOK_TEST_LOG"
|
|
if HOOK_TEST_FAIL="$phase" run_checks > "$fixture/failure.log" 2>&1; then
|
|
echo "App checks accepted a failing go $phase" >&2
|
|
exit 1
|
|
fi
|
|
case "$phase" in
|
|
list) head -n 1 "$fixture/expected.log" ;;
|
|
vet) head -n 2 "$fixture/expected.log" ;;
|
|
test) cat "$fixture/expected.log" ;;
|
|
esac > "$fixture/failure-expected.log"
|
|
diff -u "$fixture/failure-expected.log" "$HOOK_TEST_LOG"
|
|
done
|
|
|
|
echo 'Git hook coverage checks passed'
|