name: Test on: pull_request: push: branches: - "main" jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e ".[dev]" - name: Run tests run: | python -m pytest tests/ -v --cov=claude_agent_sdk --cov-report=xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: file: ./coverage.xml fail_ci_if_error: false test-e2e: runs-on: ubuntu-latest needs: test # Run after unit tests pass strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Claude Code run: | curl -fsSL https://claude.ai/install.sh | bash echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Verify Claude Code installation run: claude -v - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e ".[dev]" - name: Run end-to-end tests with real API env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | python -m pytest e2e-tests/ -v -m e2e test-examples: runs-on: ubuntu-latest needs: test-e2e # Run after e2e tests strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install Claude Code run: | curl -fsSL https://claude.ai/install.sh | bash echo "$HOME/.local/bin" >> $GITHUB_PATH - name: Verify Claude Code installation run: claude -v - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e . - name: Run example scripts env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | python examples/quick_start.py timeout 120 python examples/streaming_mode.py all