diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8ba1f38 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,110 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Lint & Type Check + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run Ruff check + run: ruff check . + + - name: Run Ruff format check + run: ruff format --check . + + - name: Run Mypy + run: mypy agentkit tests + + test: + name: Test (Python ${{ matrix.python-version }}) + runs-on: ubuntu-latest + needs: [lint] + strategy: + fail-fast: false + matrix: + python-version: ["3.11", "3.12"] + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: agentkit + POSTGRES_PASSWORD: agentkit_password + POSTGRES_DB: agentkit_test + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis:7-alpine + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + ENVIRONMENT: test + DATABASE_URL: postgresql+asyncpg://agentkit:agentkit_password@localhost:5432/agentkit_test + DATABASE_TEST_URL: postgresql+asyncpg://agentkit:agentkit_password@localhost:5432/agentkit_test + REDIS_URL: redis://localhost:6379/0 + GEMINI_API_KEY: fake_gemini_key_for_testing + OPENAI_API_KEY: fake_openai_key_for_testing + TAVILY_API_KEY: fake_tavily_key_for_testing + API_KEYS: test_api_key_1,test_api_key_2 + JWT_SECRET: test_secret_key_at_least_32_bytes_long + PYTHONPATH: . + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: "pip" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run Alembic migrations + run: alembic upgrade head + + - name: Run pytest with coverage + run: | + pytest -v --cov=agentkit --cov-report=term-missing --cov-report=xml --cov-fail-under=85 + + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + if: matrix.python-version == '3.12' + with: + name: coverage-report + path: coverage.xml