For Teams

CI/CD Integration

Replace slow Docker resets with millisecond session wipes.

GitHub Actions

yaml
name: Test
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    services:
      astapa:
        image: ghcr.io/aprdos/astapa-proxy:latest
        env:
          DATABASE_URL: postgres://user:pass@postgres:5432/testdb
        ports:
          - 5433:5433
          - 8080:8080
      postgres:
        image: postgres:16
        env:
          POSTGRES_PASSWORD: pass
          POSTGRES_USER: user
          POSTGRES_DB: testdb
        ports:
          - 5432:5432

    steps:
      - uses: actions/checkout@v4

      - name: Run tests
        env:
          DATABASE_URL: postgres://user:pass@localhost:5433/testdb
          ASTAPA_API: http://localhost:8080
        run: |
          pip install -r requirements.txt
          pytest

Test with sessions

python
import pytest
from astapa import Astapa

astapa = Astapa(api_url="http://localhost:8080")

@pytest.fixture
def db_session():
    """Each test gets an isolated session."""
    session = astapa.create_session(project_id="ci-test")
    session.connect(database="testdb", user="user", password="pass")
    yield session
    session.reject()  # Discard changes after test

def test_create_user(db_session):
    db_session.execute("INSERT INTO users (name) VALUES ('Alice')")
    result = db_session.execute("SELECT * FROM users WHERE name = 'Alice'")
    assert len(result) == 1

def test_update_user(db_session):
    # Fresh session - no Alice from previous test
    db_session.execute("INSERT INTO users (name) VALUES ('Bob')")
    db_session.execute("UPDATE users SET name = 'Robert' WHERE name = 'Bob'")
    result = db_session.execute("SELECT * FROM users WHERE name = 'Robert'")
    assert len(result) == 1

GitLab CI

yaml
test:
  image: python:3.11
  services:
    - name: postgres:16
      alias: postgres
    - name: astapa/proxy:latest
      alias: astapa
      variables:
        DATABASE_URL: postgres://user:pass@postgres:5432/testdb

  variables:
    DATABASE_URL: postgres://user:pass@astapa:5433/testdb
    ASTAPA_API: http://astapa:8080

  script:
    - pip install -r requirements.txt
    - pytest

Benefits

Before: Docker reset
~30s per test suite to rebuild container
After: Session wipe
~5ms per test - just reject the session