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
inmemorypersistence 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 -qAll Services
bash scripts/run_backend_tests.shThis iterates through all 8 services and runs their test suites sequentially.
Frontend
cd apps/client-web
npm install
npm testTest 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 modulesTests 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 -qindependently fail-fast: falseensures 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
| Script | Purpose |
|---|---|
scripts/deploy_backend_cloudrun.sh | Deploy all services to Google Cloud Run |
scripts/deploy_frontend_cloudrun.sh | Build and deploy the frontend to Cloud Run |
scripts/build_backend_images.sh | Build Docker images for all services |
scripts/smoke_compose.sh | Health-check all services after docker compose up |
Validation Tools
Production Readiness Check
python ops/validate_production_readiness.pyThis script validates environment configuration, service connectivity, and security settings for production deployment.