AnyaSelf Docs

Testing & CI/CD

Test strategy, running tests, and the continuous integration pipeline.

Testing Philosophy

All AnyaSelf backend services follow a hermetic testing approach:

  • External dependencies (Vertex AI, Firestore, Hyperbeam, GCS) are fully mocked
  • Tests run against the inmemory persistence backend
  • No network calls are made during test execution
  • Every service has its own isolated tests/ directory

Running Tests

Single Service

cd services/api-gateway
pip install -r requirements.txt
pytest -q

All Services

bash scripts/run_backend_tests.sh

This iterates through all 8 services and runs their test suites sequentially.

Frontend

cd apps/client-web
npm install
npm test

Test Structure

Each service mirrors the same test layout:

services/{service-name}/
├── src/
│   ├── api/routes.py          # Endpoints under test
│   ├── domain/models.py       # Pydantic models
│   ├── repositories/          # Storage layer
│   └── services/              # Business logic
└── tests/
    ├── conftest.py             # Shared fixtures (test client, mock repos)
    └── test_*.py               # Test modules

Tests typically use the FastAPI TestClient to make HTTP requests against the app with mocked dependencies injected via app.dependency_overrides.

CI Pipeline

The project uses GitHub Actions (.github/workflows/backend-ci.yml) with a two-stage pipeline:

Stage 1: Test Matrix

strategy:
  fail-fast: false
  matrix:
    service:
      - api-gateway
      - artifacts-audit
      - commerce
      - headless-cartprep
      - hyperbeam-bridge
      - orchestrator
      - vto
      - wardrobe
  • Python 3.12 on ubuntu-latest
  • Each service runs pytest -q independently
  • fail-fast: false ensures all services are tested even if one fails
  • Triggered on every push and pull request to paths under new_project/

Stage 2: Docker Build

After tests pass, the pipeline builds Docker images for all 8 services to verify Dockerfile correctness:

docker build \
  -f services/{service}/Dockerfile \
  -t anyaself/{service}:ci \
  services/{service}

Production Deployment Scripts

ScriptPurpose
scripts/deploy_backend_cloudrun.shDeploy all services to Google Cloud Run
scripts/deploy_frontend_cloudrun.shBuild and deploy the frontend to Cloud Run
scripts/build_backend_images.shBuild Docker images for all services
scripts/smoke_compose.shHealth-check all services after docker compose up

Validation Tools

Production Readiness Check

python ops/validate_production_readiness.py

This script validates environment configuration, service connectivity, and security settings for production deployment.

On this page