|
| 1 | +name: Agent Memory Client CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: |
| 7 | + - 'client/v*.*.*' |
| 8 | + pull_request: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + name: Test (Python ${{ matrix.python-version }}) |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + python-version: ["3.10", "3.11", "3.12"] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v4 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v3 |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + working-directory: agent-memory-client |
| 32 | + run: uv sync --extra dev |
| 33 | + |
| 34 | + - name: Lint with Ruff |
| 35 | + working-directory: agent-memory-client |
| 36 | + run: uv run ruff check agent_memory_client |
| 37 | + |
| 38 | + - name: Check formatting with Ruff formatter |
| 39 | + working-directory: agent-memory-client |
| 40 | + run: uv run ruff format --check agent_memory_client |
| 41 | + |
| 42 | + - name: Type check with mypy |
| 43 | + working-directory: agent-memory-client |
| 44 | + run: uv run mypy agent_memory_client |
| 45 | + |
| 46 | + - name: Run tests |
| 47 | + working-directory: agent-memory-client |
| 48 | + run: uv run pytest tests/ --cov=agent_memory_client --cov-report=xml |
| 49 | + |
| 50 | + publish-testpypi: |
| 51 | + name: Publish to TestPyPI |
| 52 | + needs: test |
| 53 | + if: startsWith(github.ref, 'refs/tags/client/') && contains(github.ref, '-') |
| 54 | + runs-on: ubuntu-latest |
| 55 | + environment: testpypi |
| 56 | + permissions: |
| 57 | + id-token: write |
| 58 | + contents: read |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Set up Python |
| 63 | + uses: actions/setup-python@v4 |
| 64 | + with: |
| 65 | + python-version: '3.12' |
| 66 | + |
| 67 | + - name: Install build tools |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + pip install build |
| 71 | +
|
| 72 | + - name: Build package |
| 73 | + working-directory: agent-memory-client |
| 74 | + run: python -m build |
| 75 | + |
| 76 | + - name: Publish package to TestPyPI |
| 77 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 78 | + with: |
| 79 | + repository-url: https://test.pypi.org/legacy/ |
| 80 | + packages-dir: agent-memory-client/dist/ |
| 81 | + |
| 82 | + publish-pypi: |
| 83 | + name: Publish to PyPI |
| 84 | + needs: test |
| 85 | + if: startsWith(github.ref, 'refs/tags/client/') && !contains(github.ref, '-') |
| 86 | + runs-on: ubuntu-latest |
| 87 | + environment: pypi |
| 88 | + permissions: |
| 89 | + id-token: write |
| 90 | + contents: read |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Set up Python |
| 95 | + uses: actions/setup-python@v4 |
| 96 | + with: |
| 97 | + python-version: '3.12' |
| 98 | + |
| 99 | + - name: Install build tools |
| 100 | + run: | |
| 101 | + python -m pip install --upgrade pip |
| 102 | + pip install build |
| 103 | +
|
| 104 | + - name: Build package |
| 105 | + working-directory: agent-memory-client |
| 106 | + run: python -m build |
| 107 | + |
| 108 | + - name: Publish package to PyPI |
| 109 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 110 | + with: |
| 111 | + packages-dir: agent-memory-client/dist/ |
| 112 | + |
| 113 | +# Alternative: API Token Authentication (if trusted publishing doesn't work) |
| 114 | +# Uncomment the sections below and add these secrets to your repository: |
| 115 | +# - TEST_PYPI_API_TOKEN (for TestPyPI) |
| 116 | +# - PYPI_API_TOKEN (for PyPI) |
| 117 | +# |
| 118 | +# For TestPyPI job, replace the publish step with: |
| 119 | +# - name: Publish package to TestPyPI |
| 120 | +# uses: pypa/gh-action-pypi-publish@release/v1 |
| 121 | +# with: |
| 122 | +# repository-url: https://test.pypi.org/legacy/ |
| 123 | +# packages-dir: agent-memory-client/dist/ |
| 124 | +# password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 125 | +# |
| 126 | +# For PyPI job, replace the publish step with: |
| 127 | +# - name: Publish package to PyPI |
| 128 | +# uses: pypa/gh-action-pypi-publish@release/v1 |
| 129 | +# with: |
| 130 | +# packages-dir: agent-memory-client/dist/ |
| 131 | +# password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments