Changeset 0.18.0 (#79)

This commit is contained in:
2026-02-28 18:24:19 +00:00
parent 12e316c234
commit e4a943b03e
48 changed files with 3999 additions and 1398 deletions

View File

@@ -1,16 +1,24 @@
# .gitea/workflows/ci.yaml
# ============================================
# Chat Switchboard - CI/CD Pipeline (v0.17.2)
# Chat Switchboard - CI/CD Pipeline (v0.17.3)
# ============================================
# Cluster deployments use SEPARATE FE + BE images.
# Unified image is for Docker Hub only (docker-compose use).
#
# Pipeline:
# 0. Detect changes (path-based gating for all downstream jobs)
# 1a. Frontend tests — skipped if only BE/docs changed
# 1b. Go test (PG) — skipped if only FE/docs changed
# 1c. Go test (SQLite) — skipped if only FE/docs changed
# 2. Build + Deploy — skipped if docs-only change
# 1a. Frontend tests — skipped if only BE/docs changed
# 1b. Go unit tests — all non-DB packages + SQLite integration (race-enabled)
# 1c. Go test (PG) — PG store + handlers against Postgres (race-enabled)
# 2. Build + Deploy — skipped if docs-only change
#
# Test coverage mapping (no package tested by zero jobs):
# Unit packages (auto-discovered) → test-sqlite (race)
# ./handlers/... → test-sqlite (SQLite driver, race)
# + test-go-pg (PG driver, race)
# ./store/sqlite/... → test-sqlite (race)
# ./store/postgres/... → test-go-pg (race)
# CGO_ENABLED=0 build check → test-sqlite
#
# Path gating rules:
# src/, src/editor/ → frontend tests
@@ -202,11 +210,81 @@ jobs:
- name: Run frontend tests
run: node --test src/js/__tests__/*.test.js
# ── Stage 1b: Go Build & Test (Postgres) ─────
# ── Stage 1b: Go Unit Tests + SQLite Integration ─────
# Covers ALL non-Postgres packages via auto-discovery, plus
# SQLite handler and store integration tests. Race-enabled.
#
# Coverage: unit packages (dynamic), ./handlers/... (SQLite),
# ./store/sqlite/..., CGO_ENABLED=0 build check.
#
# Runs when: backend files changed or infra changed.
# Skipped when: only frontend or docs changed.
test:
test-sqlite:
runs-on: ubuntu-latest
needs: [detect-changes]
if: needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.infra == 'true'
env:
GOPRIVATE: git.gobha.me/*
GONOSUMCHECK: git.gobha.me/*
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Download and tidy
working-directory: server
run: |
go mod download
go mod tidy
- name: Build check (CGO_ENABLED=0)
working-directory: server
run: |
echo "━━━ SQLite Backend Build Check ━━━"
CGO_ENABLED=0 go build -o /dev/null .
echo "✓ Binary compiles with SQLite backend (pure Go, no CGO)"
- name: Run unit tests (auto-discovered, no DB)
working-directory: server
run: |
echo "━━━ Unit Tests (all non-DB packages) ━━━"
# Auto-discover: everything except store/* and handlers/*
# This ensures new packages are never silently untested
UNIT_PKGS=$(go list ./... | grep -v -E '/(store|handlers)(/|$)')
echo "Packages under test:"
echo "${UNIT_PKGS}" | sed 's/^/ /'
echo ""
go test -v -race -count=1 -p 1 ${UNIT_PKGS}
echo "✓ Unit tests complete"
- name: Run SQLite handler integration tests
working-directory: server
env:
DB_DRIVER: sqlite
run: |
echo "━━━ SQLite Integration Tests (handlers + stores) ━━━"
go test -v -race -count=1 -p 1 \
./handlers/... \
./store/sqlite/...
echo "✓ SQLite integration tests complete"
# ── Stage 1c: Go Test (Postgres) ─────────────
# Tests ONLY Postgres-dependent packages: store/postgres and
# handlers (with PG driver). Runs in parallel with test-sqlite.
#
# Coverage: ./store/postgres/..., ./handlers/... (PG driver).
# Handlers are intentionally tested against BOTH drivers.
#
# Runs when: backend files changed or infra changed.
# Skipped when: only frontend or docs changed.
test-go-pg:
runs-on: ubuntu-latest
needs: [detect-changes]
if: needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.infra == 'true'
@@ -264,14 +342,19 @@ jobs:
psql -d "${DB_NAME}" -c "ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO ${APP_USER};"
echo "✓ CI test database ready"
- name: Run tests
- name: Run Postgres integration tests
working-directory: server
env:
PGHOST: ${{ env.POSTGRES_HOST }}
PGPORT: ${{ env.POSTGRES_PORT }}
PGUSER: ${{ secrets.POSTGRES_USER }}
PGPASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
run: go test -v -race -count=1 -p 1 ./...
run: |
echo "━━━ Postgres Integration Tests ━━━"
go test -v -race -count=1 -p 1 \
./store/postgres/... \
./handlers/...
echo "✓ Postgres integration tests complete"
- name: Drop CI test database
if: always()
@@ -284,72 +367,6 @@ jobs:
psql -c "DROP DATABASE IF EXISTS chat_switchboard_ci;" postgres
echo "✓ Dropped CI test database"
- name: Build check
working-directory: server
run: CGO_ENABLED=0 go build -o /dev/null .
# ── Stage 1c: Go Build & Test (SQLite) ───────
# Verifies SQLite backend compiles, stores work, and handler
# integration tests pass against an in-memory SQLite database.
# No external database or provider keys required.
#
# Runs when: backend files changed or infra changed.
# Skipped when: only frontend or docs changed.
test-sqlite:
runs-on: ubuntu-latest
needs: [detect-changes]
if: needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.infra == 'true'
env:
GOPRIVATE: git.gobha.me/*
GONOSUMCHECK: git.gobha.me/*
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Download and tidy
working-directory: server
run: |
go mod download
go mod tidy
- name: Build check (CGO_ENABLED=0)
working-directory: server
run: |
echo "━━━ SQLite Backend Build Check ━━━"
CGO_ENABLED=0 go build -o /dev/null .
echo "✓ Binary compiles with SQLite backend (pure Go, no CGO)"
- name: Run unit tests (no DB)
working-directory: server
run: |
echo "━━━ Unit Tests (no external DB) ━━━"
go test -v -count=1 -p 1 \
./capabilities/... \
./compaction/... \
./crypto/... \
./events/... \
./extraction/... \
./knowledge/... \
./providers/... \
./tools/...
echo "✓ Unit tests complete"
- name: Run SQLite handler integration tests
working-directory: server
env:
DB_DRIVER: sqlite
run: |
echo "━━━ SQLite Integration Tests (handlers + stores) ━━━"
go test -v -count=1 -p 1 \
./handlers/... \
./store/sqlite/...
echo "✓ SQLite integration tests complete"
# ── Stage 2: Build, Database, Deploy ─────────
#
# Depends on all test jobs. Skipped jobs (due to path gating)
@@ -358,7 +375,7 @@ jobs:
# Skipped entirely for docs-only changes (nothing to build).
build-and-deploy:
runs-on: ubuntu-latest
needs: [detect-changes, test, test-frontend, test-sqlite]
needs: [detect-changes, test-go-pg, test-frontend, test-sqlite]
# Run unless: a needed job failed, the workflow was cancelled, or it's docs-only.
# Skipped test jobs (path-gated) are fine — they don't block.
if: |
@@ -773,4 +790,4 @@ jobs:
fi
if [[ "${{ steps.env.outputs.is_release }}" == "true" ]]; then
echo "| **Docker Hub** | \`${DOCKERHUB_IMAGE}:${{ steps.env.outputs.EXTRA_TAG }}\` (unified) |" >> $GITHUB_STEP_SUMMARY
fi
fi