Phase 0: bootstrap the Warp homeserver
Scaffolds the server module and everything Phase 0 of PLAN.md calls for: a binary that boots, serves its discovery endpoints and nothing else yet. - config: one YAML file plus per-field WARP_* environment overrides, unknown fields rejected, validation that reports every problem at once - logging and metrics: slog, a Prometheus registry, per-route HTTP instrumentation labelled by pattern rather than path - httputil: the Matrix error envelope, error-returning handlers, CORS, request logging, panic recovery, and a router over http.ServeMux - endpoints: /_matrix/client/versions, /.well-known/matrix/client, /.well-known/matrix/server (gated), /healthz, /metrics, and M_UNRECOGNIZED for everything else - storage: driver registry, shared database/sql base, checksummed migration runner, sqlite and postgres drivers, pocketbase stub - settings: server_settings table behind a cached service, so the federation and registration switches change without a restart - federation: the gate that makes federation a runtime mode - cmd/warp: serve, migrate, generate-keys, version - Makefile, golangci-lint v2, GitHub Actions CI (Linux and Windows tests, race on Linux, storage tests against PostgreSQL, lint, boot smoke test), Dockerfile, example config and docs Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
b4fb60a8ab
50 files changed
+5672
No files matched your search
@@ -0,0 +1,159 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GO_VERSION: "1.26"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Verify formatting
|
||||
if: runner.os == 'Linux'
|
||||
working-directory: server
|
||||
run: |
|
||||
unformatted="$(gofmt -l .)"
|
||||
if [ -n "$unformatted" ]; then
|
||||
echo "These files need gofmt:"
|
||||
echo "$unformatted"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Verify go.mod is tidy
|
||||
if: runner.os == 'Linux'
|
||||
working-directory: server
|
||||
run: |
|
||||
go mod tidy
|
||||
git diff --exit-code -- go.mod go.sum
|
||||
|
||||
- name: Vet
|
||||
working-directory: server
|
||||
run: go vet ./...
|
||||
|
||||
- name: Test
|
||||
working-directory: server
|
||||
run: go test -count=1 ./...
|
||||
|
||||
- name: Test with the race detector
|
||||
if: runner.os == 'Linux'
|
||||
working-directory: server
|
||||
run: go test -race -count=1 ./...
|
||||
|
||||
- name: Build
|
||||
working-directory: server
|
||||
run: go build ./...
|
||||
|
||||
postgres:
|
||||
name: Storage tests on PostgreSQL
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16
|
||||
env:
|
||||
POSTGRES_USER: warp
|
||||
POSTGRES_PASSWORD: warp
|
||||
POSTGRES_DB: warp_test
|
||||
ports: ["5432:5432"]
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Storage tests (sqlite + postgres)
|
||||
working-directory: server
|
||||
env:
|
||||
WARP_TEST_POSTGRES_DSN: postgres://warp:warp@localhost:5432/warp_test?sslmode=disable
|
||||
run: go test -count=1 ./internal/storage/...
|
||||
|
||||
lint:
|
||||
name: golangci-lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v2.14.0
|
||||
working-directory: server
|
||||
|
||||
smoke:
|
||||
name: Smoke test the binary
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Build
|
||||
run: make build
|
||||
|
||||
- name: Generate a signing key and boot the server
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sed 's/^ server_name: .*/ server_name: ci.example/' warp.yaml.example > warp.yaml
|
||||
./bin/warp version
|
||||
./bin/warp generate-keys
|
||||
./bin/warp migrate
|
||||
./bin/warp serve &
|
||||
server_pid=$!
|
||||
trap 'kill "$server_pid" 2>/dev/null || true' EXIT
|
||||
|
||||
for _ in $(seq 1 30); do
|
||||
if curl -fsS http://127.0.0.1:8008/healthz >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
curl -fsS http://127.0.0.1:8008/healthz | tee /dev/stderr | grep -q '"status":"ok"'
|
||||
curl -fsS http://127.0.0.1:8008/_matrix/client/versions | grep -q '"versions"'
|
||||
curl -fsS http://127.0.0.1:8008/.well-known/matrix/client | grep -q 'm.homeserver'
|
||||
curl -fsS http://127.0.0.1:8008/metrics | grep -q warp_build_info
|
||||
|
||||
# Federation is off by default, so its surface must be absent.
|
||||
status="$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8008/.well-known/matrix/server)"
|
||||
test "$status" = "404"
|
||||
|
||||
# Graceful shutdown: SIGTERM must stop the process cleanly.
|
||||
kill -TERM "$server_pid"
|
||||
wait "$server_pid"
|
||||
Reference in new issue
Block a user