caelum0x 8449f89be9 test: add integration suite against real Postgres + Redis
- test-integration/flows.test.ts: 8 end-to-end flows through the app with
  no mocks — onboarding + deck save, refresh-token rotation, matchmaking
  pairing (verifies deckId survives the match transition), and match
  completion -> leaderboard with idempotency.
- vitest.integration.config.ts: isolated Redis logical DB, real DATABASE_URL;
  serial execution with per-test truncate/flush.
- package.json: test:integration script.
- docker-compose.yml: add a postgres service for local dev/integration.
- services-ci.yml: GitHub Actions job running unit + integration tests with
  Postgres/Redis service containers on every services/ PR.
- DEVELOPMENT.md: document the integration workflow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 18:19:12 +03:00

62 lines
1.7 KiB
YAML

name: Services CI
on:
push:
branches: [main]
paths: ["services/**"]
pull_request:
paths: ["services/**"]
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: services
# Real Postgres + Redis so the integration suite exercises actual DB
# queries, FKs, transactions, and Redis sorted-sets — not mocks.
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: siegebreak_test
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 10
redis:
image: redis:7-alpine
ports: ["6379:6379"]
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/siegebreak_test
REDIS_URL: redis://localhost:6379/15
JWT_SECRET: ci-secret
MATCH_SERVER_SECRET: ci-server-secret
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: services/package-lock.json
- run: npm ci
- run: npx prisma generate --schema src/db/schema.prisma
- run: npm run typecheck
- run: npm test # unit tests (mocked deps)
- run: npx prisma migrate deploy --schema src/db/schema.prisma
- run: npm run seed
- run: npm run test:integration # real Postgres + Redis