Python SDK #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: | |
| - "packages/py/**" | |
| - ".github/workflows/python-ci.yml" | |
| pull_request: | |
| branches: [main, master] | |
| paths: | |
| - "packages/py/**" | |
| - ".github/workflows/python-ci.yml" | |
| defaults: | |
| run: | |
| working-directory: packages/py | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Set up Python ${{ matrix.python-version }} | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv sync --all-packages | |
| - name: Run linting | |
| run: uv run ruff check . | |
| - name: Run formatting check | |
| run: uv run ruff format --check . | |
| - name: Run type checking | |
| run: uv run mypy sdk/src/context7 | |
| - name: Run tests | |
| env: | |
| CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} | |
| run: uv run pytest sdk/tests -v --cov=context7 --cov-report=xml | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Build package | |
| working-directory: packages/py/sdk | |
| run: uv build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-sdk-dist | |
| path: packages/py/sdk/dist/ | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [test, build] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| environment: pypi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-sdk-dist | |
| path: packages/py/sdk/dist/ | |
| - name: Publish to PyPI | |
| working-directory: packages/py/sdk | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
| run: uv publish |