Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | name: Test Python SDK |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [master, next, main] |
| 6 | paths: |
| 7 | - 'python/**/*.py' |
| 8 | - 'python/**/*.json' |
| 9 | - '.github/workflows/py.test.yml' |
| 10 | - '.github/actions/setup-python-uv/action.yml' |
| 11 | - 'mise.toml' |
| 12 | - 'mise.lock' |
| 13 | - 'toolchain-versions.json' |
| 14 | - 'python/pyproject.toml' |
| 15 | - 'uv.lock' |
| 16 | - 'python/requirements*.txt' |
| 17 | # The TypeSafe provider tests read the question corpus of the TypeScript provider. |
| 18 | - 'ts/packages/providers/typesafe/test/fixtures/question-corpus.json' |
| 19 | pull_request: |
| 20 | branches: [master, next, main] |
| 21 | paths: |
| 22 | - 'python/**/*.py' |
| 23 | - 'python/**/*.json' |
| 24 | - '.github/workflows/py.test.yml' |
| 25 | - '.github/actions/setup-python-uv/action.yml' |
| 26 | - 'mise.toml' |
| 27 | - 'mise.lock' |
| 28 | - 'toolchain-versions.json' |
| 29 | - 'python/pyproject.toml' |
| 30 | - 'uv.lock' |
| 31 | - 'python/requirements*.txt' |
| 32 | # The TypeSafe provider tests read the question corpus of the TypeScript provider. |
| 33 | - 'ts/packages/providers/typesafe/test/fixtures/question-corpus.json' |
| 34 | |
| 35 | concurrency: |
| 36 | group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} |
| 37 | cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 38 | |
| 39 | permissions: |
| 40 | contents: read |
| 41 | |
| 42 | jobs: |
| 43 | toolchain-versions: |
| 44 | name: Read toolchain test matrix |
| 45 | runs-on: ubuntu-latest |
| 46 | outputs: |
| 47 | python: ${{ steps.versions.outputs.python }} |
| 48 | steps: |
| 49 | - name: Checkout Code |
| 50 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 51 | |
| 52 | - name: Read versions |
| 53 | id: versions |
| 54 | run: echo "python=$(jq -c '.python' toolchain-versions.json)" >> "$GITHUB_OUTPUT" |
| 55 | |
| 56 | test: |
| 57 | name: Test Python SDK (${{ matrix.python-version }}) |
| 58 | needs: toolchain-versions |
| 59 | runs-on: ubuntu-latest |
| 60 | strategy: |
| 61 | matrix: |
| 62 | python-version: ${{ fromJSON(needs.toolchain-versions.outputs.python) }} |
| 63 | include: |
| 64 | - python-version: '3.15' |
| 65 | excluded-packages: 'crewai langchain langgraph' |
| 66 | |
| 67 | steps: |
| 68 | - name: Checkout Code |
| 69 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 70 | |
| 71 | - name: Set up Python ${{ matrix.python-version }} |
| 72 | uses: ./.github/actions/setup-python-uv |
| 73 | with: |
| 74 | python-version: ${{ matrix.python-version }} |
| 75 | |
| 76 | - name: Install Dependencies |
| 77 | env: |
| 78 | EXCLUDED_PACKAGES: ${{ matrix.excluded-packages }} |
| 79 | run: | |
| 80 | cd python/ |
| 81 | uv venv --python ${{ matrix.python-version }} |
| 82 | source .venv/bin/activate |
| 83 | uv pip install -e . |
| 84 | expected="" |
| 85 | for provider in crewai langchain langgraph gemini google openai_agents claude_agent_sdk anthropic google_adk llamaindex; do |
| 86 | if [[ " $EXCLUDED_PACKAGES " != *" $provider "* ]]; then |
| 87 | uv pip install -e "providers/$provider" |
| 88 | expected="$expected $provider" |
| 89 | fi |
| 90 | done |
| 91 | # The free-form argument matrix fails, rather than skips, for every |
| 92 | # provider this leg installs. |
| 93 | echo "COMPOSIO_EXPECTED_PROVIDERS=$expected" >> "$GITHUB_ENV" |
| 94 | uv pip install hypothesis pytest pytest-mock |
| 95 | |
| 96 | - name: Run Import Tests |
| 97 | run: | |
| 98 | cd python/ |
| 99 | source .venv/bin/activate |
| 100 | python -c "from composio import Composio; print('✓ Basic import successful')" |
| 101 | # The Gemini and Google provider tests skip when these are missing, so |
| 102 | # fail here instead of letting the unit tests skip silently. |
| 103 | python -c "import composio_gemini, composio_google, google.genai; print('✓ Gemini and Google provider imports successful')" |
| 104 | python -c "import composio_google_adk, composio_llamaindex; print('✓ Google ADK and LlamaIndex provider imports successful')" |
| 105 | |
| 106 | - name: Test Autogen Provider Installation |
| 107 | run: | |
| 108 | cd python/ |
| 109 | # autogen-core requires protobuf 5, while CrewAI's telemetry stack |
| 110 | # requires protobuf 6. Test the independently distributed provider in |
| 111 | # its own environment instead of constructing an invalid combination. |
| 112 | uv venv autogen-env --python ${{ matrix.python-version }} |
| 113 | source autogen-env/bin/activate |
| 114 | uv pip install -e . -e providers/autogen pytest pytest-mock |
| 115 | python -c "import composio_autogen; print('✓ Autogen provider import successful')" |
| 116 | COMPOSIO_EXPECTED_PROVIDERS=autogen python -m pytest \ |
| 117 | tests/test_provider.py::TestAgenticSkipDefaultsParity::test_autogen_signature_honors_skip_defaults \ |
| 118 | tests/test_provider.py::TestAgenticSkipDefaultsParity::test_autogen_signature_preserves_default \ |
| 119 | tests/test_provider_argument_serialization.py \ |
| 120 | -v --tb=short |
| 121 | |
| 122 | - name: Test TypeSafe Provider |
| 123 | run: | |
| 124 | cd python/ |
| 125 | # The main environment does not install this provider, and its tests use |
| 126 | # pytest.importorskip, so they would skip silently there. |
| 127 | uv venv typesafe-env --python ${{ matrix.python-version }} |
| 128 | source typesafe-env/bin/activate |
| 129 | uv pip install -e . -e providers/typesafe hypothesis pytest pytest-mock |
| 130 | python -c "import composio_typesafe; print('✓ TypeSafe provider import successful')" |
| 131 | python -m pytest tests/test_typesafe_provider.py -v --tb=short |
| 132 | |
| 133 | - name: Run Unit Tests |
| 134 | run: | |
| 135 | cd python/ |
| 136 | source .venv/bin/activate |
| 137 | python -m pytest tests/ -v --tb=short |
| 138 | |
| 139 | - name: Run Provider Package Tests |
| 140 | run: | |
| 141 | cd python/ |
| 142 | source .venv/bin/activate |
| 143 | # Separate runs: these files share the `test_provider.py` basename |
| 144 | # with tests/, which pytest cannot collect in a single session. |
| 145 | python -m pytest providers/openai_agents/tests -v --tb=short |
| 146 | python -m pytest providers/claude_agent_sdk/tests -v --tb=short |
| 147 | python -m pytest providers/anthropic/tests -v --tb=short |
| 148 | |
| 149 | - name: Test Package Installation |
| 150 | run: | |
| 151 | cd python/ |
| 152 | # Test that the package can be installed and imported in a fresh environment |
| 153 | uv venv test-env --python ${{ matrix.python-version }} |
| 154 | source test-env/bin/activate |
| 155 | uv pip install -e . |
| 156 | python -c " |
| 157 | from composio import Composio, ToolkitVersionParam |
| 158 | from composio.types import Modifiers |
| 159 | from composio.core.types import ToolkitVersion |
| 160 | print('✓ All critical imports successful') |
| 161 | " |
| 162 | |
| 163 | test-circular-imports: |
| 164 | name: Test Circular Import Prevention |
| 165 | runs-on: ubuntu-latest |
| 166 | |
| 167 | steps: |
| 168 | - name: Checkout Code |
| 169 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 170 | |
| 171 | - name: Setup Python with UV |
| 172 | uses: ./.github/actions/setup-python-uv |
| 173 | |
| 174 | - name: Install Dependencies |
| 175 | run: | |
| 176 | cd python/ |
| 177 | uv venv |
| 178 | source .venv/bin/activate |
| 179 | uv pip install -e . |
| 180 | |
| 181 | - name: Test Circular Import Prevention |
| 182 | run: | |
| 183 | cd python/ |
| 184 | source .venv/bin/activate |
| 185 | python -c " |
| 186 | # Test various import combinations that previously caused circular imports |
| 187 | import sys |
| 188 | |
| 189 | # Test 1: Basic imports |
| 190 | from composio import Composio |
| 191 | print('✓ Basic Composio import') |
| 192 | |
| 193 | # Test 2: Import toolkit version types |
| 194 | from composio import ToolkitVersionParam |
| 195 | from composio.core.types import ToolkitVersion |
| 196 | print('✓ Toolkit version types import') |
| 197 | |
| 198 | # Test 3: Import from types module |
| 199 | from composio.types import Modifiers |
| 200 | print('✓ Types module import') |
| 201 | |
| 202 | # Test 4: Import core models |
| 203 | from composio.core.models.tools import Tools |
| 204 | print('✓ Core models import') |
| 205 | |
| 206 | # Test 5: Cross-module imports that caused the original circular import |
| 207 | from composio.core.models.tools import Modifiers as CoreModifiers |
| 208 | from composio.types import Modifiers as TypesModifiers |
| 209 | assert CoreModifiers is TypesModifiers |
| 210 | print('✓ Cross-module import consistency') |
| 211 | |
| 212 | print('✓ All circular import prevention tests passed!') |
| 213 | " |
| 214 | |
| 215 | lint-and-format: |
| 216 | name: Lint and Format Check |
| 217 | runs-on: ubuntu-latest |
| 218 | |
| 219 | steps: |
| 220 | - name: Checkout Code |
| 221 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 222 | |
| 223 | - name: Setup Python with UV |
| 224 | uses: ./.github/actions/setup-python-uv |
| 225 | |
| 226 | - name: Install Dependencies |
| 227 | run: | |
| 228 | cd python/ |
| 229 | uv venv |
| 230 | source .venv/bin/activate |
| 231 | uv pip install -e . |
| 232 | uv pip install ruff |
| 233 | |
| 234 | - name: Run Ruff Linter |
| 235 | run: | |
| 236 | cd python/ |
| 237 | source .venv/bin/activate |
| 238 | ruff check --config config/ruff.toml composio/ tests/ |
| 239 | ruff check --config config/ruff.toml examples/approvals.py examples/verify_approvals.py |
| 240 | |
| 241 | - name: Run Ruff Formatter Check |
| 242 | run: | |
| 243 | cd python/ |
| 244 | source .venv/bin/activate |
| 245 | ruff format --check --config config/ruff.toml composio/ tests/ |
| 246 | ruff format --check --config config/ruff.toml examples/approvals.py examples/verify_approvals.py |
| 247 | |
| 248 | integration-tests: |
| 249 | name: Integration Tests |
| 250 | runs-on: ubuntu-22.04 # Use Ubuntu 22.04 for stability |
| 251 | permissions: read-all |
| 252 | env: |
| 253 | COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }} |
| 254 | COMPOSIO_BASE_URL: ${{ secrets.COMPOSIO_BASE_URL_STAGING }} |
| 255 | |
| 256 | steps: |
| 257 | - name: Checkout repository |
| 258 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 259 | |
| 260 | - name: Install UV |
| 261 | id: setup-python |
| 262 | uses: ./.github/actions/setup-python-uv |
| 263 | |
| 264 | - name: Install Python Dependencies |
| 265 | working-directory: ./python |
| 266 | run: | |
| 267 | # Let UV manage Python version to satisfy workspace requirements |
| 268 | uv sync --group dev |
| 269 | |
| 270 | - name: Check API key |
| 271 | id: api-key |
| 272 | env: |
| 273 | # A pull request from a fork cannot read repository secrets, so the |
| 274 | # key is missing for a reason no contributor can fix. Skip the way |
| 275 | # Dependabot does rather than failing their PR. |
| 276 | IS_FORK_PR: ${{ github.event.pull_request.head.repo.fork || false }} |
| 277 | run: | |
| 278 | if [ -z "$COMPOSIO_API_KEY" ]; then |
| 279 | echo "available=false" >> "$GITHUB_OUTPUT" |
| 280 | if [ "$GITHUB_ACTOR" = "dependabot[bot]" ]; then |
| 281 | echo "::notice::Skipping secret-backed Python integration tests for Dependabot; missing COMPOSIO_API_KEY." |
| 282 | exit 0 |
| 283 | fi |
| 284 | if [ "$IS_FORK_PR" = "true" ]; then |
| 285 | echo "::notice::Skipping secret-backed Python integration tests for a pull request from a fork; repository secrets are not available to it." |
| 286 | exit 0 |
| 287 | fi |
| 288 | |
| 289 | echo "::error::COMPOSIO_API_KEY is not set" |
| 290 | exit 1 |
| 291 | fi |
| 292 | |
| 293 | echo "available=true" >> "$GITHUB_OUTPUT" |
| 294 | echo "✅ API key is configured" |
| 295 | |
| 296 | - name: Run Integration Tests |
| 297 | if: steps.api-key.outputs.available == 'true' |
| 298 | working-directory: ./python |
| 299 | run: | |
| 300 | echo "🧪 Running Integration Tests..." |
| 301 | # Run with per-test timeout of 2 minutes and overall timeout |
| 302 | # pytest-timeout should be installed via pyproject.toml dev dependencies |
| 303 | uv run pytest composio/integration_test/ -v --tb=short --maxfail=3 --timeout=120 --timeout-method=thread |
| 304 | timeout-minutes: 10 |
| 305 | |
| 306 | - name: Upload Test Results |
| 307 | if: always() |
| 308 | uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 309 | with: |
| 310 | name: integration-test-results |
| 311 | path: | |
| 312 | python/composio/integration_test/ |
| 313 | retention-days: 7 |